Actualizacion maquina principal
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / bundles / rxjs.umd.js
1 /**
2   @license
3                                  Apache License
4                          Version 2.0, January 2004
5                       http://www.apache.org/licenses/
6
7  TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
9  1. Definitions.
10
11     "License" shall mean the terms and conditions for use, reproduction,
12     and distribution as defined by Sections 1 through 9 of this document.
13
14     "Licensor" shall mean the copyright owner or entity authorized by
15     the copyright owner that is granting the License.
16
17     "Legal Entity" shall mean the union of the acting entity and all
18     other entities that control, are controlled by, or are under common
19     control with that entity. For the purposes of this definition,
20     "control" means (i) the power, direct or indirect, to cause the
21     direction or management of such entity, whether by contract or
22     otherwise, or (ii) ownership of fifty percent (50%) or more of the
23     outstanding shares, or (iii) beneficial ownership of such entity.
24
25     "You" (or "Your") shall mean an individual or Legal Entity
26     exercising permissions granted by this License.
27
28     "Source" form shall mean the preferred form for making modifications,
29     including but not limited to software source code, documentation
30     source, and configuration files.
31
32     "Object" form shall mean any form resulting from mechanical
33     transformation or translation of a Source form, including but
34     not limited to compiled object code, generated documentation,
35     and conversions to other media types.
36
37     "Work" shall mean the work of authorship, whether in Source or
38     Object form, made available under the License, as indicated by a
39     copyright notice that is included in or attached to the work
40     (an example is provided in the Appendix below).
41
42     "Derivative Works" shall mean any work, whether in Source or Object
43     form, that is based on (or derived from) the Work and for which the
44     editorial revisions, annotations, elaborations, or other modifications
45     represent, as a whole, an original work of authorship. For the purposes
46     of this License, Derivative Works shall not include works that remain
47     separable from, or merely link (or bind by name) to the interfaces of,
48     the Work and Derivative Works thereof.
49
50     "Contribution" shall mean any work of authorship, including
51     the original version of the Work and any modifications or additions
52     to that Work or Derivative Works thereof, that is intentionally
53     submitted to Licensor for inclusion in the Work by the copyright owner
54     or by an individual or Legal Entity authorized to submit on behalf of
55     the copyright owner. For the purposes of this definition, "submitted"
56     means any form of electronic, verbal, or written communication sent
57     to the Licensor or its representatives, including but not limited to
58     communication on electronic mailing lists, source code control systems,
59     and issue tracking systems that are managed by, or on behalf of, the
60     Licensor for the purpose of discussing and improving the Work, but
61     excluding communication that is conspicuously marked or otherwise
62     designated in writing by the copyright owner as "Not a Contribution."
63
64     "Contributor" shall mean Licensor and any individual or Legal Entity
65     on behalf of whom a Contribution has been received by Licensor and
66     subsequently incorporated within the Work.
67
68  2. Grant of Copyright License. Subject to the terms and conditions of
69     this License, each Contributor hereby grants to You a perpetual,
70     worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71     copyright license to reproduce, prepare Derivative Works of,
72     publicly display, publicly perform, sublicense, and distribute the
73     Work and such Derivative Works in Source or Object form.
74
75  3. Grant of Patent License. Subject to the terms and conditions of
76     this License, each Contributor hereby grants to You a perpetual,
77     worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78     (except as stated in this section) patent license to make, have made,
79     use, offer to sell, sell, import, and otherwise transfer the Work,
80     where such license applies only to those patent claims licensable
81     by such Contributor that are necessarily infringed by their
82     Contribution(s) alone or by combination of their Contribution(s)
83     with the Work to which such Contribution(s) was submitted. If You
84     institute patent litigation against any entity (including a
85     cross-claim or counterclaim in a lawsuit) alleging that the Work
86     or a Contribution incorporated within the Work constitutes direct
87     or contributory patent infringement, then any patent licenses
88     granted to You under this License for that Work shall terminate
89     as of the date such litigation is filed.
90
91  4. Redistribution. You may reproduce and distribute copies of the
92     Work or Derivative Works thereof in any medium, with or without
93     modifications, and in Source or Object form, provided that You
94     meet the following conditions:
95
96     (a) You must give any other recipients of the Work or
97         Derivative Works a copy of this License; and
98
99     (b) You must cause any modified files to carry prominent notices
100         stating that You changed the files; and
101
102     (c) You must retain, in the Source form of any Derivative Works
103         that You distribute, all copyright, patent, trademark, and
104         attribution notices from the Source form of the Work,
105         excluding those notices that do not pertain to any part of
106         the Derivative Works; and
107
108     (d) If the Work includes a "NOTICE" text file as part of its
109         distribution, then any Derivative Works that You distribute must
110         include a readable copy of the attribution notices contained
111         within such NOTICE file, excluding those notices that do not
112         pertain to any part of the Derivative Works, in at least one
113         of the following places: within a NOTICE text file distributed
114         as part of the Derivative Works; within the Source form or
115         documentation, if provided along with the Derivative Works; or,
116         within a display generated by the Derivative Works, if and
117         wherever such third-party notices normally appear. The contents
118         of the NOTICE file are for informational purposes only and
119         do not modify the License. You may add Your own attribution
120         notices within Derivative Works that You distribute, alongside
121         or as an addendum to the NOTICE text from the Work, provided
122         that such additional attribution notices cannot be construed
123         as modifying the License.
124
125     You may add Your own copyright statement to Your modifications and
126     may provide additional or different license terms and conditions
127     for use, reproduction, or distribution of Your modifications, or
128     for any such Derivative Works as a whole, provided Your use,
129     reproduction, and distribution of the Work otherwise complies with
130     the conditions stated in this License.
131
132  5. Submission of Contributions. Unless You explicitly state otherwise,
133     any Contribution intentionally submitted for inclusion in the Work
134     by You to the Licensor shall be under the terms and conditions of
135     this License, without any additional terms or conditions.
136     Notwithstanding the above, nothing herein shall supersede or modify
137     the terms of any separate license agreement you may have executed
138     with Licensor regarding such Contributions.
139
140  6. Trademarks. This License does not grant permission to use the trade
141     names, trademarks, service marks, or product names of the Licensor,
142     except as required for reasonable and customary use in describing the
143     origin of the Work and reproducing the content of the NOTICE file.
144
145  7. Disclaimer of Warranty. Unless required by applicable law or
146     agreed to in writing, Licensor provides the Work (and each
147     Contributor provides its Contributions) on an "AS IS" BASIS,
148     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149     implied, including, without limitation, any warranties or conditions
150     of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151     PARTICULAR PURPOSE. You are solely responsible for determining the
152     appropriateness of using or redistributing the Work and assume any
153     risks associated with Your exercise of permissions under this License.
154
155  8. Limitation of Liability. In no event and under no legal theory,
156     whether in tort (including negligence), contract, or otherwise,
157     unless required by applicable law (such as deliberate and grossly
158     negligent acts) or agreed to in writing, shall any Contributor be
159     liable to You for damages, including any direct, indirect, special,
160     incidental, or consequential damages of any character arising as a
161     result of this License or out of the use or inability to use the
162     Work (including but not limited to damages for loss of goodwill,
163     work stoppage, computer failure or malfunction, or any and all
164     other commercial damages or losses), even if such Contributor
165     has been advised of the possibility of such damages.
166
167  9. Accepting Warranty or Additional Liability. While redistributing
168     the Work or Derivative Works thereof, You may choose to offer,
169     and charge a fee for, acceptance of support, warranty, indemnity,
170     or other liability obligations and/or rights consistent with this
171     License. However, in accepting such obligations, You may act only
172     on Your own behalf and on Your sole responsibility, not on behalf
173     of any other Contributor, and only if You agree to indemnify,
174     defend, and hold each Contributor harmless for any liability
175     incurred by, or claims asserted against, such Contributor by reason
176     of your accepting any such warranty or additional liability.
177
178  END OF TERMS AND CONDITIONS
179
180  APPENDIX: How to apply the Apache License to your work.
181
182     To apply the Apache License to your work, attach the following
183     boilerplate notice, with the fields enclosed by brackets "[]"
184     replaced with your own identifying information. (Don't include
185     the brackets!)  The text should be enclosed in the appropriate
186     comment syntax for the file format. We also recommend that a
187     file or class name and description of purpose be included on the
188     same "printed page" as the copyright notice for easier
189     identification within third-party archives.
190
191  Copyright (c) 2015-2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors
192
193  Licensed under the Apache License, Version 2.0 (the "License");
194  you may not use this file except in compliance with the License.
195  You may obtain a copy of the License at
196
197      http://www.apache.org/licenses/LICENSE-2.0
198
199  Unless required by applicable law or agreed to in writing, software
200  distributed under the License is distributed on an "AS IS" BASIS,
201  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202  See the License for the specific language governing permissions and
203  limitations under the License.
204  
205
206  **/
207 /**
208   @license
209                                  Apache License
210                          Version 2.0, January 2004
211                       http://www.apache.org/licenses/
212
213  TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
214
215  1. Definitions.
216
217     "License" shall mean the terms and conditions for use, reproduction,
218     and distribution as defined by Sections 1 through 9 of this document.
219
220     "Licensor" shall mean the copyright owner or entity authorized by
221     the copyright owner that is granting the License.
222
223     "Legal Entity" shall mean the union of the acting entity and all
224     other entities that control, are controlled by, or are under common
225     control with that entity. For the purposes of this definition,
226     "control" means (i) the power, direct or indirect, to cause the
227     direction or management of such entity, whether by contract or
228     otherwise, or (ii) ownership of fifty percent (50%) or more of the
229     outstanding shares, or (iii) beneficial ownership of such entity.
230
231     "You" (or "Your") shall mean an individual or Legal Entity
232     exercising permissions granted by this License.
233
234     "Source" form shall mean the preferred form for making modifications,
235     including but not limited to software source code, documentation
236     source, and configuration files.
237
238     "Object" form shall mean any form resulting from mechanical
239     transformation or translation of a Source form, including but
240     not limited to compiled object code, generated documentation,
241     and conversions to other media types.
242
243     "Work" shall mean the work of authorship, whether in Source or
244     Object form, made available under the License, as indicated by a
245     copyright notice that is included in or attached to the work
246     (an example is provided in the Appendix below).
247
248     "Derivative Works" shall mean any work, whether in Source or Object
249     form, that is based on (or derived from) the Work and for which the
250     editorial revisions, annotations, elaborations, or other modifications
251     represent, as a whole, an original work of authorship. For the purposes
252     of this License, Derivative Works shall not include works that remain
253     separable from, or merely link (or bind by name) to the interfaces of,
254     the Work and Derivative Works thereof.
255
256     "Contribution" shall mean any work of authorship, including
257     the original version of the Work and any modifications or additions
258     to that Work or Derivative Works thereof, that is intentionally
259     submitted to Licensor for inclusion in the Work by the copyright owner
260     or by an individual or Legal Entity authorized to submit on behalf of
261     the copyright owner. For the purposes of this definition, "submitted"
262     means any form of electronic, verbal, or written communication sent
263     to the Licensor or its representatives, including but not limited to
264     communication on electronic mailing lists, source code control systems,
265     and issue tracking systems that are managed by, or on behalf of, the
266     Licensor for the purpose of discussing and improving the Work, but
267     excluding communication that is conspicuously marked or otherwise
268     designated in writing by the copyright owner as "Not a Contribution."
269
270     "Contributor" shall mean Licensor and any individual or Legal Entity
271     on behalf of whom a Contribution has been received by Licensor and
272     subsequently incorporated within the Work.
273
274  2. Grant of Copyright License. Subject to the terms and conditions of
275     this License, each Contributor hereby grants to You a perpetual,
276     worldwide, non-exclusive, no-charge, royalty-free, irrevocable
277     copyright license to reproduce, prepare Derivative Works of,
278     publicly display, publicly perform, sublicense, and distribute the
279     Work and such Derivative Works in Source or Object form.
280
281  3. Grant of Patent License. Subject to the terms and conditions of
282     this License, each Contributor hereby grants to You a perpetual,
283     worldwide, non-exclusive, no-charge, royalty-free, irrevocable
284     (except as stated in this section) patent license to make, have made,
285     use, offer to sell, sell, import, and otherwise transfer the Work,
286     where such license applies only to those patent claims licensable
287     by such Contributor that are necessarily infringed by their
288     Contribution(s) alone or by combination of their Contribution(s)
289     with the Work to which such Contribution(s) was submitted. If You
290     institute patent litigation against any entity (including a
291     cross-claim or counterclaim in a lawsuit) alleging that the Work
292     or a Contribution incorporated within the Work constitutes direct
293     or contributory patent infringement, then any patent licenses
294     granted to You under this License for that Work shall terminate
295     as of the date such litigation is filed.
296
297  4. Redistribution. You may reproduce and distribute copies of the
298     Work or Derivative Works thereof in any medium, with or without
299     modifications, and in Source or Object form, provided that You
300     meet the following conditions:
301
302     (a) You must give any other recipients of the Work or
303         Derivative Works a copy of this License; and
304
305     (b) You must cause any modified files to carry prominent notices
306         stating that You changed the files; and
307
308     (c) You must retain, in the Source form of any Derivative Works
309         that You distribute, all copyright, patent, trademark, and
310         attribution notices from the Source form of the Work,
311         excluding those notices that do not pertain to any part of
312         the Derivative Works; and
313
314     (d) If the Work includes a "NOTICE" text file as part of its
315         distribution, then any Derivative Works that You distribute must
316         include a readable copy of the attribution notices contained
317         within such NOTICE file, excluding those notices that do not
318         pertain to any part of the Derivative Works, in at least one
319         of the following places: within a NOTICE text file distributed
320         as part of the Derivative Works; within the Source form or
321         documentation, if provided along with the Derivative Works; or,
322         within a display generated by the Derivative Works, if and
323         wherever such third-party notices normally appear. The contents
324         of the NOTICE file are for informational purposes only and
325         do not modify the License. You may add Your own attribution
326         notices within Derivative Works that You distribute, alongside
327         or as an addendum to the NOTICE text from the Work, provided
328         that such additional attribution notices cannot be construed
329         as modifying the License.
330
331     You may add Your own copyright statement to Your modifications and
332     may provide additional or different license terms and conditions
333     for use, reproduction, or distribution of Your modifications, or
334     for any such Derivative Works as a whole, provided Your use,
335     reproduction, and distribution of the Work otherwise complies with
336     the conditions stated in this License.
337
338  5. Submission of Contributions. Unless You explicitly state otherwise,
339     any Contribution intentionally submitted for inclusion in the Work
340     by You to the Licensor shall be under the terms and conditions of
341     this License, without any additional terms or conditions.
342     Notwithstanding the above, nothing herein shall supersede or modify
343     the terms of any separate license agreement you may have executed
344     with Licensor regarding such Contributions.
345
346  6. Trademarks. This License does not grant permission to use the trade
347     names, trademarks, service marks, or product names of the Licensor,
348     except as required for reasonable and customary use in describing the
349     origin of the Work and reproducing the content of the NOTICE file.
350
351  7. Disclaimer of Warranty. Unless required by applicable law or
352     agreed to in writing, Licensor provides the Work (and each
353     Contributor provides its Contributions) on an "AS IS" BASIS,
354     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
355     implied, including, without limitation, any warranties or conditions
356     of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
357     PARTICULAR PURPOSE. You are solely responsible for determining the
358     appropriateness of using or redistributing the Work and assume any
359     risks associated with Your exercise of permissions under this License.
360
361  8. Limitation of Liability. In no event and under no legal theory,
362     whether in tort (including negligence), contract, or otherwise,
363     unless required by applicable law (such as deliberate and grossly
364     negligent acts) or agreed to in writing, shall any Contributor be
365     liable to You for damages, including any direct, indirect, special,
366     incidental, or consequential damages of any character arising as a
367     result of this License or out of the use or inability to use the
368     Work (including but not limited to damages for loss of goodwill,
369     work stoppage, computer failure or malfunction, or any and all
370     other commercial damages or losses), even if such Contributor
371     has been advised of the possibility of such damages.
372
373  9. Accepting Warranty or Additional Liability. While redistributing
374     the Work or Derivative Works thereof, You may choose to offer,
375     and charge a fee for, acceptance of support, warranty, indemnity,
376     or other liability obligations and/or rights consistent with this
377     License. However, in accepting such obligations, You may act only
378     on Your own behalf and on Your sole responsibility, not on behalf
379     of any other Contributor, and only if You agree to indemnify,
380     defend, and hold each Contributor harmless for any liability
381     incurred by, or claims asserted against, such Contributor by reason
382     of your accepting any such warranty or additional liability.
383
384  END OF TERMS AND CONDITIONS
385
386  APPENDIX: How to apply the Apache License to your work.
387
388     To apply the Apache License to your work, attach the following
389     boilerplate notice, with the fields enclosed by brackets "[]"
390     replaced with your own identifying information. (Don't include
391     the brackets!)  The text should be enclosed in the appropriate
392     comment syntax for the file format. We also recommend that a
393     file or class name and description of purpose be included on the
394     same "printed page" as the copyright notice for easier
395     identification within third-party archives.
396
397  Copyright (c) 2015-2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors
398
399  Licensed under the Apache License, Version 2.0 (the "License");
400  you may not use this file except in compliance with the License.
401  You may obtain a copy of the License at
402
403      http://www.apache.org/licenses/LICENSE-2.0
404
405  Unless required by applicable law or agreed to in writing, software
406  distributed under the License is distributed on an "AS IS" BASIS,
407  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
408  See the License for the specific language governing permissions and
409  limitations under the License.
410  
411
412  **/
413 (function (global, factory) {
414     typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
415     typeof define === 'function' && define.amd ? define('rxjs', ['exports'], factory) :
416     (factory((global.rxjs = {})));
417 }(this, (function (exports) { 'use strict';
418
419     /*! *****************************************************************************\r
420     Copyright (c) Microsoft Corporation. All rights reserved.\r
421     Licensed under the Apache License, Version 2.0 (the "License"); you may not use\r
422     this file except in compliance with the License. You may obtain a copy of the\r
423     License at http://www.apache.org/licenses/LICENSE-2.0\r
424 \r
425     THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
426     KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r
427     WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r
428     MERCHANTABLITY OR NON-INFRINGEMENT.\r
429 \r
430     See the Apache Version 2.0 License for specific language governing permissions\r
431     and limitations under the License.\r
432     ***************************************************************************** */\r
433     /* global Reflect, Promise */\r
434 \r
435     var extendStatics = Object.setPrototypeOf ||\r
436         ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r
437         function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r
438 \r
439     function __extends(d, b) {\r
440         extendStatics(d, b);\r
441         function __() { this.constructor = d; }\r
442         d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r
443     }\r
444 \r
445     var __assign = Object.assign || function __assign(t) {\r
446         for (var s, i = 1, n = arguments.length; i < n; i++) {\r
447             s = arguments[i];\r
448             for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r
449         }\r
450         return t;\r
451     };\r
452 \r
453     function __rest(s, e) {\r
454         var t = {};\r
455         for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r
456             t[p] = s[p];\r
457         if (s != null && typeof Object.getOwnPropertySymbols === "function")\r
458             for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\r
459                 t[p[i]] = s[p[i]];\r
460         return t;\r
461     }
462
463     function isFunction(x) {
464         return typeof x === 'function';
465     }
466
467     var _enable_super_gross_mode_that_will_cause_bad_things = false;
468     var config = {
469         Promise: undefined,
470         set useDeprecatedSynchronousErrorHandling(value) {
471             if (value) {
472                 var error = new Error();
473                 console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
474             }
475             else if (_enable_super_gross_mode_that_will_cause_bad_things) {
476                 console.log('RxJS: Back to a better error behavior. Thank you. <3');
477             }
478             _enable_super_gross_mode_that_will_cause_bad_things = value;
479         },
480         get useDeprecatedSynchronousErrorHandling() {
481             return _enable_super_gross_mode_that_will_cause_bad_things;
482         },
483     };
484
485     function hostReportError(err) {
486         setTimeout(function () { throw err; }, 0);
487     }
488
489     var empty = {
490         closed: true,
491         next: function (value) { },
492         error: function (err) {
493             if (config.useDeprecatedSynchronousErrorHandling) {
494                 throw err;
495             }
496             else {
497                 hostReportError(err);
498             }
499         },
500         complete: function () { }
501     };
502
503     var isArray = (function () { return Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); })();
504
505     function isObject(x) {
506         return x !== null && typeof x === 'object';
507     }
508
509     var UnsubscriptionErrorImpl = (function () {
510         function UnsubscriptionErrorImpl(errors) {
511             Error.call(this);
512             this.message = errors ?
513                 errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n  ') : '';
514             this.name = 'UnsubscriptionError';
515             this.errors = errors;
516             return this;
517         }
518         UnsubscriptionErrorImpl.prototype = Object.create(Error.prototype);
519         return UnsubscriptionErrorImpl;
520     })();
521     var UnsubscriptionError = UnsubscriptionErrorImpl;
522
523     var Subscription = (function () {
524         function Subscription(unsubscribe) {
525             this.closed = false;
526             this._parentOrParents = null;
527             this._subscriptions = null;
528             if (unsubscribe) {
529                 this._unsubscribe = unsubscribe;
530             }
531         }
532         Subscription.prototype.unsubscribe = function () {
533             var errors;
534             if (this.closed) {
535                 return;
536             }
537             var _a = this, _parentOrParents = _a._parentOrParents, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
538             this.closed = true;
539             this._parentOrParents = null;
540             this._subscriptions = null;
541             if (_parentOrParents instanceof Subscription) {
542                 _parentOrParents.remove(this);
543             }
544             else if (_parentOrParents !== null) {
545                 for (var index = 0; index < _parentOrParents.length; ++index) {
546                     var parent_1 = _parentOrParents[index];
547                     parent_1.remove(this);
548                 }
549             }
550             if (isFunction(_unsubscribe)) {
551                 try {
552                     _unsubscribe.call(this);
553                 }
554                 catch (e) {
555                     errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
556                 }
557             }
558             if (isArray(_subscriptions)) {
559                 var index = -1;
560                 var len = _subscriptions.length;
561                 while (++index < len) {
562                     var sub = _subscriptions[index];
563                     if (isObject(sub)) {
564                         try {
565                             sub.unsubscribe();
566                         }
567                         catch (e) {
568                             errors = errors || [];
569                             if (e instanceof UnsubscriptionError) {
570                                 errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
571                             }
572                             else {
573                                 errors.push(e);
574                             }
575                         }
576                     }
577                 }
578             }
579             if (errors) {
580                 throw new UnsubscriptionError(errors);
581             }
582         };
583         Subscription.prototype.add = function (teardown) {
584             var subscription = teardown;
585             if (!teardown) {
586                 return Subscription.EMPTY;
587             }
588             switch (typeof teardown) {
589                 case 'function':
590                     subscription = new Subscription(teardown);
591                 case 'object':
592                     if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
593                         return subscription;
594                     }
595                     else if (this.closed) {
596                         subscription.unsubscribe();
597                         return subscription;
598                     }
599                     else if (!(subscription instanceof Subscription)) {
600                         var tmp = subscription;
601                         subscription = new Subscription();
602                         subscription._subscriptions = [tmp];
603                     }
604                     break;
605                 default: {
606                     throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
607                 }
608             }
609             var _parentOrParents = subscription._parentOrParents;
610             if (_parentOrParents === null) {
611                 subscription._parentOrParents = this;
612             }
613             else if (_parentOrParents instanceof Subscription) {
614                 if (_parentOrParents === this) {
615                     return subscription;
616                 }
617                 subscription._parentOrParents = [_parentOrParents, this];
618             }
619             else if (_parentOrParents.indexOf(this) === -1) {
620                 _parentOrParents.push(this);
621             }
622             else {
623                 return subscription;
624             }
625             var subscriptions = this._subscriptions;
626             if (subscriptions === null) {
627                 this._subscriptions = [subscription];
628             }
629             else {
630                 subscriptions.push(subscription);
631             }
632             return subscription;
633         };
634         Subscription.prototype.remove = function (subscription) {
635             var subscriptions = this._subscriptions;
636             if (subscriptions) {
637                 var subscriptionIndex = subscriptions.indexOf(subscription);
638                 if (subscriptionIndex !== -1) {
639                     subscriptions.splice(subscriptionIndex, 1);
640                 }
641             }
642         };
643         Subscription.EMPTY = (function (empty) {
644             empty.closed = true;
645             return empty;
646         }(new Subscription()));
647         return Subscription;
648     }());
649     function flattenUnsubscriptionErrors(errors) {
650         return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError) ? err.errors : err); }, []);
651     }
652
653     var rxSubscriber = (function () {
654         return typeof Symbol === 'function'
655             ? Symbol('rxSubscriber')
656             : '@@rxSubscriber_' + Math.random();
657     })();
658
659     var Subscriber = (function (_super) {
660         __extends(Subscriber, _super);
661         function Subscriber(destinationOrNext, error, complete) {
662             var _this = _super.call(this) || this;
663             _this.syncErrorValue = null;
664             _this.syncErrorThrown = false;
665             _this.syncErrorThrowable = false;
666             _this.isStopped = false;
667             switch (arguments.length) {
668                 case 0:
669                     _this.destination = empty;
670                     break;
671                 case 1:
672                     if (!destinationOrNext) {
673                         _this.destination = empty;
674                         break;
675                     }
676                     if (typeof destinationOrNext === 'object') {
677                         if (destinationOrNext instanceof Subscriber) {
678                             _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
679                             _this.destination = destinationOrNext;
680                             destinationOrNext.add(_this);
681                         }
682                         else {
683                             _this.syncErrorThrowable = true;
684                             _this.destination = new SafeSubscriber(_this, destinationOrNext);
685                         }
686                         break;
687                     }
688                 default:
689                     _this.syncErrorThrowable = true;
690                     _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
691                     break;
692             }
693             return _this;
694         }
695         Subscriber.prototype[rxSubscriber] = function () { return this; };
696         Subscriber.create = function (next, error, complete) {
697             var subscriber = new Subscriber(next, error, complete);
698             subscriber.syncErrorThrowable = false;
699             return subscriber;
700         };
701         Subscriber.prototype.next = function (value) {
702             if (!this.isStopped) {
703                 this._next(value);
704             }
705         };
706         Subscriber.prototype.error = function (err) {
707             if (!this.isStopped) {
708                 this.isStopped = true;
709                 this._error(err);
710             }
711         };
712         Subscriber.prototype.complete = function () {
713             if (!this.isStopped) {
714                 this.isStopped = true;
715                 this._complete();
716             }
717         };
718         Subscriber.prototype.unsubscribe = function () {
719             if (this.closed) {
720                 return;
721             }
722             this.isStopped = true;
723             _super.prototype.unsubscribe.call(this);
724         };
725         Subscriber.prototype._next = function (value) {
726             this.destination.next(value);
727         };
728         Subscriber.prototype._error = function (err) {
729             this.destination.error(err);
730             this.unsubscribe();
731         };
732         Subscriber.prototype._complete = function () {
733             this.destination.complete();
734             this.unsubscribe();
735         };
736         Subscriber.prototype._unsubscribeAndRecycle = function () {
737             var _parentOrParents = this._parentOrParents;
738             this._parentOrParents = null;
739             this.unsubscribe();
740             this.closed = false;
741             this.isStopped = false;
742             this._parentOrParents = _parentOrParents;
743             return this;
744         };
745         return Subscriber;
746     }(Subscription));
747     var SafeSubscriber = (function (_super) {
748         __extends(SafeSubscriber, _super);
749         function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
750             var _this = _super.call(this) || this;
751             _this._parentSubscriber = _parentSubscriber;
752             var next;
753             var context = _this;
754             if (isFunction(observerOrNext)) {
755                 next = observerOrNext;
756             }
757             else if (observerOrNext) {
758                 next = observerOrNext.next;
759                 error = observerOrNext.error;
760                 complete = observerOrNext.complete;
761                 if (observerOrNext !== empty) {
762                     context = Object.create(observerOrNext);
763                     if (isFunction(context.unsubscribe)) {
764                         _this.add(context.unsubscribe.bind(context));
765                     }
766                     context.unsubscribe = _this.unsubscribe.bind(_this);
767                 }
768             }
769             _this._context = context;
770             _this._next = next;
771             _this._error = error;
772             _this._complete = complete;
773             return _this;
774         }
775         SafeSubscriber.prototype.next = function (value) {
776             if (!this.isStopped && this._next) {
777                 var _parentSubscriber = this._parentSubscriber;
778                 if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
779                     this.__tryOrUnsub(this._next, value);
780                 }
781                 else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
782                     this.unsubscribe();
783                 }
784             }
785         };
786         SafeSubscriber.prototype.error = function (err) {
787             if (!this.isStopped) {
788                 var _parentSubscriber = this._parentSubscriber;
789                 var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;
790                 if (this._error) {
791                     if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
792                         this.__tryOrUnsub(this._error, err);
793                         this.unsubscribe();
794                     }
795                     else {
796                         this.__tryOrSetError(_parentSubscriber, this._error, err);
797                         this.unsubscribe();
798                     }
799                 }
800                 else if (!_parentSubscriber.syncErrorThrowable) {
801                     this.unsubscribe();
802                     if (useDeprecatedSynchronousErrorHandling) {
803                         throw err;
804                     }
805                     hostReportError(err);
806                 }
807                 else {
808                     if (useDeprecatedSynchronousErrorHandling) {
809                         _parentSubscriber.syncErrorValue = err;
810                         _parentSubscriber.syncErrorThrown = true;
811                     }
812                     else {
813                         hostReportError(err);
814                     }
815                     this.unsubscribe();
816                 }
817             }
818         };
819         SafeSubscriber.prototype.complete = function () {
820             var _this = this;
821             if (!this.isStopped) {
822                 var _parentSubscriber = this._parentSubscriber;
823                 if (this._complete) {
824                     var wrappedComplete = function () { return _this._complete.call(_this._context); };
825                     if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
826                         this.__tryOrUnsub(wrappedComplete);
827                         this.unsubscribe();
828                     }
829                     else {
830                         this.__tryOrSetError(_parentSubscriber, wrappedComplete);
831                         this.unsubscribe();
832                     }
833                 }
834                 else {
835                     this.unsubscribe();
836                 }
837             }
838         };
839         SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
840             try {
841                 fn.call(this._context, value);
842             }
843             catch (err) {
844                 this.unsubscribe();
845                 if (config.useDeprecatedSynchronousErrorHandling) {
846                     throw err;
847                 }
848                 else {
849                     hostReportError(err);
850                 }
851             }
852         };
853         SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
854             if (!config.useDeprecatedSynchronousErrorHandling) {
855                 throw new Error('bad call');
856             }
857             try {
858                 fn.call(this._context, value);
859             }
860             catch (err) {
861                 if (config.useDeprecatedSynchronousErrorHandling) {
862                     parent.syncErrorValue = err;
863                     parent.syncErrorThrown = true;
864                     return true;
865                 }
866                 else {
867                     hostReportError(err);
868                     return true;
869                 }
870             }
871             return false;
872         };
873         SafeSubscriber.prototype._unsubscribe = function () {
874             var _parentSubscriber = this._parentSubscriber;
875             this._context = null;
876             this._parentSubscriber = null;
877             _parentSubscriber.unsubscribe();
878         };
879         return SafeSubscriber;
880     }(Subscriber));
881
882     function canReportError(observer) {
883         while (observer) {
884             var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
885             if (closed_1 || isStopped) {
886                 return false;
887             }
888             else if (destination && destination instanceof Subscriber) {
889                 observer = destination;
890             }
891             else {
892                 observer = null;
893             }
894         }
895         return true;
896     }
897
898     function toSubscriber(nextOrObserver, error, complete) {
899         if (nextOrObserver) {
900             if (nextOrObserver instanceof Subscriber) {
901                 return nextOrObserver;
902             }
903             if (nextOrObserver[rxSubscriber]) {
904                 return nextOrObserver[rxSubscriber]();
905             }
906         }
907         if (!nextOrObserver && !error && !complete) {
908             return new Subscriber(empty);
909         }
910         return new Subscriber(nextOrObserver, error, complete);
911     }
912
913     var observable = (function () { return typeof Symbol === 'function' && Symbol.observable || '@@observable'; })();
914
915     function identity(x) {
916         return x;
917     }
918
919     function pipe() {
920         var fns = [];
921         for (var _i = 0; _i < arguments.length; _i++) {
922             fns[_i] = arguments[_i];
923         }
924         return pipeFromArray(fns);
925     }
926     function pipeFromArray(fns) {
927         if (fns.length === 0) {
928             return identity;
929         }
930         if (fns.length === 1) {
931             return fns[0];
932         }
933         return function piped(input) {
934             return fns.reduce(function (prev, fn) { return fn(prev); }, input);
935         };
936     }
937
938     var Observable = (function () {
939         function Observable(subscribe) {
940             this._isScalar = false;
941             if (subscribe) {
942                 this._subscribe = subscribe;
943             }
944         }
945         Observable.prototype.lift = function (operator) {
946             var observable$$1 = new Observable();
947             observable$$1.source = this;
948             observable$$1.operator = operator;
949             return observable$$1;
950         };
951         Observable.prototype.subscribe = function (observerOrNext, error, complete) {
952             var operator = this.operator;
953             var sink = toSubscriber(observerOrNext, error, complete);
954             if (operator) {
955                 sink.add(operator.call(sink, this.source));
956             }
957             else {
958                 sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
959                     this._subscribe(sink) :
960                     this._trySubscribe(sink));
961             }
962             if (config.useDeprecatedSynchronousErrorHandling) {
963                 if (sink.syncErrorThrowable) {
964                     sink.syncErrorThrowable = false;
965                     if (sink.syncErrorThrown) {
966                         throw sink.syncErrorValue;
967                     }
968                 }
969             }
970             return sink;
971         };
972         Observable.prototype._trySubscribe = function (sink) {
973             try {
974                 return this._subscribe(sink);
975             }
976             catch (err) {
977                 if (config.useDeprecatedSynchronousErrorHandling) {
978                     sink.syncErrorThrown = true;
979                     sink.syncErrorValue = err;
980                 }
981                 if (canReportError(sink)) {
982                     sink.error(err);
983                 }
984                 else {
985                     console.warn(err);
986                 }
987             }
988         };
989         Observable.prototype.forEach = function (next, promiseCtor) {
990             var _this = this;
991             promiseCtor = getPromiseCtor(promiseCtor);
992             return new promiseCtor(function (resolve, reject) {
993                 var subscription;
994                 subscription = _this.subscribe(function (value) {
995                     try {
996                         next(value);
997                     }
998                     catch (err) {
999                         reject(err);
1000                         if (subscription) {
1001                             subscription.unsubscribe();
1002                         }
1003                     }
1004                 }, reject, resolve);
1005             });
1006         };
1007         Observable.prototype._subscribe = function (subscriber) {
1008             var source = this.source;
1009             return source && source.subscribe(subscriber);
1010         };
1011         Observable.prototype[observable] = function () {
1012             return this;
1013         };
1014         Observable.prototype.pipe = function () {
1015             var operations = [];
1016             for (var _i = 0; _i < arguments.length; _i++) {
1017                 operations[_i] = arguments[_i];
1018             }
1019             if (operations.length === 0) {
1020                 return this;
1021             }
1022             return pipeFromArray(operations)(this);
1023         };
1024         Observable.prototype.toPromise = function (promiseCtor) {
1025             var _this = this;
1026             promiseCtor = getPromiseCtor(promiseCtor);
1027             return new promiseCtor(function (resolve, reject) {
1028                 var value;
1029                 _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
1030             });
1031         };
1032         Observable.create = function (subscribe) {
1033             return new Observable(subscribe);
1034         };
1035         return Observable;
1036     }());
1037     function getPromiseCtor(promiseCtor) {
1038         if (!promiseCtor) {
1039             promiseCtor = config.Promise || Promise;
1040         }
1041         if (!promiseCtor) {
1042             throw new Error('no Promise impl found');
1043         }
1044         return promiseCtor;
1045     }
1046
1047     var ObjectUnsubscribedErrorImpl = (function () {
1048         function ObjectUnsubscribedErrorImpl() {
1049             Error.call(this);
1050             this.message = 'object unsubscribed';
1051             this.name = 'ObjectUnsubscribedError';
1052             return this;
1053         }
1054         ObjectUnsubscribedErrorImpl.prototype = Object.create(Error.prototype);
1055         return ObjectUnsubscribedErrorImpl;
1056     })();
1057     var ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl;
1058
1059     var SubjectSubscription = (function (_super) {
1060         __extends(SubjectSubscription, _super);
1061         function SubjectSubscription(subject, subscriber) {
1062             var _this = _super.call(this) || this;
1063             _this.subject = subject;
1064             _this.subscriber = subscriber;
1065             _this.closed = false;
1066             return _this;
1067         }
1068         SubjectSubscription.prototype.unsubscribe = function () {
1069             if (this.closed) {
1070                 return;
1071             }
1072             this.closed = true;
1073             var subject = this.subject;
1074             var observers = subject.observers;
1075             this.subject = null;
1076             if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
1077                 return;
1078             }
1079             var subscriberIndex = observers.indexOf(this.subscriber);
1080             if (subscriberIndex !== -1) {
1081                 observers.splice(subscriberIndex, 1);
1082             }
1083         };
1084         return SubjectSubscription;
1085     }(Subscription));
1086
1087     var SubjectSubscriber = (function (_super) {
1088         __extends(SubjectSubscriber, _super);
1089         function SubjectSubscriber(destination) {
1090             var _this = _super.call(this, destination) || this;
1091             _this.destination = destination;
1092             return _this;
1093         }
1094         return SubjectSubscriber;
1095     }(Subscriber));
1096     var Subject = (function (_super) {
1097         __extends(Subject, _super);
1098         function Subject() {
1099             var _this = _super.call(this) || this;
1100             _this.observers = [];
1101             _this.closed = false;
1102             _this.isStopped = false;
1103             _this.hasError = false;
1104             _this.thrownError = null;
1105             return _this;
1106         }
1107         Subject.prototype[rxSubscriber] = function () {
1108             return new SubjectSubscriber(this);
1109         };
1110         Subject.prototype.lift = function (operator) {
1111             var subject = new AnonymousSubject(this, this);
1112             subject.operator = operator;
1113             return subject;
1114         };
1115         Subject.prototype.next = function (value) {
1116             if (this.closed) {
1117                 throw new ObjectUnsubscribedError();
1118             }
1119             if (!this.isStopped) {
1120                 var observers = this.observers;
1121                 var len = observers.length;
1122                 var copy = observers.slice();
1123                 for (var i = 0; i < len; i++) {
1124                     copy[i].next(value);
1125                 }
1126             }
1127         };
1128         Subject.prototype.error = function (err) {
1129             if (this.closed) {
1130                 throw new ObjectUnsubscribedError();
1131             }
1132             this.hasError = true;
1133             this.thrownError = err;
1134             this.isStopped = true;
1135             var observers = this.observers;
1136             var len = observers.length;
1137             var copy = observers.slice();
1138             for (var i = 0; i < len; i++) {
1139                 copy[i].error(err);
1140             }
1141             this.observers.length = 0;
1142         };
1143         Subject.prototype.complete = function () {
1144             if (this.closed) {
1145                 throw new ObjectUnsubscribedError();
1146             }
1147             this.isStopped = true;
1148             var observers = this.observers;
1149             var len = observers.length;
1150             var copy = observers.slice();
1151             for (var i = 0; i < len; i++) {
1152                 copy[i].complete();
1153             }
1154             this.observers.length = 0;
1155         };
1156         Subject.prototype.unsubscribe = function () {
1157             this.isStopped = true;
1158             this.closed = true;
1159             this.observers = null;
1160         };
1161         Subject.prototype._trySubscribe = function (subscriber) {
1162             if (this.closed) {
1163                 throw new ObjectUnsubscribedError();
1164             }
1165             else {
1166                 return _super.prototype._trySubscribe.call(this, subscriber);
1167             }
1168         };
1169         Subject.prototype._subscribe = function (subscriber) {
1170             if (this.closed) {
1171                 throw new ObjectUnsubscribedError();
1172             }
1173             else if (this.hasError) {
1174                 subscriber.error(this.thrownError);
1175                 return Subscription.EMPTY;
1176             }
1177             else if (this.isStopped) {
1178                 subscriber.complete();
1179                 return Subscription.EMPTY;
1180             }
1181             else {
1182                 this.observers.push(subscriber);
1183                 return new SubjectSubscription(this, subscriber);
1184             }
1185         };
1186         Subject.prototype.asObservable = function () {
1187             var observable = new Observable();
1188             observable.source = this;
1189             return observable;
1190         };
1191         Subject.create = function (destination, source) {
1192             return new AnonymousSubject(destination, source);
1193         };
1194         return Subject;
1195     }(Observable));
1196     var AnonymousSubject = (function (_super) {
1197         __extends(AnonymousSubject, _super);
1198         function AnonymousSubject(destination, source) {
1199             var _this = _super.call(this) || this;
1200             _this.destination = destination;
1201             _this.source = source;
1202             return _this;
1203         }
1204         AnonymousSubject.prototype.next = function (value) {
1205             var destination = this.destination;
1206             if (destination && destination.next) {
1207                 destination.next(value);
1208             }
1209         };
1210         AnonymousSubject.prototype.error = function (err) {
1211             var destination = this.destination;
1212             if (destination && destination.error) {
1213                 this.destination.error(err);
1214             }
1215         };
1216         AnonymousSubject.prototype.complete = function () {
1217             var destination = this.destination;
1218             if (destination && destination.complete) {
1219                 this.destination.complete();
1220             }
1221         };
1222         AnonymousSubject.prototype._subscribe = function (subscriber) {
1223             var source = this.source;
1224             if (source) {
1225                 return this.source.subscribe(subscriber);
1226             }
1227             else {
1228                 return Subscription.EMPTY;
1229             }
1230         };
1231         return AnonymousSubject;
1232     }(Subject));
1233
1234     function refCount() {
1235         return function refCountOperatorFunction(source) {
1236             return source.lift(new RefCountOperator(source));
1237         };
1238     }
1239     var RefCountOperator = (function () {
1240         function RefCountOperator(connectable) {
1241             this.connectable = connectable;
1242         }
1243         RefCountOperator.prototype.call = function (subscriber, source) {
1244             var connectable = this.connectable;
1245             connectable._refCount++;
1246             var refCounter = new RefCountSubscriber(subscriber, connectable);
1247             var subscription = source.subscribe(refCounter);
1248             if (!refCounter.closed) {
1249                 refCounter.connection = connectable.connect();
1250             }
1251             return subscription;
1252         };
1253         return RefCountOperator;
1254     }());
1255     var RefCountSubscriber = (function (_super) {
1256         __extends(RefCountSubscriber, _super);
1257         function RefCountSubscriber(destination, connectable) {
1258             var _this = _super.call(this, destination) || this;
1259             _this.connectable = connectable;
1260             return _this;
1261         }
1262         RefCountSubscriber.prototype._unsubscribe = function () {
1263             var connectable = this.connectable;
1264             if (!connectable) {
1265                 this.connection = null;
1266                 return;
1267             }
1268             this.connectable = null;
1269             var refCount = connectable._refCount;
1270             if (refCount <= 0) {
1271                 this.connection = null;
1272                 return;
1273             }
1274             connectable._refCount = refCount - 1;
1275             if (refCount > 1) {
1276                 this.connection = null;
1277                 return;
1278             }
1279             var connection = this.connection;
1280             var sharedConnection = connectable._connection;
1281             this.connection = null;
1282             if (sharedConnection && (!connection || sharedConnection === connection)) {
1283                 sharedConnection.unsubscribe();
1284             }
1285         };
1286         return RefCountSubscriber;
1287     }(Subscriber));
1288
1289     var ConnectableObservable = (function (_super) {
1290         __extends(ConnectableObservable, _super);
1291         function ConnectableObservable(source, subjectFactory) {
1292             var _this = _super.call(this) || this;
1293             _this.source = source;
1294             _this.subjectFactory = subjectFactory;
1295             _this._refCount = 0;
1296             _this._isComplete = false;
1297             return _this;
1298         }
1299         ConnectableObservable.prototype._subscribe = function (subscriber) {
1300             return this.getSubject().subscribe(subscriber);
1301         };
1302         ConnectableObservable.prototype.getSubject = function () {
1303             var subject = this._subject;
1304             if (!subject || subject.isStopped) {
1305                 this._subject = this.subjectFactory();
1306             }
1307             return this._subject;
1308         };
1309         ConnectableObservable.prototype.connect = function () {
1310             var connection = this._connection;
1311             if (!connection) {
1312                 this._isComplete = false;
1313                 connection = this._connection = new Subscription();
1314                 connection.add(this.source
1315                     .subscribe(new ConnectableSubscriber(this.getSubject(), this)));
1316                 if (connection.closed) {
1317                     this._connection = null;
1318                     connection = Subscription.EMPTY;
1319                 }
1320             }
1321             return connection;
1322         };
1323         ConnectableObservable.prototype.refCount = function () {
1324             return refCount()(this);
1325         };
1326         return ConnectableObservable;
1327     }(Observable));
1328     var connectableObservableDescriptor = (function () {
1329         var connectableProto = ConnectableObservable.prototype;
1330         return {
1331             operator: { value: null },
1332             _refCount: { value: 0, writable: true },
1333             _subject: { value: null, writable: true },
1334             _connection: { value: null, writable: true },
1335             _subscribe: { value: connectableProto._subscribe },
1336             _isComplete: { value: connectableProto._isComplete, writable: true },
1337             getSubject: { value: connectableProto.getSubject },
1338             connect: { value: connectableProto.connect },
1339             refCount: { value: connectableProto.refCount }
1340         };
1341     })();
1342     var ConnectableSubscriber = (function (_super) {
1343         __extends(ConnectableSubscriber, _super);
1344         function ConnectableSubscriber(destination, connectable) {
1345             var _this = _super.call(this, destination) || this;
1346             _this.connectable = connectable;
1347             return _this;
1348         }
1349         ConnectableSubscriber.prototype._error = function (err) {
1350             this._unsubscribe();
1351             _super.prototype._error.call(this, err);
1352         };
1353         ConnectableSubscriber.prototype._complete = function () {
1354             this.connectable._isComplete = true;
1355             this._unsubscribe();
1356             _super.prototype._complete.call(this);
1357         };
1358         ConnectableSubscriber.prototype._unsubscribe = function () {
1359             var connectable = this.connectable;
1360             if (connectable) {
1361                 this.connectable = null;
1362                 var connection = connectable._connection;
1363                 connectable._refCount = 0;
1364                 connectable._subject = null;
1365                 connectable._connection = null;
1366                 if (connection) {
1367                     connection.unsubscribe();
1368                 }
1369             }
1370         };
1371         return ConnectableSubscriber;
1372     }(SubjectSubscriber));
1373     var RefCountSubscriber$1 = (function (_super) {
1374         __extends(RefCountSubscriber, _super);
1375         function RefCountSubscriber(destination, connectable) {
1376             var _this = _super.call(this, destination) || this;
1377             _this.connectable = connectable;
1378             return _this;
1379         }
1380         RefCountSubscriber.prototype._unsubscribe = function () {
1381             var connectable = this.connectable;
1382             if (!connectable) {
1383                 this.connection = null;
1384                 return;
1385             }
1386             this.connectable = null;
1387             var refCount$$1 = connectable._refCount;
1388             if (refCount$$1 <= 0) {
1389                 this.connection = null;
1390                 return;
1391             }
1392             connectable._refCount = refCount$$1 - 1;
1393             if (refCount$$1 > 1) {
1394                 this.connection = null;
1395                 return;
1396             }
1397             var connection = this.connection;
1398             var sharedConnection = connectable._connection;
1399             this.connection = null;
1400             if (sharedConnection && (!connection || sharedConnection === connection)) {
1401                 sharedConnection.unsubscribe();
1402             }
1403         };
1404         return RefCountSubscriber;
1405     }(Subscriber));
1406
1407     function groupBy(keySelector, elementSelector, durationSelector, subjectSelector) {
1408         return function (source) {
1409             return source.lift(new GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector));
1410         };
1411     }
1412     var GroupByOperator = (function () {
1413         function GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector) {
1414             this.keySelector = keySelector;
1415             this.elementSelector = elementSelector;
1416             this.durationSelector = durationSelector;
1417             this.subjectSelector = subjectSelector;
1418         }
1419         GroupByOperator.prototype.call = function (subscriber, source) {
1420             return source.subscribe(new GroupBySubscriber(subscriber, this.keySelector, this.elementSelector, this.durationSelector, this.subjectSelector));
1421         };
1422         return GroupByOperator;
1423     }());
1424     var GroupBySubscriber = (function (_super) {
1425         __extends(GroupBySubscriber, _super);
1426         function GroupBySubscriber(destination, keySelector, elementSelector, durationSelector, subjectSelector) {
1427             var _this = _super.call(this, destination) || this;
1428             _this.keySelector = keySelector;
1429             _this.elementSelector = elementSelector;
1430             _this.durationSelector = durationSelector;
1431             _this.subjectSelector = subjectSelector;
1432             _this.groups = null;
1433             _this.attemptedToUnsubscribe = false;
1434             _this.count = 0;
1435             return _this;
1436         }
1437         GroupBySubscriber.prototype._next = function (value) {
1438             var key;
1439             try {
1440                 key = this.keySelector(value);
1441             }
1442             catch (err) {
1443                 this.error(err);
1444                 return;
1445             }
1446             this._group(value, key);
1447         };
1448         GroupBySubscriber.prototype._group = function (value, key) {
1449             var groups = this.groups;
1450             if (!groups) {
1451                 groups = this.groups = new Map();
1452             }
1453             var group = groups.get(key);
1454             var element;
1455             if (this.elementSelector) {
1456                 try {
1457                     element = this.elementSelector(value);
1458                 }
1459                 catch (err) {
1460                     this.error(err);
1461                 }
1462             }
1463             else {
1464                 element = value;
1465             }
1466             if (!group) {
1467                 group = (this.subjectSelector ? this.subjectSelector() : new Subject());
1468                 groups.set(key, group);
1469                 var groupedObservable = new GroupedObservable(key, group, this);
1470                 this.destination.next(groupedObservable);
1471                 if (this.durationSelector) {
1472                     var duration = void 0;
1473                     try {
1474                         duration = this.durationSelector(new GroupedObservable(key, group));
1475                     }
1476                     catch (err) {
1477                         this.error(err);
1478                         return;
1479                     }
1480                     this.add(duration.subscribe(new GroupDurationSubscriber(key, group, this)));
1481                 }
1482             }
1483             if (!group.closed) {
1484                 group.next(element);
1485             }
1486         };
1487         GroupBySubscriber.prototype._error = function (err) {
1488             var groups = this.groups;
1489             if (groups) {
1490                 groups.forEach(function (group, key) {
1491                     group.error(err);
1492                 });
1493                 groups.clear();
1494             }
1495             this.destination.error(err);
1496         };
1497         GroupBySubscriber.prototype._complete = function () {
1498             var groups = this.groups;
1499             if (groups) {
1500                 groups.forEach(function (group, key) {
1501                     group.complete();
1502                 });
1503                 groups.clear();
1504             }
1505             this.destination.complete();
1506         };
1507         GroupBySubscriber.prototype.removeGroup = function (key) {
1508             this.groups.delete(key);
1509         };
1510         GroupBySubscriber.prototype.unsubscribe = function () {
1511             if (!this.closed) {
1512                 this.attemptedToUnsubscribe = true;
1513                 if (this.count === 0) {
1514                     _super.prototype.unsubscribe.call(this);
1515                 }
1516             }
1517         };
1518         return GroupBySubscriber;
1519     }(Subscriber));
1520     var GroupDurationSubscriber = (function (_super) {
1521         __extends(GroupDurationSubscriber, _super);
1522         function GroupDurationSubscriber(key, group, parent) {
1523             var _this = _super.call(this, group) || this;
1524             _this.key = key;
1525             _this.group = group;
1526             _this.parent = parent;
1527             return _this;
1528         }
1529         GroupDurationSubscriber.prototype._next = function (value) {
1530             this.complete();
1531         };
1532         GroupDurationSubscriber.prototype._unsubscribe = function () {
1533             var _a = this, parent = _a.parent, key = _a.key;
1534             this.key = this.parent = null;
1535             if (parent) {
1536                 parent.removeGroup(key);
1537             }
1538         };
1539         return GroupDurationSubscriber;
1540     }(Subscriber));
1541     var GroupedObservable = (function (_super) {
1542         __extends(GroupedObservable, _super);
1543         function GroupedObservable(key, groupSubject, refCountSubscription) {
1544             var _this = _super.call(this) || this;
1545             _this.key = key;
1546             _this.groupSubject = groupSubject;
1547             _this.refCountSubscription = refCountSubscription;
1548             return _this;
1549         }
1550         GroupedObservable.prototype._subscribe = function (subscriber) {
1551             var subscription = new Subscription();
1552             var _a = this, refCountSubscription = _a.refCountSubscription, groupSubject = _a.groupSubject;
1553             if (refCountSubscription && !refCountSubscription.closed) {
1554                 subscription.add(new InnerRefCountSubscription(refCountSubscription));
1555             }
1556             subscription.add(groupSubject.subscribe(subscriber));
1557             return subscription;
1558         };
1559         return GroupedObservable;
1560     }(Observable));
1561     var InnerRefCountSubscription = (function (_super) {
1562         __extends(InnerRefCountSubscription, _super);
1563         function InnerRefCountSubscription(parent) {
1564             var _this = _super.call(this) || this;
1565             _this.parent = parent;
1566             parent.count++;
1567             return _this;
1568         }
1569         InnerRefCountSubscription.prototype.unsubscribe = function () {
1570             var parent = this.parent;
1571             if (!parent.closed && !this.closed) {
1572                 _super.prototype.unsubscribe.call(this);
1573                 parent.count -= 1;
1574                 if (parent.count === 0 && parent.attemptedToUnsubscribe) {
1575                     parent.unsubscribe();
1576                 }
1577             }
1578         };
1579         return InnerRefCountSubscription;
1580     }(Subscription));
1581
1582     var BehaviorSubject = (function (_super) {
1583         __extends(BehaviorSubject, _super);
1584         function BehaviorSubject(_value) {
1585             var _this = _super.call(this) || this;
1586             _this._value = _value;
1587             return _this;
1588         }
1589         Object.defineProperty(BehaviorSubject.prototype, "value", {
1590             get: function () {
1591                 return this.getValue();
1592             },
1593             enumerable: true,
1594             configurable: true
1595         });
1596         BehaviorSubject.prototype._subscribe = function (subscriber) {
1597             var subscription = _super.prototype._subscribe.call(this, subscriber);
1598             if (subscription && !subscription.closed) {
1599                 subscriber.next(this._value);
1600             }
1601             return subscription;
1602         };
1603         BehaviorSubject.prototype.getValue = function () {
1604             if (this.hasError) {
1605                 throw this.thrownError;
1606             }
1607             else if (this.closed) {
1608                 throw new ObjectUnsubscribedError();
1609             }
1610             else {
1611                 return this._value;
1612             }
1613         };
1614         BehaviorSubject.prototype.next = function (value) {
1615             _super.prototype.next.call(this, this._value = value);
1616         };
1617         return BehaviorSubject;
1618     }(Subject));
1619
1620     var Action = (function (_super) {
1621         __extends(Action, _super);
1622         function Action(scheduler, work) {
1623             return _super.call(this) || this;
1624         }
1625         Action.prototype.schedule = function (state, delay) {
1626             if (delay === void 0) { delay = 0; }
1627             return this;
1628         };
1629         return Action;
1630     }(Subscription));
1631
1632     var AsyncAction = (function (_super) {
1633         __extends(AsyncAction, _super);
1634         function AsyncAction(scheduler, work) {
1635             var _this = _super.call(this, scheduler, work) || this;
1636             _this.scheduler = scheduler;
1637             _this.work = work;
1638             _this.pending = false;
1639             return _this;
1640         }
1641         AsyncAction.prototype.schedule = function (state, delay) {
1642             if (delay === void 0) { delay = 0; }
1643             if (this.closed) {
1644                 return this;
1645             }
1646             this.state = state;
1647             var id = this.id;
1648             var scheduler = this.scheduler;
1649             if (id != null) {
1650                 this.id = this.recycleAsyncId(scheduler, id, delay);
1651             }
1652             this.pending = true;
1653             this.delay = delay;
1654             this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
1655             return this;
1656         };
1657         AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) {
1658             if (delay === void 0) { delay = 0; }
1659             return setInterval(scheduler.flush.bind(scheduler, this), delay);
1660         };
1661         AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
1662             if (delay === void 0) { delay = 0; }
1663             if (delay !== null && this.delay === delay && this.pending === false) {
1664                 return id;
1665             }
1666             clearInterval(id);
1667             return undefined;
1668         };
1669         AsyncAction.prototype.execute = function (state, delay) {
1670             if (this.closed) {
1671                 return new Error('executing a cancelled action');
1672             }
1673             this.pending = false;
1674             var error = this._execute(state, delay);
1675             if (error) {
1676                 return error;
1677             }
1678             else if (this.pending === false && this.id != null) {
1679                 this.id = this.recycleAsyncId(this.scheduler, this.id, null);
1680             }
1681         };
1682         AsyncAction.prototype._execute = function (state, delay) {
1683             var errored = false;
1684             var errorValue = undefined;
1685             try {
1686                 this.work(state);
1687             }
1688             catch (e) {
1689                 errored = true;
1690                 errorValue = !!e && e || new Error(e);
1691             }
1692             if (errored) {
1693                 this.unsubscribe();
1694                 return errorValue;
1695             }
1696         };
1697         AsyncAction.prototype._unsubscribe = function () {
1698             var id = this.id;
1699             var scheduler = this.scheduler;
1700             var actions = scheduler.actions;
1701             var index = actions.indexOf(this);
1702             this.work = null;
1703             this.state = null;
1704             this.pending = false;
1705             this.scheduler = null;
1706             if (index !== -1) {
1707                 actions.splice(index, 1);
1708             }
1709             if (id != null) {
1710                 this.id = this.recycleAsyncId(scheduler, id, null);
1711             }
1712             this.delay = null;
1713         };
1714         return AsyncAction;
1715     }(Action));
1716
1717     var QueueAction = (function (_super) {
1718         __extends(QueueAction, _super);
1719         function QueueAction(scheduler, work) {
1720             var _this = _super.call(this, scheduler, work) || this;
1721             _this.scheduler = scheduler;
1722             _this.work = work;
1723             return _this;
1724         }
1725         QueueAction.prototype.schedule = function (state, delay) {
1726             if (delay === void 0) { delay = 0; }
1727             if (delay > 0) {
1728                 return _super.prototype.schedule.call(this, state, delay);
1729             }
1730             this.delay = delay;
1731             this.state = state;
1732             this.scheduler.flush(this);
1733             return this;
1734         };
1735         QueueAction.prototype.execute = function (state, delay) {
1736             return (delay > 0 || this.closed) ?
1737                 _super.prototype.execute.call(this, state, delay) :
1738                 this._execute(state, delay);
1739         };
1740         QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) {
1741             if (delay === void 0) { delay = 0; }
1742             if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
1743                 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
1744             }
1745             return scheduler.flush(this);
1746         };
1747         return QueueAction;
1748     }(AsyncAction));
1749
1750     var Scheduler = (function () {
1751         function Scheduler(SchedulerAction, now) {
1752             if (now === void 0) { now = Scheduler.now; }
1753             this.SchedulerAction = SchedulerAction;
1754             this.now = now;
1755         }
1756         Scheduler.prototype.schedule = function (work, delay, state) {
1757             if (delay === void 0) { delay = 0; }
1758             return new this.SchedulerAction(this, work).schedule(state, delay);
1759         };
1760         Scheduler.now = function () { return Date.now(); };
1761         return Scheduler;
1762     }());
1763
1764     var AsyncScheduler = (function (_super) {
1765         __extends(AsyncScheduler, _super);
1766         function AsyncScheduler(SchedulerAction, now) {
1767             if (now === void 0) { now = Scheduler.now; }
1768             var _this = _super.call(this, SchedulerAction, function () {
1769                 if (AsyncScheduler.delegate && AsyncScheduler.delegate !== _this) {
1770                     return AsyncScheduler.delegate.now();
1771                 }
1772                 else {
1773                     return now();
1774                 }
1775             }) || this;
1776             _this.actions = [];
1777             _this.active = false;
1778             _this.scheduled = undefined;
1779             return _this;
1780         }
1781         AsyncScheduler.prototype.schedule = function (work, delay, state) {
1782             if (delay === void 0) { delay = 0; }
1783             if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) {
1784                 return AsyncScheduler.delegate.schedule(work, delay, state);
1785             }
1786             else {
1787                 return _super.prototype.schedule.call(this, work, delay, state);
1788             }
1789         };
1790         AsyncScheduler.prototype.flush = function (action) {
1791             var actions = this.actions;
1792             if (this.active) {
1793                 actions.push(action);
1794                 return;
1795             }
1796             var error;
1797             this.active = true;
1798             do {
1799                 if (error = action.execute(action.state, action.delay)) {
1800                     break;
1801                 }
1802             } while (action = actions.shift());
1803             this.active = false;
1804             if (error) {
1805                 while (action = actions.shift()) {
1806                     action.unsubscribe();
1807                 }
1808                 throw error;
1809             }
1810         };
1811         return AsyncScheduler;
1812     }(Scheduler));
1813
1814     var QueueScheduler = (function (_super) {
1815         __extends(QueueScheduler, _super);
1816         function QueueScheduler() {
1817             return _super !== null && _super.apply(this, arguments) || this;
1818         }
1819         return QueueScheduler;
1820     }(AsyncScheduler));
1821
1822     var queueScheduler = new QueueScheduler(QueueAction);
1823     var queue = queueScheduler;
1824
1825     var EMPTY = new Observable(function (subscriber) { return subscriber.complete(); });
1826     function empty$1(scheduler) {
1827         return scheduler ? emptyScheduled(scheduler) : EMPTY;
1828     }
1829     function emptyScheduled(scheduler) {
1830         return new Observable(function (subscriber) { return scheduler.schedule(function () { return subscriber.complete(); }); });
1831     }
1832
1833     function isScheduler(value) {
1834         return value && typeof value.schedule === 'function';
1835     }
1836
1837     var subscribeToArray = function (array) { return function (subscriber) {
1838         for (var i = 0, len = array.length; i < len && !subscriber.closed; i++) {
1839             subscriber.next(array[i]);
1840         }
1841         subscriber.complete();
1842     }; };
1843
1844     function scheduleArray(input, scheduler) {
1845         return new Observable(function (subscriber) {
1846             var sub = new Subscription();
1847             var i = 0;
1848             sub.add(scheduler.schedule(function () {
1849                 if (i === input.length) {
1850                     subscriber.complete();
1851                     return;
1852                 }
1853                 subscriber.next(input[i++]);
1854                 if (!subscriber.closed) {
1855                     sub.add(this.schedule());
1856                 }
1857             }));
1858             return sub;
1859         });
1860     }
1861
1862     function fromArray(input, scheduler) {
1863         if (!scheduler) {
1864             return new Observable(subscribeToArray(input));
1865         }
1866         else {
1867             return scheduleArray(input, scheduler);
1868         }
1869     }
1870
1871     function of() {
1872         var args = [];
1873         for (var _i = 0; _i < arguments.length; _i++) {
1874             args[_i] = arguments[_i];
1875         }
1876         var scheduler = args[args.length - 1];
1877         if (isScheduler(scheduler)) {
1878             args.pop();
1879             return scheduleArray(args, scheduler);
1880         }
1881         else {
1882             return fromArray(args);
1883         }
1884     }
1885
1886     function throwError(error, scheduler) {
1887         if (!scheduler) {
1888             return new Observable(function (subscriber) { return subscriber.error(error); });
1889         }
1890         else {
1891             return new Observable(function (subscriber) { return scheduler.schedule(dispatch, 0, { error: error, subscriber: subscriber }); });
1892         }
1893     }
1894     function dispatch(_a) {
1895         var error = _a.error, subscriber = _a.subscriber;
1896         subscriber.error(error);
1897     }
1898
1899     (function (NotificationKind) {
1900         NotificationKind["NEXT"] = "N";
1901         NotificationKind["ERROR"] = "E";
1902         NotificationKind["COMPLETE"] = "C";
1903     })(exports.NotificationKind || (exports.NotificationKind = {}));
1904     var Notification = (function () {
1905         function Notification(kind, value, error) {
1906             this.kind = kind;
1907             this.value = value;
1908             this.error = error;
1909             this.hasValue = kind === 'N';
1910         }
1911         Notification.prototype.observe = function (observer) {
1912             switch (this.kind) {
1913                 case 'N':
1914                     return observer.next && observer.next(this.value);
1915                 case 'E':
1916                     return observer.error && observer.error(this.error);
1917                 case 'C':
1918                     return observer.complete && observer.complete();
1919             }
1920         };
1921         Notification.prototype.do = function (next, error, complete) {
1922             var kind = this.kind;
1923             switch (kind) {
1924                 case 'N':
1925                     return next && next(this.value);
1926                 case 'E':
1927                     return error && error(this.error);
1928                 case 'C':
1929                     return complete && complete();
1930             }
1931         };
1932         Notification.prototype.accept = function (nextOrObserver, error, complete) {
1933             if (nextOrObserver && typeof nextOrObserver.next === 'function') {
1934                 return this.observe(nextOrObserver);
1935             }
1936             else {
1937                 return this.do(nextOrObserver, error, complete);
1938             }
1939         };
1940         Notification.prototype.toObservable = function () {
1941             var kind = this.kind;
1942             switch (kind) {
1943                 case 'N':
1944                     return of(this.value);
1945                 case 'E':
1946                     return throwError(this.error);
1947                 case 'C':
1948                     return empty$1();
1949             }
1950             throw new Error('unexpected notification kind value');
1951         };
1952         Notification.createNext = function (value) {
1953             if (typeof value !== 'undefined') {
1954                 return new Notification('N', value);
1955             }
1956             return Notification.undefinedValueNotification;
1957         };
1958         Notification.createError = function (err) {
1959             return new Notification('E', undefined, err);
1960         };
1961         Notification.createComplete = function () {
1962             return Notification.completeNotification;
1963         };
1964         Notification.completeNotification = new Notification('C');
1965         Notification.undefinedValueNotification = new Notification('N', undefined);
1966         return Notification;
1967     }());
1968
1969     function observeOn(scheduler, delay) {
1970         if (delay === void 0) { delay = 0; }
1971         return function observeOnOperatorFunction(source) {
1972             return source.lift(new ObserveOnOperator(scheduler, delay));
1973         };
1974     }
1975     var ObserveOnOperator = (function () {
1976         function ObserveOnOperator(scheduler, delay) {
1977             if (delay === void 0) { delay = 0; }
1978             this.scheduler = scheduler;
1979             this.delay = delay;
1980         }
1981         ObserveOnOperator.prototype.call = function (subscriber, source) {
1982             return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));
1983         };
1984         return ObserveOnOperator;
1985     }());
1986     var ObserveOnSubscriber = (function (_super) {
1987         __extends(ObserveOnSubscriber, _super);
1988         function ObserveOnSubscriber(destination, scheduler, delay) {
1989             if (delay === void 0) { delay = 0; }
1990             var _this = _super.call(this, destination) || this;
1991             _this.scheduler = scheduler;
1992             _this.delay = delay;
1993             return _this;
1994         }
1995         ObserveOnSubscriber.dispatch = function (arg) {
1996             var notification = arg.notification, destination = arg.destination;
1997             notification.observe(destination);
1998             this.unsubscribe();
1999         };
2000         ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
2001             var destination = this.destination;
2002             destination.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
2003         };
2004         ObserveOnSubscriber.prototype._next = function (value) {
2005             this.scheduleMessage(Notification.createNext(value));
2006         };
2007         ObserveOnSubscriber.prototype._error = function (err) {
2008             this.scheduleMessage(Notification.createError(err));
2009             this.unsubscribe();
2010         };
2011         ObserveOnSubscriber.prototype._complete = function () {
2012             this.scheduleMessage(Notification.createComplete());
2013             this.unsubscribe();
2014         };
2015         return ObserveOnSubscriber;
2016     }(Subscriber));
2017     var ObserveOnMessage = (function () {
2018         function ObserveOnMessage(notification, destination) {
2019             this.notification = notification;
2020             this.destination = destination;
2021         }
2022         return ObserveOnMessage;
2023     }());
2024
2025     var ReplaySubject = (function (_super) {
2026         __extends(ReplaySubject, _super);
2027         function ReplaySubject(bufferSize, windowTime, scheduler) {
2028             if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
2029             if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
2030             var _this = _super.call(this) || this;
2031             _this.scheduler = scheduler;
2032             _this._events = [];
2033             _this._infiniteTimeWindow = false;
2034             _this._bufferSize = bufferSize < 1 ? 1 : bufferSize;
2035             _this._windowTime = windowTime < 1 ? 1 : windowTime;
2036             if (windowTime === Number.POSITIVE_INFINITY) {
2037                 _this._infiniteTimeWindow = true;
2038                 _this.next = _this.nextInfiniteTimeWindow;
2039             }
2040             else {
2041                 _this.next = _this.nextTimeWindow;
2042             }
2043             return _this;
2044         }
2045         ReplaySubject.prototype.nextInfiniteTimeWindow = function (value) {
2046             var _events = this._events;
2047             _events.push(value);
2048             if (_events.length > this._bufferSize) {
2049                 _events.shift();
2050             }
2051             _super.prototype.next.call(this, value);
2052         };
2053         ReplaySubject.prototype.nextTimeWindow = function (value) {
2054             this._events.push(new ReplayEvent(this._getNow(), value));
2055             this._trimBufferThenGetEvents();
2056             _super.prototype.next.call(this, value);
2057         };
2058         ReplaySubject.prototype._subscribe = function (subscriber) {
2059             var _infiniteTimeWindow = this._infiniteTimeWindow;
2060             var _events = _infiniteTimeWindow ? this._events : this._trimBufferThenGetEvents();
2061             var scheduler = this.scheduler;
2062             var len = _events.length;
2063             var subscription;
2064             if (this.closed) {
2065                 throw new ObjectUnsubscribedError();
2066             }
2067             else if (this.isStopped || this.hasError) {
2068                 subscription = Subscription.EMPTY;
2069             }
2070             else {
2071                 this.observers.push(subscriber);
2072                 subscription = new SubjectSubscription(this, subscriber);
2073             }
2074             if (scheduler) {
2075                 subscriber.add(subscriber = new ObserveOnSubscriber(subscriber, scheduler));
2076             }
2077             if (_infiniteTimeWindow) {
2078                 for (var i = 0; i < len && !subscriber.closed; i++) {
2079                     subscriber.next(_events[i]);
2080                 }
2081             }
2082             else {
2083                 for (var i = 0; i < len && !subscriber.closed; i++) {
2084                     subscriber.next(_events[i].value);
2085                 }
2086             }
2087             if (this.hasError) {
2088                 subscriber.error(this.thrownError);
2089             }
2090             else if (this.isStopped) {
2091                 subscriber.complete();
2092             }
2093             return subscription;
2094         };
2095         ReplaySubject.prototype._getNow = function () {
2096             return (this.scheduler || queue).now();
2097         };
2098         ReplaySubject.prototype._trimBufferThenGetEvents = function () {
2099             var now = this._getNow();
2100             var _bufferSize = this._bufferSize;
2101             var _windowTime = this._windowTime;
2102             var _events = this._events;
2103             var eventsCount = _events.length;
2104             var spliceCount = 0;
2105             while (spliceCount < eventsCount) {
2106                 if ((now - _events[spliceCount].time) < _windowTime) {
2107                     break;
2108                 }
2109                 spliceCount++;
2110             }
2111             if (eventsCount > _bufferSize) {
2112                 spliceCount = Math.max(spliceCount, eventsCount - _bufferSize);
2113             }
2114             if (spliceCount > 0) {
2115                 _events.splice(0, spliceCount);
2116             }
2117             return _events;
2118         };
2119         return ReplaySubject;
2120     }(Subject));
2121     var ReplayEvent = (function () {
2122         function ReplayEvent(time, value) {
2123             this.time = time;
2124             this.value = value;
2125         }
2126         return ReplayEvent;
2127     }());
2128
2129     var AsyncSubject = (function (_super) {
2130         __extends(AsyncSubject, _super);
2131         function AsyncSubject() {
2132             var _this = _super !== null && _super.apply(this, arguments) || this;
2133             _this.value = null;
2134             _this.hasNext = false;
2135             _this.hasCompleted = false;
2136             return _this;
2137         }
2138         AsyncSubject.prototype._subscribe = function (subscriber) {
2139             if (this.hasError) {
2140                 subscriber.error(this.thrownError);
2141                 return Subscription.EMPTY;
2142             }
2143             else if (this.hasCompleted && this.hasNext) {
2144                 subscriber.next(this.value);
2145                 subscriber.complete();
2146                 return Subscription.EMPTY;
2147             }
2148             return _super.prototype._subscribe.call(this, subscriber);
2149         };
2150         AsyncSubject.prototype.next = function (value) {
2151             if (!this.hasCompleted) {
2152                 this.value = value;
2153                 this.hasNext = true;
2154             }
2155         };
2156         AsyncSubject.prototype.error = function (error) {
2157             if (!this.hasCompleted) {
2158                 _super.prototype.error.call(this, error);
2159             }
2160         };
2161         AsyncSubject.prototype.complete = function () {
2162             this.hasCompleted = true;
2163             if (this.hasNext) {
2164                 _super.prototype.next.call(this, this.value);
2165             }
2166             _super.prototype.complete.call(this);
2167         };
2168         return AsyncSubject;
2169     }(Subject));
2170
2171     var nextHandle = 1;
2172     var RESOLVED = (function () { return Promise.resolve(); })();
2173     var activeHandles = {};
2174     function findAndClearHandle(handle) {
2175         if (handle in activeHandles) {
2176             delete activeHandles[handle];
2177             return true;
2178         }
2179         return false;
2180     }
2181     var Immediate = {
2182         setImmediate: function (cb) {
2183             var handle = nextHandle++;
2184             activeHandles[handle] = true;
2185             RESOLVED.then(function () { return findAndClearHandle(handle) && cb(); });
2186             return handle;
2187         },
2188         clearImmediate: function (handle) {
2189             findAndClearHandle(handle);
2190         },
2191     };
2192
2193     var AsapAction = (function (_super) {
2194         __extends(AsapAction, _super);
2195         function AsapAction(scheduler, work) {
2196             var _this = _super.call(this, scheduler, work) || this;
2197             _this.scheduler = scheduler;
2198             _this.work = work;
2199             return _this;
2200         }
2201         AsapAction.prototype.requestAsyncId = function (scheduler, id, delay) {
2202             if (delay === void 0) { delay = 0; }
2203             if (delay !== null && delay > 0) {
2204                 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
2205             }
2206             scheduler.actions.push(this);
2207             return scheduler.scheduled || (scheduler.scheduled = Immediate.setImmediate(scheduler.flush.bind(scheduler, null)));
2208         };
2209         AsapAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
2210             if (delay === void 0) { delay = 0; }
2211             if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
2212                 return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
2213             }
2214             if (scheduler.actions.length === 0) {
2215                 Immediate.clearImmediate(id);
2216                 scheduler.scheduled = undefined;
2217             }
2218             return undefined;
2219         };
2220         return AsapAction;
2221     }(AsyncAction));
2222
2223     var AsapScheduler = (function (_super) {
2224         __extends(AsapScheduler, _super);
2225         function AsapScheduler() {
2226             return _super !== null && _super.apply(this, arguments) || this;
2227         }
2228         AsapScheduler.prototype.flush = function (action) {
2229             this.active = true;
2230             this.scheduled = undefined;
2231             var actions = this.actions;
2232             var error;
2233             var index = -1;
2234             var count = actions.length;
2235             action = action || actions.shift();
2236             do {
2237                 if (error = action.execute(action.state, action.delay)) {
2238                     break;
2239                 }
2240             } while (++index < count && (action = actions.shift()));
2241             this.active = false;
2242             if (error) {
2243                 while (++index < count && (action = actions.shift())) {
2244                     action.unsubscribe();
2245                 }
2246                 throw error;
2247             }
2248         };
2249         return AsapScheduler;
2250     }(AsyncScheduler));
2251
2252     var asapScheduler = new AsapScheduler(AsapAction);
2253     var asap = asapScheduler;
2254
2255     var asyncScheduler = new AsyncScheduler(AsyncAction);
2256     var async = asyncScheduler;
2257
2258     var AnimationFrameAction = (function (_super) {
2259         __extends(AnimationFrameAction, _super);
2260         function AnimationFrameAction(scheduler, work) {
2261             var _this = _super.call(this, scheduler, work) || this;
2262             _this.scheduler = scheduler;
2263             _this.work = work;
2264             return _this;
2265         }
2266         AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) {
2267             if (delay === void 0) { delay = 0; }
2268             if (delay !== null && delay > 0) {
2269                 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
2270             }
2271             scheduler.actions.push(this);
2272             return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame(function () { return scheduler.flush(null); }));
2273         };
2274         AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
2275             if (delay === void 0) { delay = 0; }
2276             if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
2277                 return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
2278             }
2279             if (scheduler.actions.length === 0) {
2280                 cancelAnimationFrame(id);
2281                 scheduler.scheduled = undefined;
2282             }
2283             return undefined;
2284         };
2285         return AnimationFrameAction;
2286     }(AsyncAction));
2287
2288     var AnimationFrameScheduler = (function (_super) {
2289         __extends(AnimationFrameScheduler, _super);
2290         function AnimationFrameScheduler() {
2291             return _super !== null && _super.apply(this, arguments) || this;
2292         }
2293         AnimationFrameScheduler.prototype.flush = function (action) {
2294             this.active = true;
2295             this.scheduled = undefined;
2296             var actions = this.actions;
2297             var error;
2298             var index = -1;
2299             var count = actions.length;
2300             action = action || actions.shift();
2301             do {
2302                 if (error = action.execute(action.state, action.delay)) {
2303                     break;
2304                 }
2305             } while (++index < count && (action = actions.shift()));
2306             this.active = false;
2307             if (error) {
2308                 while (++index < count && (action = actions.shift())) {
2309                     action.unsubscribe();
2310                 }
2311                 throw error;
2312             }
2313         };
2314         return AnimationFrameScheduler;
2315     }(AsyncScheduler));
2316
2317     var animationFrameScheduler = new AnimationFrameScheduler(AnimationFrameAction);
2318     var animationFrame = animationFrameScheduler;
2319
2320     var VirtualTimeScheduler = (function (_super) {
2321         __extends(VirtualTimeScheduler, _super);
2322         function VirtualTimeScheduler(SchedulerAction, maxFrames) {
2323             if (SchedulerAction === void 0) { SchedulerAction = VirtualAction; }
2324             if (maxFrames === void 0) { maxFrames = Number.POSITIVE_INFINITY; }
2325             var _this = _super.call(this, SchedulerAction, function () { return _this.frame; }) || this;
2326             _this.maxFrames = maxFrames;
2327             _this.frame = 0;
2328             _this.index = -1;
2329             return _this;
2330         }
2331         VirtualTimeScheduler.prototype.flush = function () {
2332             var _a = this, actions = _a.actions, maxFrames = _a.maxFrames;
2333             var error, action;
2334             while ((action = actions[0]) && action.delay <= maxFrames) {
2335                 actions.shift();
2336                 this.frame = action.delay;
2337                 if (error = action.execute(action.state, action.delay)) {
2338                     break;
2339                 }
2340             }
2341             if (error) {
2342                 while (action = actions.shift()) {
2343                     action.unsubscribe();
2344                 }
2345                 throw error;
2346             }
2347         };
2348         VirtualTimeScheduler.frameTimeFactor = 10;
2349         return VirtualTimeScheduler;
2350     }(AsyncScheduler));
2351     var VirtualAction = (function (_super) {
2352         __extends(VirtualAction, _super);
2353         function VirtualAction(scheduler, work, index) {
2354             if (index === void 0) { index = scheduler.index += 1; }
2355             var _this = _super.call(this, scheduler, work) || this;
2356             _this.scheduler = scheduler;
2357             _this.work = work;
2358             _this.index = index;
2359             _this.active = true;
2360             _this.index = scheduler.index = index;
2361             return _this;
2362         }
2363         VirtualAction.prototype.schedule = function (state, delay) {
2364             if (delay === void 0) { delay = 0; }
2365             if (!this.id) {
2366                 return _super.prototype.schedule.call(this, state, delay);
2367             }
2368             this.active = false;
2369             var action = new VirtualAction(this.scheduler, this.work);
2370             this.add(action);
2371             return action.schedule(state, delay);
2372         };
2373         VirtualAction.prototype.requestAsyncId = function (scheduler, id, delay) {
2374             if (delay === void 0) { delay = 0; }
2375             this.delay = scheduler.frame + delay;
2376             var actions = scheduler.actions;
2377             actions.push(this);
2378             actions.sort(VirtualAction.sortActions);
2379             return true;
2380         };
2381         VirtualAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
2382             if (delay === void 0) { delay = 0; }
2383             return undefined;
2384         };
2385         VirtualAction.prototype._execute = function (state, delay) {
2386             if (this.active === true) {
2387                 return _super.prototype._execute.call(this, state, delay);
2388             }
2389         };
2390         VirtualAction.sortActions = function (a, b) {
2391             if (a.delay === b.delay) {
2392                 if (a.index === b.index) {
2393                     return 0;
2394                 }
2395                 else if (a.index > b.index) {
2396                     return 1;
2397                 }
2398                 else {
2399                     return -1;
2400                 }
2401             }
2402             else if (a.delay > b.delay) {
2403                 return 1;
2404             }
2405             else {
2406                 return -1;
2407             }
2408         };
2409         return VirtualAction;
2410     }(AsyncAction));
2411
2412     function noop() { }
2413
2414     function isObservable(obj) {
2415         return !!obj && (obj instanceof Observable || (typeof obj.lift === 'function' && typeof obj.subscribe === 'function'));
2416     }
2417
2418     var ArgumentOutOfRangeErrorImpl = (function () {
2419         function ArgumentOutOfRangeErrorImpl() {
2420             Error.call(this);
2421             this.message = 'argument out of range';
2422             this.name = 'ArgumentOutOfRangeError';
2423             return this;
2424         }
2425         ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype);
2426         return ArgumentOutOfRangeErrorImpl;
2427     })();
2428     var ArgumentOutOfRangeError = ArgumentOutOfRangeErrorImpl;
2429
2430     var EmptyErrorImpl = (function () {
2431         function EmptyErrorImpl() {
2432             Error.call(this);
2433             this.message = 'no elements in sequence';
2434             this.name = 'EmptyError';
2435             return this;
2436         }
2437         EmptyErrorImpl.prototype = Object.create(Error.prototype);
2438         return EmptyErrorImpl;
2439     })();
2440     var EmptyError = EmptyErrorImpl;
2441
2442     var TimeoutErrorImpl = (function () {
2443         function TimeoutErrorImpl() {
2444             Error.call(this);
2445             this.message = 'Timeout has occurred';
2446             this.name = 'TimeoutError';
2447             return this;
2448         }
2449         TimeoutErrorImpl.prototype = Object.create(Error.prototype);
2450         return TimeoutErrorImpl;
2451     })();
2452     var TimeoutError = TimeoutErrorImpl;
2453
2454     function map(project, thisArg) {
2455         return function mapOperation(source) {
2456             if (typeof project !== 'function') {
2457                 throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
2458             }
2459             return source.lift(new MapOperator(project, thisArg));
2460         };
2461     }
2462     var MapOperator = (function () {
2463         function MapOperator(project, thisArg) {
2464             this.project = project;
2465             this.thisArg = thisArg;
2466         }
2467         MapOperator.prototype.call = function (subscriber, source) {
2468             return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
2469         };
2470         return MapOperator;
2471     }());
2472     var MapSubscriber = (function (_super) {
2473         __extends(MapSubscriber, _super);
2474         function MapSubscriber(destination, project, thisArg) {
2475             var _this = _super.call(this, destination) || this;
2476             _this.project = project;
2477             _this.count = 0;
2478             _this.thisArg = thisArg || _this;
2479             return _this;
2480         }
2481         MapSubscriber.prototype._next = function (value) {
2482             var result;
2483             try {
2484                 result = this.project.call(this.thisArg, value, this.count++);
2485             }
2486             catch (err) {
2487                 this.destination.error(err);
2488                 return;
2489             }
2490             this.destination.next(result);
2491         };
2492         return MapSubscriber;
2493     }(Subscriber));
2494
2495     function bindCallback(callbackFunc, resultSelector, scheduler) {
2496         if (resultSelector) {
2497             if (isScheduler(resultSelector)) {
2498                 scheduler = resultSelector;
2499             }
2500             else {
2501                 return function () {
2502                     var args = [];
2503                     for (var _i = 0; _i < arguments.length; _i++) {
2504                         args[_i] = arguments[_i];
2505                     }
2506                     return bindCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
2507                 };
2508             }
2509         }
2510         return function () {
2511             var args = [];
2512             for (var _i = 0; _i < arguments.length; _i++) {
2513                 args[_i] = arguments[_i];
2514             }
2515             var context = this;
2516             var subject;
2517             var params = {
2518                 context: context,
2519                 subject: subject,
2520                 callbackFunc: callbackFunc,
2521                 scheduler: scheduler,
2522             };
2523             return new Observable(function (subscriber) {
2524                 if (!scheduler) {
2525                     if (!subject) {
2526                         subject = new AsyncSubject();
2527                         var handler = function () {
2528                             var innerArgs = [];
2529                             for (var _i = 0; _i < arguments.length; _i++) {
2530                                 innerArgs[_i] = arguments[_i];
2531                             }
2532                             subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
2533                             subject.complete();
2534                         };
2535                         try {
2536                             callbackFunc.apply(context, args.concat([handler]));
2537                         }
2538                         catch (err) {
2539                             if (canReportError(subject)) {
2540                                 subject.error(err);
2541                             }
2542                             else {
2543                                 console.warn(err);
2544                             }
2545                         }
2546                     }
2547                     return subject.subscribe(subscriber);
2548                 }
2549                 else {
2550                     var state = {
2551                         args: args, subscriber: subscriber, params: params,
2552                     };
2553                     return scheduler.schedule(dispatch$1, 0, state);
2554                 }
2555             });
2556         };
2557     }
2558     function dispatch$1(state) {
2559         var _this = this;
2560         var args = state.args, subscriber = state.subscriber, params = state.params;
2561         var callbackFunc = params.callbackFunc, context = params.context, scheduler = params.scheduler;
2562         var subject = params.subject;
2563         if (!subject) {
2564             subject = params.subject = new AsyncSubject();
2565             var handler = function () {
2566                 var innerArgs = [];
2567                 for (var _i = 0; _i < arguments.length; _i++) {
2568                     innerArgs[_i] = arguments[_i];
2569                 }
2570                 var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
2571                 _this.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject }));
2572             };
2573             try {
2574                 callbackFunc.apply(context, args.concat([handler]));
2575             }
2576             catch (err) {
2577                 subject.error(err);
2578             }
2579         }
2580         this.add(subject.subscribe(subscriber));
2581     }
2582     function dispatchNext(state) {
2583         var value = state.value, subject = state.subject;
2584         subject.next(value);
2585         subject.complete();
2586     }
2587
2588     function bindNodeCallback(callbackFunc, resultSelector, scheduler) {
2589         if (resultSelector) {
2590             if (isScheduler(resultSelector)) {
2591                 scheduler = resultSelector;
2592             }
2593             else {
2594                 return function () {
2595                     var args = [];
2596                     for (var _i = 0; _i < arguments.length; _i++) {
2597                         args[_i] = arguments[_i];
2598                     }
2599                     return bindNodeCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
2600                 };
2601             }
2602         }
2603         return function () {
2604             var args = [];
2605             for (var _i = 0; _i < arguments.length; _i++) {
2606                 args[_i] = arguments[_i];
2607             }
2608             var params = {
2609                 subject: undefined,
2610                 args: args,
2611                 callbackFunc: callbackFunc,
2612                 scheduler: scheduler,
2613                 context: this,
2614             };
2615             return new Observable(function (subscriber) {
2616                 var context = params.context;
2617                 var subject = params.subject;
2618                 if (!scheduler) {
2619                     if (!subject) {
2620                         subject = params.subject = new AsyncSubject();
2621                         var handler = function () {
2622                             var innerArgs = [];
2623                             for (var _i = 0; _i < arguments.length; _i++) {
2624                                 innerArgs[_i] = arguments[_i];
2625                             }
2626                             var err = innerArgs.shift();
2627                             if (err) {
2628                                 subject.error(err);
2629                                 return;
2630                             }
2631                             subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
2632                             subject.complete();
2633                         };
2634                         try {
2635                             callbackFunc.apply(context, args.concat([handler]));
2636                         }
2637                         catch (err) {
2638                             if (canReportError(subject)) {
2639                                 subject.error(err);
2640                             }
2641                             else {
2642                                 console.warn(err);
2643                             }
2644                         }
2645                     }
2646                     return subject.subscribe(subscriber);
2647                 }
2648                 else {
2649                     return scheduler.schedule(dispatch$2, 0, { params: params, subscriber: subscriber, context: context });
2650                 }
2651             });
2652         };
2653     }
2654     function dispatch$2(state) {
2655         var _this = this;
2656         var params = state.params, subscriber = state.subscriber, context = state.context;
2657         var callbackFunc = params.callbackFunc, args = params.args, scheduler = params.scheduler;
2658         var subject = params.subject;
2659         if (!subject) {
2660             subject = params.subject = new AsyncSubject();
2661             var handler = function () {
2662                 var innerArgs = [];
2663                 for (var _i = 0; _i < arguments.length; _i++) {
2664                     innerArgs[_i] = arguments[_i];
2665                 }
2666                 var err = innerArgs.shift();
2667                 if (err) {
2668                     _this.add(scheduler.schedule(dispatchError$1, 0, { err: err, subject: subject }));
2669                 }
2670                 else {
2671                     var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
2672                     _this.add(scheduler.schedule(dispatchNext$1, 0, { value: value, subject: subject }));
2673                 }
2674             };
2675             try {
2676                 callbackFunc.apply(context, args.concat([handler]));
2677             }
2678             catch (err) {
2679                 this.add(scheduler.schedule(dispatchError$1, 0, { err: err, subject: subject }));
2680             }
2681         }
2682         this.add(subject.subscribe(subscriber));
2683     }
2684     function dispatchNext$1(arg) {
2685         var value = arg.value, subject = arg.subject;
2686         subject.next(value);
2687         subject.complete();
2688     }
2689     function dispatchError$1(arg) {
2690         var err = arg.err, subject = arg.subject;
2691         subject.error(err);
2692     }
2693
2694     var OuterSubscriber = (function (_super) {
2695         __extends(OuterSubscriber, _super);
2696         function OuterSubscriber() {
2697             return _super !== null && _super.apply(this, arguments) || this;
2698         }
2699         OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
2700             this.destination.next(innerValue);
2701         };
2702         OuterSubscriber.prototype.notifyError = function (error, innerSub) {
2703             this.destination.error(error);
2704         };
2705         OuterSubscriber.prototype.notifyComplete = function (innerSub) {
2706             this.destination.complete();
2707         };
2708         return OuterSubscriber;
2709     }(Subscriber));
2710
2711     var InnerSubscriber = (function (_super) {
2712         __extends(InnerSubscriber, _super);
2713         function InnerSubscriber(parent, outerValue, outerIndex) {
2714             var _this = _super.call(this) || this;
2715             _this.parent = parent;
2716             _this.outerValue = outerValue;
2717             _this.outerIndex = outerIndex;
2718             _this.index = 0;
2719             return _this;
2720         }
2721         InnerSubscriber.prototype._next = function (value) {
2722             this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this);
2723         };
2724         InnerSubscriber.prototype._error = function (error) {
2725             this.parent.notifyError(error, this);
2726             this.unsubscribe();
2727         };
2728         InnerSubscriber.prototype._complete = function () {
2729             this.parent.notifyComplete(this);
2730             this.unsubscribe();
2731         };
2732         return InnerSubscriber;
2733     }(Subscriber));
2734
2735     var subscribeToPromise = function (promise) { return function (subscriber) {
2736         promise.then(function (value) {
2737             if (!subscriber.closed) {
2738                 subscriber.next(value);
2739                 subscriber.complete();
2740             }
2741         }, function (err) { return subscriber.error(err); })
2742             .then(null, hostReportError);
2743         return subscriber;
2744     }; };
2745
2746     function getSymbolIterator() {
2747         if (typeof Symbol !== 'function' || !Symbol.iterator) {
2748             return '@@iterator';
2749         }
2750         return Symbol.iterator;
2751     }
2752     var iterator = getSymbolIterator();
2753
2754     var subscribeToIterable = function (iterable) { return function (subscriber) {
2755         var iterator$$1 = iterable[iterator]();
2756         do {
2757             var item = void 0;
2758             try {
2759                 item = iterator$$1.next();
2760             }
2761             catch (err) {
2762                 subscriber.error(err);
2763                 return subscriber;
2764             }
2765             if (item.done) {
2766                 subscriber.complete();
2767                 break;
2768             }
2769             subscriber.next(item.value);
2770             if (subscriber.closed) {
2771                 break;
2772             }
2773         } while (true);
2774         if (typeof iterator$$1.return === 'function') {
2775             subscriber.add(function () {
2776                 if (iterator$$1.return) {
2777                     iterator$$1.return();
2778                 }
2779             });
2780         }
2781         return subscriber;
2782     }; };
2783
2784     var subscribeToObservable = function (obj) { return function (subscriber) {
2785         var obs = obj[observable]();
2786         if (typeof obs.subscribe !== 'function') {
2787             throw new TypeError('Provided object does not correctly implement Symbol.observable');
2788         }
2789         else {
2790             return obs.subscribe(subscriber);
2791         }
2792     }; };
2793
2794     var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
2795
2796     function isPromise(value) {
2797         return !!value && typeof value.subscribe !== 'function' && typeof value.then === 'function';
2798     }
2799
2800     var subscribeTo = function (result) {
2801         if (!!result && typeof result[observable] === 'function') {
2802             return subscribeToObservable(result);
2803         }
2804         else if (isArrayLike(result)) {
2805             return subscribeToArray(result);
2806         }
2807         else if (isPromise(result)) {
2808             return subscribeToPromise(result);
2809         }
2810         else if (!!result && typeof result[iterator] === 'function') {
2811             return subscribeToIterable(result);
2812         }
2813         else {
2814             var value = isObject(result) ? 'an invalid object' : "'" + result + "'";
2815             var msg = "You provided " + value + " where a stream was expected."
2816                 + ' You can provide an Observable, Promise, Array, or Iterable.';
2817             throw new TypeError(msg);
2818         }
2819     };
2820
2821     function subscribeToResult(outerSubscriber, result, outerValue, outerIndex, innerSubscriber) {
2822         if (innerSubscriber === void 0) { innerSubscriber = new InnerSubscriber(outerSubscriber, outerValue, outerIndex); }
2823         if (innerSubscriber.closed) {
2824             return undefined;
2825         }
2826         if (result instanceof Observable) {
2827             return result.subscribe(innerSubscriber);
2828         }
2829         return subscribeTo(result)(innerSubscriber);
2830     }
2831
2832     var NONE = {};
2833     function combineLatest() {
2834         var observables = [];
2835         for (var _i = 0; _i < arguments.length; _i++) {
2836             observables[_i] = arguments[_i];
2837         }
2838         var resultSelector = null;
2839         var scheduler = null;
2840         if (isScheduler(observables[observables.length - 1])) {
2841             scheduler = observables.pop();
2842         }
2843         if (typeof observables[observables.length - 1] === 'function') {
2844             resultSelector = observables.pop();
2845         }
2846         if (observables.length === 1 && isArray(observables[0])) {
2847             observables = observables[0];
2848         }
2849         return fromArray(observables, scheduler).lift(new CombineLatestOperator(resultSelector));
2850     }
2851     var CombineLatestOperator = (function () {
2852         function CombineLatestOperator(resultSelector) {
2853             this.resultSelector = resultSelector;
2854         }
2855         CombineLatestOperator.prototype.call = function (subscriber, source) {
2856             return source.subscribe(new CombineLatestSubscriber(subscriber, this.resultSelector));
2857         };
2858         return CombineLatestOperator;
2859     }());
2860     var CombineLatestSubscriber = (function (_super) {
2861         __extends(CombineLatestSubscriber, _super);
2862         function CombineLatestSubscriber(destination, resultSelector) {
2863             var _this = _super.call(this, destination) || this;
2864             _this.resultSelector = resultSelector;
2865             _this.active = 0;
2866             _this.values = [];
2867             _this.observables = [];
2868             return _this;
2869         }
2870         CombineLatestSubscriber.prototype._next = function (observable) {
2871             this.values.push(NONE);
2872             this.observables.push(observable);
2873         };
2874         CombineLatestSubscriber.prototype._complete = function () {
2875             var observables = this.observables;
2876             var len = observables.length;
2877             if (len === 0) {
2878                 this.destination.complete();
2879             }
2880             else {
2881                 this.active = len;
2882                 this.toRespond = len;
2883                 for (var i = 0; i < len; i++) {
2884                     var observable = observables[i];
2885                     this.add(subscribeToResult(this, observable, observable, i));
2886                 }
2887             }
2888         };
2889         CombineLatestSubscriber.prototype.notifyComplete = function (unused) {
2890             if ((this.active -= 1) === 0) {
2891                 this.destination.complete();
2892             }
2893         };
2894         CombineLatestSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
2895             var values = this.values;
2896             var oldVal = values[outerIndex];
2897             var toRespond = !this.toRespond
2898                 ? 0
2899                 : oldVal === NONE ? --this.toRespond : this.toRespond;
2900             values[outerIndex] = innerValue;
2901             if (toRespond === 0) {
2902                 if (this.resultSelector) {
2903                     this._tryResultSelector(values);
2904                 }
2905                 else {
2906                     this.destination.next(values.slice());
2907                 }
2908             }
2909         };
2910         CombineLatestSubscriber.prototype._tryResultSelector = function (values) {
2911             var result;
2912             try {
2913                 result = this.resultSelector.apply(this, values);
2914             }
2915             catch (err) {
2916                 this.destination.error(err);
2917                 return;
2918             }
2919             this.destination.next(result);
2920         };
2921         return CombineLatestSubscriber;
2922     }(OuterSubscriber));
2923
2924     function scheduleObservable(input, scheduler) {
2925         return new Observable(function (subscriber) {
2926             var sub = new Subscription();
2927             sub.add(scheduler.schedule(function () {
2928                 var observable$$1 = input[observable]();
2929                 sub.add(observable$$1.subscribe({
2930                     next: function (value) { sub.add(scheduler.schedule(function () { return subscriber.next(value); })); },
2931                     error: function (err) { sub.add(scheduler.schedule(function () { return subscriber.error(err); })); },
2932                     complete: function () { sub.add(scheduler.schedule(function () { return subscriber.complete(); })); },
2933                 }));
2934             }));
2935             return sub;
2936         });
2937     }
2938
2939     function schedulePromise(input, scheduler) {
2940         return new Observable(function (subscriber) {
2941             var sub = new Subscription();
2942             sub.add(scheduler.schedule(function () { return input.then(function (value) {
2943                 sub.add(scheduler.schedule(function () {
2944                     subscriber.next(value);
2945                     sub.add(scheduler.schedule(function () { return subscriber.complete(); }));
2946                 }));
2947             }, function (err) {
2948                 sub.add(scheduler.schedule(function () { return subscriber.error(err); }));
2949             }); }));
2950             return sub;
2951         });
2952     }
2953
2954     function scheduleIterable(input, scheduler) {
2955         if (!input) {
2956             throw new Error('Iterable cannot be null');
2957         }
2958         return new Observable(function (subscriber) {
2959             var sub = new Subscription();
2960             var iterator$$1;
2961             sub.add(function () {
2962                 if (iterator$$1 && typeof iterator$$1.return === 'function') {
2963                     iterator$$1.return();
2964                 }
2965             });
2966             sub.add(scheduler.schedule(function () {
2967                 iterator$$1 = input[iterator]();
2968                 sub.add(scheduler.schedule(function () {
2969                     if (subscriber.closed) {
2970                         return;
2971                     }
2972                     var value;
2973                     var done;
2974                     try {
2975                         var result = iterator$$1.next();
2976                         value = result.value;
2977                         done = result.done;
2978                     }
2979                     catch (err) {
2980                         subscriber.error(err);
2981                         return;
2982                     }
2983                     if (done) {
2984                         subscriber.complete();
2985                     }
2986                     else {
2987                         subscriber.next(value);
2988                         this.schedule();
2989                     }
2990                 }));
2991             }));
2992             return sub;
2993         });
2994     }
2995
2996     function isInteropObservable(input) {
2997         return input && typeof input[observable] === 'function';
2998     }
2999
3000     function isIterable(input) {
3001         return input && typeof input[iterator] === 'function';
3002     }
3003
3004     function scheduled(input, scheduler) {
3005         if (input != null) {
3006             if (isInteropObservable(input)) {
3007                 return scheduleObservable(input, scheduler);
3008             }
3009             else if (isPromise(input)) {
3010                 return schedulePromise(input, scheduler);
3011             }
3012             else if (isArrayLike(input)) {
3013                 return scheduleArray(input, scheduler);
3014             }
3015             else if (isIterable(input) || typeof input === 'string') {
3016                 return scheduleIterable(input, scheduler);
3017             }
3018         }
3019         throw new TypeError((input !== null && typeof input || input) + ' is not observable');
3020     }
3021
3022     function from(input, scheduler) {
3023         if (!scheduler) {
3024             if (input instanceof Observable) {
3025                 return input;
3026             }
3027             return new Observable(subscribeTo(input));
3028         }
3029         else {
3030             return scheduled(input, scheduler);
3031         }
3032     }
3033
3034     function mergeMap(project, resultSelector, concurrent) {
3035         if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
3036         if (typeof resultSelector === 'function') {
3037             return function (source) { return source.pipe(mergeMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); }, concurrent)); };
3038         }
3039         else if (typeof resultSelector === 'number') {
3040             concurrent = resultSelector;
3041         }
3042         return function (source) { return source.lift(new MergeMapOperator(project, concurrent)); };
3043     }
3044     var MergeMapOperator = (function () {
3045         function MergeMapOperator(project, concurrent) {
3046             if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
3047             this.project = project;
3048             this.concurrent = concurrent;
3049         }
3050         MergeMapOperator.prototype.call = function (observer, source) {
3051             return source.subscribe(new MergeMapSubscriber(observer, this.project, this.concurrent));
3052         };
3053         return MergeMapOperator;
3054     }());
3055     var MergeMapSubscriber = (function (_super) {
3056         __extends(MergeMapSubscriber, _super);
3057         function MergeMapSubscriber(destination, project, concurrent) {
3058             if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
3059             var _this = _super.call(this, destination) || this;
3060             _this.project = project;
3061             _this.concurrent = concurrent;
3062             _this.hasCompleted = false;
3063             _this.buffer = [];
3064             _this.active = 0;
3065             _this.index = 0;
3066             return _this;
3067         }
3068         MergeMapSubscriber.prototype._next = function (value) {
3069             if (this.active < this.concurrent) {
3070                 this._tryNext(value);
3071             }
3072             else {
3073                 this.buffer.push(value);
3074             }
3075         };
3076         MergeMapSubscriber.prototype._tryNext = function (value) {
3077             var result;
3078             var index = this.index++;
3079             try {
3080                 result = this.project(value, index);
3081             }
3082             catch (err) {
3083                 this.destination.error(err);
3084                 return;
3085             }
3086             this.active++;
3087             this._innerSub(result, value, index);
3088         };
3089         MergeMapSubscriber.prototype._innerSub = function (ish, value, index) {
3090             var innerSubscriber = new InnerSubscriber(this, value, index);
3091             var destination = this.destination;
3092             destination.add(innerSubscriber);
3093             var innerSubscription = subscribeToResult(this, ish, undefined, undefined, innerSubscriber);
3094             if (innerSubscription !== innerSubscriber) {
3095                 destination.add(innerSubscription);
3096             }
3097         };
3098         MergeMapSubscriber.prototype._complete = function () {
3099             this.hasCompleted = true;
3100             if (this.active === 0 && this.buffer.length === 0) {
3101                 this.destination.complete();
3102             }
3103             this.unsubscribe();
3104         };
3105         MergeMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
3106             this.destination.next(innerValue);
3107         };
3108         MergeMapSubscriber.prototype.notifyComplete = function (innerSub) {
3109             var buffer = this.buffer;
3110             this.remove(innerSub);
3111             this.active--;
3112             if (buffer.length > 0) {
3113                 this._next(buffer.shift());
3114             }
3115             else if (this.active === 0 && this.hasCompleted) {
3116                 this.destination.complete();
3117             }
3118         };
3119         return MergeMapSubscriber;
3120     }(OuterSubscriber));
3121     var flatMap = mergeMap;
3122
3123     function mergeAll(concurrent) {
3124         if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
3125         return mergeMap(identity, concurrent);
3126     }
3127
3128     function concatAll() {
3129         return mergeAll(1);
3130     }
3131
3132     function concat() {
3133         var observables = [];
3134         for (var _i = 0; _i < arguments.length; _i++) {
3135             observables[_i] = arguments[_i];
3136         }
3137         return concatAll()(of.apply(void 0, observables));
3138     }
3139
3140     function defer(observableFactory) {
3141         return new Observable(function (subscriber) {
3142             var input;
3143             try {
3144                 input = observableFactory();
3145             }
3146             catch (err) {
3147                 subscriber.error(err);
3148                 return undefined;
3149             }
3150             var source = input ? from(input) : empty$1();
3151             return source.subscribe(subscriber);
3152         });
3153     }
3154
3155     function forkJoin() {
3156         var sources = [];
3157         for (var _i = 0; _i < arguments.length; _i++) {
3158             sources[_i] = arguments[_i];
3159         }
3160         if (sources.length === 1) {
3161             var first_1 = sources[0];
3162             if (isArray(first_1)) {
3163                 return forkJoinInternal(first_1, null);
3164             }
3165             if (isObject(first_1) && Object.getPrototypeOf(first_1) === Object.prototype) {
3166                 var keys = Object.keys(first_1);
3167                 return forkJoinInternal(keys.map(function (key) { return first_1[key]; }), keys);
3168             }
3169         }
3170         if (typeof sources[sources.length - 1] === 'function') {
3171             var resultSelector_1 = sources.pop();
3172             sources = (sources.length === 1 && isArray(sources[0])) ? sources[0] : sources;
3173             return forkJoinInternal(sources, null).pipe(map(function (args) { return resultSelector_1.apply(void 0, args); }));
3174         }
3175         return forkJoinInternal(sources, null);
3176     }
3177     function forkJoinInternal(sources, keys) {
3178         return new Observable(function (subscriber) {
3179             var len = sources.length;
3180             if (len === 0) {
3181                 subscriber.complete();
3182                 return;
3183             }
3184             var values = new Array(len);
3185             var completed = 0;
3186             var emitted = 0;
3187             var _loop_1 = function (i) {
3188                 var source = from(sources[i]);
3189                 var hasValue = false;
3190                 subscriber.add(source.subscribe({
3191                     next: function (value) {
3192                         if (!hasValue) {
3193                             hasValue = true;
3194                             emitted++;
3195                         }
3196                         values[i] = value;
3197                     },
3198                     error: function (err) { return subscriber.error(err); },
3199                     complete: function () {
3200                         completed++;
3201                         if (completed === len || !hasValue) {
3202                             if (emitted === len) {
3203                                 subscriber.next(keys ?
3204                                     keys.reduce(function (result, key, i) { return (result[key] = values[i], result); }, {}) :
3205                                     values);
3206                             }
3207                             subscriber.complete();
3208                         }
3209                     }
3210                 }));
3211             };
3212             for (var i = 0; i < len; i++) {
3213                 _loop_1(i);
3214             }
3215         });
3216     }
3217
3218     function fromEvent(target, eventName, options, resultSelector) {
3219         if (isFunction(options)) {
3220             resultSelector = options;
3221             options = undefined;
3222         }
3223         if (resultSelector) {
3224             return fromEvent(target, eventName, options).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
3225         }
3226         return new Observable(function (subscriber) {
3227             function handler(e) {
3228                 if (arguments.length > 1) {
3229                     subscriber.next(Array.prototype.slice.call(arguments));
3230                 }
3231                 else {
3232                     subscriber.next(e);
3233                 }
3234             }
3235             setupSubscription(target, eventName, handler, subscriber, options);
3236         });
3237     }
3238     function setupSubscription(sourceObj, eventName, handler, subscriber, options) {
3239         var unsubscribe;
3240         if (isEventTarget(sourceObj)) {
3241             var source_1 = sourceObj;
3242             sourceObj.addEventListener(eventName, handler, options);
3243             unsubscribe = function () { return source_1.removeEventListener(eventName, handler, options); };
3244         }
3245         else if (isJQueryStyleEventEmitter(sourceObj)) {
3246             var source_2 = sourceObj;
3247             sourceObj.on(eventName, handler);
3248             unsubscribe = function () { return source_2.off(eventName, handler); };
3249         }
3250         else if (isNodeStyleEventEmitter(sourceObj)) {
3251             var source_3 = sourceObj;
3252             sourceObj.addListener(eventName, handler);
3253             unsubscribe = function () { return source_3.removeListener(eventName, handler); };
3254         }
3255         else if (sourceObj && sourceObj.length) {
3256             for (var i = 0, len = sourceObj.length; i < len; i++) {
3257                 setupSubscription(sourceObj[i], eventName, handler, subscriber, options);
3258             }
3259         }
3260         else {
3261             throw new TypeError('Invalid event target');
3262         }
3263         subscriber.add(unsubscribe);
3264     }
3265     function isNodeStyleEventEmitter(sourceObj) {
3266         return sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function';
3267     }
3268     function isJQueryStyleEventEmitter(sourceObj) {
3269         return sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function';
3270     }
3271     function isEventTarget(sourceObj) {
3272         return sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function';
3273     }
3274
3275     function fromEventPattern(addHandler, removeHandler, resultSelector) {
3276         if (resultSelector) {
3277             return fromEventPattern(addHandler, removeHandler).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
3278         }
3279         return new Observable(function (subscriber) {
3280             var handler = function () {
3281                 var e = [];
3282                 for (var _i = 0; _i < arguments.length; _i++) {
3283                     e[_i] = arguments[_i];
3284                 }
3285                 return subscriber.next(e.length === 1 ? e[0] : e);
3286             };
3287             var retValue;
3288             try {
3289                 retValue = addHandler(handler);
3290             }
3291             catch (err) {
3292                 subscriber.error(err);
3293                 return undefined;
3294             }
3295             if (!isFunction(removeHandler)) {
3296                 return undefined;
3297             }
3298             return function () { return removeHandler(handler, retValue); };
3299         });
3300     }
3301
3302     function generate(initialStateOrOptions, condition, iterate, resultSelectorOrObservable, scheduler) {
3303         var resultSelector;
3304         var initialState;
3305         if (arguments.length == 1) {
3306             var options = initialStateOrOptions;
3307             initialState = options.initialState;
3308             condition = options.condition;
3309             iterate = options.iterate;
3310             resultSelector = options.resultSelector || identity;
3311             scheduler = options.scheduler;
3312         }
3313         else if (resultSelectorOrObservable === undefined || isScheduler(resultSelectorOrObservable)) {
3314             initialState = initialStateOrOptions;
3315             resultSelector = identity;
3316             scheduler = resultSelectorOrObservable;
3317         }
3318         else {
3319             initialState = initialStateOrOptions;
3320             resultSelector = resultSelectorOrObservable;
3321         }
3322         return new Observable(function (subscriber) {
3323             var state = initialState;
3324             if (scheduler) {
3325                 return scheduler.schedule(dispatch$3, 0, {
3326                     subscriber: subscriber,
3327                     iterate: iterate,
3328                     condition: condition,
3329                     resultSelector: resultSelector,
3330                     state: state
3331                 });
3332             }
3333             do {
3334                 if (condition) {
3335                     var conditionResult = void 0;
3336                     try {
3337                         conditionResult = condition(state);
3338                     }
3339                     catch (err) {
3340                         subscriber.error(err);
3341                         return undefined;
3342                     }
3343                     if (!conditionResult) {
3344                         subscriber.complete();
3345                         break;
3346                     }
3347                 }
3348                 var value = void 0;
3349                 try {
3350                     value = resultSelector(state);
3351                 }
3352                 catch (err) {
3353                     subscriber.error(err);
3354                     return undefined;
3355                 }
3356                 subscriber.next(value);
3357                 if (subscriber.closed) {
3358                     break;
3359                 }
3360                 try {
3361                     state = iterate(state);
3362                 }
3363                 catch (err) {
3364                     subscriber.error(err);
3365                     return undefined;
3366                 }
3367             } while (true);
3368             return undefined;
3369         });
3370     }
3371     function dispatch$3(state) {
3372         var subscriber = state.subscriber, condition = state.condition;
3373         if (subscriber.closed) {
3374             return undefined;
3375         }
3376         if (state.needIterate) {
3377             try {
3378                 state.state = state.iterate(state.state);
3379             }
3380             catch (err) {
3381                 subscriber.error(err);
3382                 return undefined;
3383             }
3384         }
3385         else {
3386             state.needIterate = true;
3387         }
3388         if (condition) {
3389             var conditionResult = void 0;
3390             try {
3391                 conditionResult = condition(state.state);
3392             }
3393             catch (err) {
3394                 subscriber.error(err);
3395                 return undefined;
3396             }
3397             if (!conditionResult) {
3398                 subscriber.complete();
3399                 return undefined;
3400             }
3401             if (subscriber.closed) {
3402                 return undefined;
3403             }
3404         }
3405         var value;
3406         try {
3407             value = state.resultSelector(state.state);
3408         }
3409         catch (err) {
3410             subscriber.error(err);
3411             return undefined;
3412         }
3413         if (subscriber.closed) {
3414             return undefined;
3415         }
3416         subscriber.next(value);
3417         if (subscriber.closed) {
3418             return undefined;
3419         }
3420         return this.schedule(state);
3421     }
3422
3423     function iif(condition, trueResult, falseResult) {
3424         if (trueResult === void 0) { trueResult = EMPTY; }
3425         if (falseResult === void 0) { falseResult = EMPTY; }
3426         return defer(function () { return condition() ? trueResult : falseResult; });
3427     }
3428
3429     function isNumeric(val) {
3430         return !isArray(val) && (val - parseFloat(val) + 1) >= 0;
3431     }
3432
3433     function interval(period, scheduler) {
3434         if (period === void 0) { period = 0; }
3435         if (scheduler === void 0) { scheduler = async; }
3436         if (!isNumeric(period) || period < 0) {
3437             period = 0;
3438         }
3439         if (!scheduler || typeof scheduler.schedule !== 'function') {
3440             scheduler = async;
3441         }
3442         return new Observable(function (subscriber) {
3443             subscriber.add(scheduler.schedule(dispatch$4, period, { subscriber: subscriber, counter: 0, period: period }));
3444             return subscriber;
3445         });
3446     }
3447     function dispatch$4(state) {
3448         var subscriber = state.subscriber, counter = state.counter, period = state.period;
3449         subscriber.next(counter);
3450         this.schedule({ subscriber: subscriber, counter: counter + 1, period: period }, period);
3451     }
3452
3453     function merge() {
3454         var observables = [];
3455         for (var _i = 0; _i < arguments.length; _i++) {
3456             observables[_i] = arguments[_i];
3457         }
3458         var concurrent = Number.POSITIVE_INFINITY;
3459         var scheduler = null;
3460         var last = observables[observables.length - 1];
3461         if (isScheduler(last)) {
3462             scheduler = observables.pop();
3463             if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
3464                 concurrent = observables.pop();
3465             }
3466         }
3467         else if (typeof last === 'number') {
3468             concurrent = observables.pop();
3469         }
3470         if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable) {
3471             return observables[0];
3472         }
3473         return mergeAll(concurrent)(fromArray(observables, scheduler));
3474     }
3475
3476     var NEVER = new Observable(noop);
3477     function never() {
3478         return NEVER;
3479     }
3480
3481     function onErrorResumeNext() {
3482         var sources = [];
3483         for (var _i = 0; _i < arguments.length; _i++) {
3484             sources[_i] = arguments[_i];
3485         }
3486         if (sources.length === 0) {
3487             return EMPTY;
3488         }
3489         var first = sources[0], remainder = sources.slice(1);
3490         if (sources.length === 1 && isArray(first)) {
3491             return onErrorResumeNext.apply(void 0, first);
3492         }
3493         return new Observable(function (subscriber) {
3494             var subNext = function () { return subscriber.add(onErrorResumeNext.apply(void 0, remainder).subscribe(subscriber)); };
3495             return from(first).subscribe({
3496                 next: function (value) { subscriber.next(value); },
3497                 error: subNext,
3498                 complete: subNext,
3499             });
3500         });
3501     }
3502
3503     function pairs(obj, scheduler) {
3504         if (!scheduler) {
3505             return new Observable(function (subscriber) {
3506                 var keys = Object.keys(obj);
3507                 for (var i = 0; i < keys.length && !subscriber.closed; i++) {
3508                     var key = keys[i];
3509                     if (obj.hasOwnProperty(key)) {
3510                         subscriber.next([key, obj[key]]);
3511                     }
3512                 }
3513                 subscriber.complete();
3514             });
3515         }
3516         else {
3517             return new Observable(function (subscriber) {
3518                 var keys = Object.keys(obj);
3519                 var subscription = new Subscription();
3520                 subscription.add(scheduler.schedule(dispatch$5, 0, { keys: keys, index: 0, subscriber: subscriber, subscription: subscription, obj: obj }));
3521                 return subscription;
3522             });
3523         }
3524     }
3525     function dispatch$5(state) {
3526         var keys = state.keys, index = state.index, subscriber = state.subscriber, subscription = state.subscription, obj = state.obj;
3527         if (!subscriber.closed) {
3528             if (index < keys.length) {
3529                 var key = keys[index];
3530                 subscriber.next([key, obj[key]]);
3531                 subscription.add(this.schedule({ keys: keys, index: index + 1, subscriber: subscriber, subscription: subscription, obj: obj }));
3532             }
3533             else {
3534                 subscriber.complete();
3535             }
3536         }
3537     }
3538
3539     function not(pred, thisArg) {
3540         function notPred() {
3541             return !(notPred.pred.apply(notPred.thisArg, arguments));
3542         }
3543         notPred.pred = pred;
3544         notPred.thisArg = thisArg;
3545         return notPred;
3546     }
3547
3548     function filter(predicate, thisArg) {
3549         return function filterOperatorFunction(source) {
3550             return source.lift(new FilterOperator(predicate, thisArg));
3551         };
3552     }
3553     var FilterOperator = (function () {
3554         function FilterOperator(predicate, thisArg) {
3555             this.predicate = predicate;
3556             this.thisArg = thisArg;
3557         }
3558         FilterOperator.prototype.call = function (subscriber, source) {
3559             return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
3560         };
3561         return FilterOperator;
3562     }());
3563     var FilterSubscriber = (function (_super) {
3564         __extends(FilterSubscriber, _super);
3565         function FilterSubscriber(destination, predicate, thisArg) {
3566             var _this = _super.call(this, destination) || this;
3567             _this.predicate = predicate;
3568             _this.thisArg = thisArg;
3569             _this.count = 0;
3570             return _this;
3571         }
3572         FilterSubscriber.prototype._next = function (value) {
3573             var result;
3574             try {
3575                 result = this.predicate.call(this.thisArg, value, this.count++);
3576             }
3577             catch (err) {
3578                 this.destination.error(err);
3579                 return;
3580             }
3581             if (result) {
3582                 this.destination.next(value);
3583             }
3584         };
3585         return FilterSubscriber;
3586     }(Subscriber));
3587
3588     function partition(source, predicate, thisArg) {
3589         return [
3590             filter(predicate, thisArg)(new Observable(subscribeTo(source))),
3591             filter(not(predicate, thisArg))(new Observable(subscribeTo(source)))
3592         ];
3593     }
3594
3595     function race() {
3596         var observables = [];
3597         for (var _i = 0; _i < arguments.length; _i++) {
3598             observables[_i] = arguments[_i];
3599         }
3600         if (observables.length === 1) {
3601             if (isArray(observables[0])) {
3602                 observables = observables[0];
3603             }
3604             else {
3605                 return observables[0];
3606             }
3607         }
3608         return fromArray(observables, undefined).lift(new RaceOperator());
3609     }
3610     var RaceOperator = (function () {
3611         function RaceOperator() {
3612         }
3613         RaceOperator.prototype.call = function (subscriber, source) {
3614             return source.subscribe(new RaceSubscriber(subscriber));
3615         };
3616         return RaceOperator;
3617     }());
3618     var RaceSubscriber = (function (_super) {
3619         __extends(RaceSubscriber, _super);
3620         function RaceSubscriber(destination) {
3621             var _this = _super.call(this, destination) || this;
3622             _this.hasFirst = false;
3623             _this.observables = [];
3624             _this.subscriptions = [];
3625             return _this;
3626         }
3627         RaceSubscriber.prototype._next = function (observable) {
3628             this.observables.push(observable);
3629         };
3630         RaceSubscriber.prototype._complete = function () {
3631             var observables = this.observables;
3632             var len = observables.length;
3633             if (len === 0) {
3634                 this.destination.complete();
3635             }
3636             else {
3637                 for (var i = 0; i < len && !this.hasFirst; i++) {
3638                     var observable = observables[i];
3639                     var subscription = subscribeToResult(this, observable, observable, i);
3640                     if (this.subscriptions) {
3641                         this.subscriptions.push(subscription);
3642                     }
3643                     this.add(subscription);
3644                 }
3645                 this.observables = null;
3646             }
3647         };
3648         RaceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
3649             if (!this.hasFirst) {
3650                 this.hasFirst = true;
3651                 for (var i = 0; i < this.subscriptions.length; i++) {
3652                     if (i !== outerIndex) {
3653                         var subscription = this.subscriptions[i];
3654                         subscription.unsubscribe();
3655                         this.remove(subscription);
3656                     }
3657                 }
3658                 this.subscriptions = null;
3659             }
3660             this.destination.next(innerValue);
3661         };
3662         return RaceSubscriber;
3663     }(OuterSubscriber));
3664
3665     function range(start, count, scheduler) {
3666         if (start === void 0) { start = 0; }
3667         return new Observable(function (subscriber) {
3668             if (count === undefined) {
3669                 count = start;
3670                 start = 0;
3671             }
3672             var index = 0;
3673             var current = start;
3674             if (scheduler) {
3675                 return scheduler.schedule(dispatch$6, 0, {
3676                     index: index, count: count, start: start, subscriber: subscriber
3677                 });
3678             }
3679             else {
3680                 do {
3681                     if (index++ >= count) {
3682                         subscriber.complete();
3683                         break;
3684                     }
3685                     subscriber.next(current++);
3686                     if (subscriber.closed) {
3687                         break;
3688                     }
3689                 } while (true);
3690             }
3691             return undefined;
3692         });
3693     }
3694     function dispatch$6(state) {
3695         var start = state.start, index = state.index, count = state.count, subscriber = state.subscriber;
3696         if (index >= count) {
3697             subscriber.complete();
3698             return;
3699         }
3700         subscriber.next(start);
3701         if (subscriber.closed) {
3702             return;
3703         }
3704         state.index = index + 1;
3705         state.start = start + 1;
3706         this.schedule(state);
3707     }
3708
3709     function timer(dueTime, periodOrScheduler, scheduler) {
3710         if (dueTime === void 0) { dueTime = 0; }
3711         var period = -1;
3712         if (isNumeric(periodOrScheduler)) {
3713             period = Number(periodOrScheduler) < 1 && 1 || Number(periodOrScheduler);
3714         }
3715         else if (isScheduler(periodOrScheduler)) {
3716             scheduler = periodOrScheduler;
3717         }
3718         if (!isScheduler(scheduler)) {
3719             scheduler = async;
3720         }
3721         return new Observable(function (subscriber) {
3722             var due = isNumeric(dueTime)
3723                 ? dueTime
3724                 : (+dueTime - scheduler.now());
3725             return scheduler.schedule(dispatch$7, due, {
3726                 index: 0, period: period, subscriber: subscriber
3727             });
3728         });
3729     }
3730     function dispatch$7(state) {
3731         var index = state.index, period = state.period, subscriber = state.subscriber;
3732         subscriber.next(index);
3733         if (subscriber.closed) {
3734             return;
3735         }
3736         else if (period === -1) {
3737             return subscriber.complete();
3738         }
3739         state.index = index + 1;
3740         this.schedule(state, period);
3741     }
3742
3743     function using(resourceFactory, observableFactory) {
3744         return new Observable(function (subscriber) {
3745             var resource;
3746             try {
3747                 resource = resourceFactory();
3748             }
3749             catch (err) {
3750                 subscriber.error(err);
3751                 return undefined;
3752             }
3753             var result;
3754             try {
3755                 result = observableFactory(resource);
3756             }
3757             catch (err) {
3758                 subscriber.error(err);
3759                 return undefined;
3760             }
3761             var source = result ? from(result) : EMPTY;
3762             var subscription = source.subscribe(subscriber);
3763             return function () {
3764                 subscription.unsubscribe();
3765                 if (resource) {
3766                     resource.unsubscribe();
3767                 }
3768             };
3769         });
3770     }
3771
3772     function zip() {
3773         var observables = [];
3774         for (var _i = 0; _i < arguments.length; _i++) {
3775             observables[_i] = arguments[_i];
3776         }
3777         var resultSelector = observables[observables.length - 1];
3778         if (typeof resultSelector === 'function') {
3779             observables.pop();
3780         }
3781         return fromArray(observables, undefined).lift(new ZipOperator(resultSelector));
3782     }
3783     var ZipOperator = (function () {
3784         function ZipOperator(resultSelector) {
3785             this.resultSelector = resultSelector;
3786         }
3787         ZipOperator.prototype.call = function (subscriber, source) {
3788             return source.subscribe(new ZipSubscriber(subscriber, this.resultSelector));
3789         };
3790         return ZipOperator;
3791     }());
3792     var ZipSubscriber = (function (_super) {
3793         __extends(ZipSubscriber, _super);
3794         function ZipSubscriber(destination, resultSelector, values) {
3795             if (values === void 0) { values = Object.create(null); }
3796             var _this = _super.call(this, destination) || this;
3797             _this.iterators = [];
3798             _this.active = 0;
3799             _this.resultSelector = (typeof resultSelector === 'function') ? resultSelector : null;
3800             _this.values = values;
3801             return _this;
3802         }
3803         ZipSubscriber.prototype._next = function (value) {
3804             var iterators = this.iterators;
3805             if (isArray(value)) {
3806                 iterators.push(new StaticArrayIterator(value));
3807             }
3808             else if (typeof value[iterator] === 'function') {
3809                 iterators.push(new StaticIterator(value[iterator]()));
3810             }
3811             else {
3812                 iterators.push(new ZipBufferIterator(this.destination, this, value));
3813             }
3814         };
3815         ZipSubscriber.prototype._complete = function () {
3816             var iterators = this.iterators;
3817             var len = iterators.length;
3818             this.unsubscribe();
3819             if (len === 0) {
3820                 this.destination.complete();
3821                 return;
3822             }
3823             this.active = len;
3824             for (var i = 0; i < len; i++) {
3825                 var iterator$$1 = iterators[i];
3826                 if (iterator$$1.stillUnsubscribed) {
3827                     var destination = this.destination;
3828                     destination.add(iterator$$1.subscribe(iterator$$1, i));
3829                 }
3830                 else {
3831                     this.active--;
3832                 }
3833             }
3834         };
3835         ZipSubscriber.prototype.notifyInactive = function () {
3836             this.active--;
3837             if (this.active === 0) {
3838                 this.destination.complete();
3839             }
3840         };
3841         ZipSubscriber.prototype.checkIterators = function () {
3842             var iterators = this.iterators;
3843             var len = iterators.length;
3844             var destination = this.destination;
3845             for (var i = 0; i < len; i++) {
3846                 var iterator$$1 = iterators[i];
3847                 if (typeof iterator$$1.hasValue === 'function' && !iterator$$1.hasValue()) {
3848                     return;
3849                 }
3850             }
3851             var shouldComplete = false;
3852             var args = [];
3853             for (var i = 0; i < len; i++) {
3854                 var iterator$$1 = iterators[i];
3855                 var result = iterator$$1.next();
3856                 if (iterator$$1.hasCompleted()) {
3857                     shouldComplete = true;
3858                 }
3859                 if (result.done) {
3860                     destination.complete();
3861                     return;
3862                 }
3863                 args.push(result.value);
3864             }
3865             if (this.resultSelector) {
3866                 this._tryresultSelector(args);
3867             }
3868             else {
3869                 destination.next(args);
3870             }
3871             if (shouldComplete) {
3872                 destination.complete();
3873             }
3874         };
3875         ZipSubscriber.prototype._tryresultSelector = function (args) {
3876             var result;
3877             try {
3878                 result = this.resultSelector.apply(this, args);
3879             }
3880             catch (err) {
3881                 this.destination.error(err);
3882                 return;
3883             }
3884             this.destination.next(result);
3885         };
3886         return ZipSubscriber;
3887     }(Subscriber));
3888     var StaticIterator = (function () {
3889         function StaticIterator(iterator$$1) {
3890             this.iterator = iterator$$1;
3891             this.nextResult = iterator$$1.next();
3892         }
3893         StaticIterator.prototype.hasValue = function () {
3894             return true;
3895         };
3896         StaticIterator.prototype.next = function () {
3897             var result = this.nextResult;
3898             this.nextResult = this.iterator.next();
3899             return result;
3900         };
3901         StaticIterator.prototype.hasCompleted = function () {
3902             var nextResult = this.nextResult;
3903             return nextResult && nextResult.done;
3904         };
3905         return StaticIterator;
3906     }());
3907     var StaticArrayIterator = (function () {
3908         function StaticArrayIterator(array) {
3909             this.array = array;
3910             this.index = 0;
3911             this.length = 0;
3912             this.length = array.length;
3913         }
3914         StaticArrayIterator.prototype[iterator] = function () {
3915             return this;
3916         };
3917         StaticArrayIterator.prototype.next = function (value) {
3918             var i = this.index++;
3919             var array = this.array;
3920             return i < this.length ? { value: array[i], done: false } : { value: null, done: true };
3921         };
3922         StaticArrayIterator.prototype.hasValue = function () {
3923             return this.array.length > this.index;
3924         };
3925         StaticArrayIterator.prototype.hasCompleted = function () {
3926             return this.array.length === this.index;
3927         };
3928         return StaticArrayIterator;
3929     }());
3930     var ZipBufferIterator = (function (_super) {
3931         __extends(ZipBufferIterator, _super);
3932         function ZipBufferIterator(destination, parent, observable) {
3933             var _this = _super.call(this, destination) || this;
3934             _this.parent = parent;
3935             _this.observable = observable;
3936             _this.stillUnsubscribed = true;
3937             _this.buffer = [];
3938             _this.isComplete = false;
3939             return _this;
3940         }
3941         ZipBufferIterator.prototype[iterator] = function () {
3942             return this;
3943         };
3944         ZipBufferIterator.prototype.next = function () {
3945             var buffer = this.buffer;
3946             if (buffer.length === 0 && this.isComplete) {
3947                 return { value: null, done: true };
3948             }
3949             else {
3950                 return { value: buffer.shift(), done: false };
3951             }
3952         };
3953         ZipBufferIterator.prototype.hasValue = function () {
3954             return this.buffer.length > 0;
3955         };
3956         ZipBufferIterator.prototype.hasCompleted = function () {
3957             return this.buffer.length === 0 && this.isComplete;
3958         };
3959         ZipBufferIterator.prototype.notifyComplete = function () {
3960             if (this.buffer.length > 0) {
3961                 this.isComplete = true;
3962                 this.parent.notifyInactive();
3963             }
3964             else {
3965                 this.destination.complete();
3966             }
3967         };
3968         ZipBufferIterator.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
3969             this.buffer.push(innerValue);
3970             this.parent.checkIterators();
3971         };
3972         ZipBufferIterator.prototype.subscribe = function (value, index) {
3973             return subscribeToResult(this, this.observable, this, index);
3974         };
3975         return ZipBufferIterator;
3976     }(OuterSubscriber));
3977
3978     function audit(durationSelector) {
3979         return function auditOperatorFunction(source) {
3980             return source.lift(new AuditOperator(durationSelector));
3981         };
3982     }
3983     var AuditOperator = (function () {
3984         function AuditOperator(durationSelector) {
3985             this.durationSelector = durationSelector;
3986         }
3987         AuditOperator.prototype.call = function (subscriber, source) {
3988             return source.subscribe(new AuditSubscriber(subscriber, this.durationSelector));
3989         };
3990         return AuditOperator;
3991     }());
3992     var AuditSubscriber = (function (_super) {
3993         __extends(AuditSubscriber, _super);
3994         function AuditSubscriber(destination, durationSelector) {
3995             var _this = _super.call(this, destination) || this;
3996             _this.durationSelector = durationSelector;
3997             _this.hasValue = false;
3998             return _this;
3999         }
4000         AuditSubscriber.prototype._next = function (value) {
4001             this.value = value;
4002             this.hasValue = true;
4003             if (!this.throttled) {
4004                 var duration = void 0;
4005                 try {
4006                     var durationSelector = this.durationSelector;
4007                     duration = durationSelector(value);
4008                 }
4009                 catch (err) {
4010                     return this.destination.error(err);
4011                 }
4012                 var innerSubscription = subscribeToResult(this, duration);
4013                 if (!innerSubscription || innerSubscription.closed) {
4014                     this.clearThrottle();
4015                 }
4016                 else {
4017                     this.add(this.throttled = innerSubscription);
4018                 }
4019             }
4020         };
4021         AuditSubscriber.prototype.clearThrottle = function () {
4022             var _a = this, value = _a.value, hasValue = _a.hasValue, throttled = _a.throttled;
4023             if (throttled) {
4024                 this.remove(throttled);
4025                 this.throttled = null;
4026                 throttled.unsubscribe();
4027             }
4028             if (hasValue) {
4029                 this.value = null;
4030                 this.hasValue = false;
4031                 this.destination.next(value);
4032             }
4033         };
4034         AuditSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex) {
4035             this.clearThrottle();
4036         };
4037         AuditSubscriber.prototype.notifyComplete = function () {
4038             this.clearThrottle();
4039         };
4040         return AuditSubscriber;
4041     }(OuterSubscriber));
4042
4043     function auditTime(duration, scheduler) {
4044         if (scheduler === void 0) { scheduler = async; }
4045         return audit(function () { return timer(duration, scheduler); });
4046     }
4047
4048     function buffer(closingNotifier) {
4049         return function bufferOperatorFunction(source) {
4050             return source.lift(new BufferOperator(closingNotifier));
4051         };
4052     }
4053     var BufferOperator = (function () {
4054         function BufferOperator(closingNotifier) {
4055             this.closingNotifier = closingNotifier;
4056         }
4057         BufferOperator.prototype.call = function (subscriber, source) {
4058             return source.subscribe(new BufferSubscriber(subscriber, this.closingNotifier));
4059         };
4060         return BufferOperator;
4061     }());
4062     var BufferSubscriber = (function (_super) {
4063         __extends(BufferSubscriber, _super);
4064         function BufferSubscriber(destination, closingNotifier) {
4065             var _this = _super.call(this, destination) || this;
4066             _this.buffer = [];
4067             _this.add(subscribeToResult(_this, closingNotifier));
4068             return _this;
4069         }
4070         BufferSubscriber.prototype._next = function (value) {
4071             this.buffer.push(value);
4072         };
4073         BufferSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
4074             var buffer = this.buffer;
4075             this.buffer = [];
4076             this.destination.next(buffer);
4077         };
4078         return BufferSubscriber;
4079     }(OuterSubscriber));
4080
4081     function bufferCount(bufferSize, startBufferEvery) {
4082         if (startBufferEvery === void 0) { startBufferEvery = null; }
4083         return function bufferCountOperatorFunction(source) {
4084             return source.lift(new BufferCountOperator(bufferSize, startBufferEvery));
4085         };
4086     }
4087     var BufferCountOperator = (function () {
4088         function BufferCountOperator(bufferSize, startBufferEvery) {
4089             this.bufferSize = bufferSize;
4090             this.startBufferEvery = startBufferEvery;
4091             if (!startBufferEvery || bufferSize === startBufferEvery) {
4092                 this.subscriberClass = BufferCountSubscriber;
4093             }
4094             else {
4095                 this.subscriberClass = BufferSkipCountSubscriber;
4096             }
4097         }
4098         BufferCountOperator.prototype.call = function (subscriber, source) {
4099             return source.subscribe(new this.subscriberClass(subscriber, this.bufferSize, this.startBufferEvery));
4100         };
4101         return BufferCountOperator;
4102     }());
4103     var BufferCountSubscriber = (function (_super) {
4104         __extends(BufferCountSubscriber, _super);
4105         function BufferCountSubscriber(destination, bufferSize) {
4106             var _this = _super.call(this, destination) || this;
4107             _this.bufferSize = bufferSize;
4108             _this.buffer = [];
4109             return _this;
4110         }
4111         BufferCountSubscriber.prototype._next = function (value) {
4112             var buffer = this.buffer;
4113             buffer.push(value);
4114             if (buffer.length == this.bufferSize) {
4115                 this.destination.next(buffer);
4116                 this.buffer = [];
4117             }
4118         };
4119         BufferCountSubscriber.prototype._complete = function () {
4120             var buffer = this.buffer;
4121             if (buffer.length > 0) {
4122                 this.destination.next(buffer);
4123             }
4124             _super.prototype._complete.call(this);
4125         };
4126         return BufferCountSubscriber;
4127     }(Subscriber));
4128     var BufferSkipCountSubscriber = (function (_super) {
4129         __extends(BufferSkipCountSubscriber, _super);
4130         function BufferSkipCountSubscriber(destination, bufferSize, startBufferEvery) {
4131             var _this = _super.call(this, destination) || this;
4132             _this.bufferSize = bufferSize;
4133             _this.startBufferEvery = startBufferEvery;
4134             _this.buffers = [];
4135             _this.count = 0;
4136             return _this;
4137         }
4138         BufferSkipCountSubscriber.prototype._next = function (value) {
4139             var _a = this, bufferSize = _a.bufferSize, startBufferEvery = _a.startBufferEvery, buffers = _a.buffers, count = _a.count;
4140             this.count++;
4141             if (count % startBufferEvery === 0) {
4142                 buffers.push([]);
4143             }
4144             for (var i = buffers.length; i--;) {
4145                 var buffer = buffers[i];
4146                 buffer.push(value);
4147                 if (buffer.length === bufferSize) {
4148                     buffers.splice(i, 1);
4149                     this.destination.next(buffer);
4150                 }
4151             }
4152         };
4153         BufferSkipCountSubscriber.prototype._complete = function () {
4154             var _a = this, buffers = _a.buffers, destination = _a.destination;
4155             while (buffers.length > 0) {
4156                 var buffer = buffers.shift();
4157                 if (buffer.length > 0) {
4158                     destination.next(buffer);
4159                 }
4160             }
4161             _super.prototype._complete.call(this);
4162         };
4163         return BufferSkipCountSubscriber;
4164     }(Subscriber));
4165
4166     function bufferTime(bufferTimeSpan) {
4167         var length = arguments.length;
4168         var scheduler = async;
4169         if (isScheduler(arguments[arguments.length - 1])) {
4170             scheduler = arguments[arguments.length - 1];
4171             length--;
4172         }
4173         var bufferCreationInterval = null;
4174         if (length >= 2) {
4175             bufferCreationInterval = arguments[1];
4176         }
4177         var maxBufferSize = Number.POSITIVE_INFINITY;
4178         if (length >= 3) {
4179             maxBufferSize = arguments[2];
4180         }
4181         return function bufferTimeOperatorFunction(source) {
4182             return source.lift(new BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler));
4183         };
4184     }
4185     var BufferTimeOperator = (function () {
4186         function BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
4187             this.bufferTimeSpan = bufferTimeSpan;
4188             this.bufferCreationInterval = bufferCreationInterval;
4189             this.maxBufferSize = maxBufferSize;
4190             this.scheduler = scheduler;
4191         }
4192         BufferTimeOperator.prototype.call = function (subscriber, source) {
4193             return source.subscribe(new BufferTimeSubscriber(subscriber, this.bufferTimeSpan, this.bufferCreationInterval, this.maxBufferSize, this.scheduler));
4194         };
4195         return BufferTimeOperator;
4196     }());
4197     var Context = (function () {
4198         function Context() {
4199             this.buffer = [];
4200         }
4201         return Context;
4202     }());
4203     var BufferTimeSubscriber = (function (_super) {
4204         __extends(BufferTimeSubscriber, _super);
4205         function BufferTimeSubscriber(destination, bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
4206             var _this = _super.call(this, destination) || this;
4207             _this.bufferTimeSpan = bufferTimeSpan;
4208             _this.bufferCreationInterval = bufferCreationInterval;
4209             _this.maxBufferSize = maxBufferSize;
4210             _this.scheduler = scheduler;
4211             _this.contexts = [];
4212             var context = _this.openContext();
4213             _this.timespanOnly = bufferCreationInterval == null || bufferCreationInterval < 0;
4214             if (_this.timespanOnly) {
4215                 var timeSpanOnlyState = { subscriber: _this, context: context, bufferTimeSpan: bufferTimeSpan };
4216                 _this.add(context.closeAction = scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
4217             }
4218             else {
4219                 var closeState = { subscriber: _this, context: context };
4220                 var creationState = { bufferTimeSpan: bufferTimeSpan, bufferCreationInterval: bufferCreationInterval, subscriber: _this, scheduler: scheduler };
4221                 _this.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, closeState));
4222                 _this.add(scheduler.schedule(dispatchBufferCreation, bufferCreationInterval, creationState));
4223             }
4224             return _this;
4225         }
4226         BufferTimeSubscriber.prototype._next = function (value) {
4227             var contexts = this.contexts;
4228             var len = contexts.length;
4229             var filledBufferContext;
4230             for (var i = 0; i < len; i++) {
4231                 var context_1 = contexts[i];
4232                 var buffer = context_1.buffer;
4233                 buffer.push(value);
4234                 if (buffer.length == this.maxBufferSize) {
4235                     filledBufferContext = context_1;
4236                 }
4237             }
4238             if (filledBufferContext) {
4239                 this.onBufferFull(filledBufferContext);
4240             }
4241         };
4242         BufferTimeSubscriber.prototype._error = function (err) {
4243             this.contexts.length = 0;
4244             _super.prototype._error.call(this, err);
4245         };
4246         BufferTimeSubscriber.prototype._complete = function () {
4247             var _a = this, contexts = _a.contexts, destination = _a.destination;
4248             while (contexts.length > 0) {
4249                 var context_2 = contexts.shift();
4250                 destination.next(context_2.buffer);
4251             }
4252             _super.prototype._complete.call(this);
4253         };
4254         BufferTimeSubscriber.prototype._unsubscribe = function () {
4255             this.contexts = null;
4256         };
4257         BufferTimeSubscriber.prototype.onBufferFull = function (context) {
4258             this.closeContext(context);
4259             var closeAction = context.closeAction;
4260             closeAction.unsubscribe();
4261             this.remove(closeAction);
4262             if (!this.closed && this.timespanOnly) {
4263                 context = this.openContext();
4264                 var bufferTimeSpan = this.bufferTimeSpan;
4265                 var timeSpanOnlyState = { subscriber: this, context: context, bufferTimeSpan: bufferTimeSpan };
4266                 this.add(context.closeAction = this.scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
4267             }
4268         };
4269         BufferTimeSubscriber.prototype.openContext = function () {
4270             var context = new Context();
4271             this.contexts.push(context);
4272             return context;
4273         };
4274         BufferTimeSubscriber.prototype.closeContext = function (context) {
4275             this.destination.next(context.buffer);
4276             var contexts = this.contexts;
4277             var spliceIndex = contexts ? contexts.indexOf(context) : -1;
4278             if (spliceIndex >= 0) {
4279                 contexts.splice(contexts.indexOf(context), 1);
4280             }
4281         };
4282         return BufferTimeSubscriber;
4283     }(Subscriber));
4284     function dispatchBufferTimeSpanOnly(state) {
4285         var subscriber = state.subscriber;
4286         var prevContext = state.context;
4287         if (prevContext) {
4288             subscriber.closeContext(prevContext);
4289         }
4290         if (!subscriber.closed) {
4291             state.context = subscriber.openContext();
4292             state.context.closeAction = this.schedule(state, state.bufferTimeSpan);
4293         }
4294     }
4295     function dispatchBufferCreation(state) {
4296         var bufferCreationInterval = state.bufferCreationInterval, bufferTimeSpan = state.bufferTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler;
4297         var context = subscriber.openContext();
4298         var action = this;
4299         if (!subscriber.closed) {
4300             subscriber.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, { subscriber: subscriber, context: context }));
4301             action.schedule(state, bufferCreationInterval);
4302         }
4303     }
4304     function dispatchBufferClose(arg) {
4305         var subscriber = arg.subscriber, context = arg.context;
4306         subscriber.closeContext(context);
4307     }
4308
4309     function bufferToggle(openings, closingSelector) {
4310         return function bufferToggleOperatorFunction(source) {
4311             return source.lift(new BufferToggleOperator(openings, closingSelector));
4312         };
4313     }
4314     var BufferToggleOperator = (function () {
4315         function BufferToggleOperator(openings, closingSelector) {
4316             this.openings = openings;
4317             this.closingSelector = closingSelector;
4318         }
4319         BufferToggleOperator.prototype.call = function (subscriber, source) {
4320             return source.subscribe(new BufferToggleSubscriber(subscriber, this.openings, this.closingSelector));
4321         };
4322         return BufferToggleOperator;
4323     }());
4324     var BufferToggleSubscriber = (function (_super) {
4325         __extends(BufferToggleSubscriber, _super);
4326         function BufferToggleSubscriber(destination, openings, closingSelector) {
4327             var _this = _super.call(this, destination) || this;
4328             _this.openings = openings;
4329             _this.closingSelector = closingSelector;
4330             _this.contexts = [];
4331             _this.add(subscribeToResult(_this, openings));
4332             return _this;
4333         }
4334         BufferToggleSubscriber.prototype._next = function (value) {
4335             var contexts = this.contexts;
4336             var len = contexts.length;
4337             for (var i = 0; i < len; i++) {
4338                 contexts[i].buffer.push(value);
4339             }
4340         };
4341         BufferToggleSubscriber.prototype._error = function (err) {
4342             var contexts = this.contexts;
4343             while (contexts.length > 0) {
4344                 var context_1 = contexts.shift();
4345                 context_1.subscription.unsubscribe();
4346                 context_1.buffer = null;
4347                 context_1.subscription = null;
4348             }
4349             this.contexts = null;
4350             _super.prototype._error.call(this, err);
4351         };
4352         BufferToggleSubscriber.prototype._complete = function () {
4353             var contexts = this.contexts;
4354             while (contexts.length > 0) {
4355                 var context_2 = contexts.shift();
4356                 this.destination.next(context_2.buffer);
4357                 context_2.subscription.unsubscribe();
4358                 context_2.buffer = null;
4359                 context_2.subscription = null;
4360             }
4361             this.contexts = null;
4362             _super.prototype._complete.call(this);
4363         };
4364         BufferToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
4365             outerValue ? this.closeBuffer(outerValue) : this.openBuffer(innerValue);
4366         };
4367         BufferToggleSubscriber.prototype.notifyComplete = function (innerSub) {
4368             this.closeBuffer(innerSub.context);
4369         };
4370         BufferToggleSubscriber.prototype.openBuffer = function (value) {
4371             try {
4372                 var closingSelector = this.closingSelector;
4373                 var closingNotifier = closingSelector.call(this, value);
4374                 if (closingNotifier) {
4375                     this.trySubscribe(closingNotifier);
4376                 }
4377             }
4378             catch (err) {
4379                 this._error(err);
4380             }
4381         };
4382         BufferToggleSubscriber.prototype.closeBuffer = function (context) {
4383             var contexts = this.contexts;
4384             if (contexts && context) {
4385                 var buffer = context.buffer, subscription = context.subscription;
4386                 this.destination.next(buffer);
4387                 contexts.splice(contexts.indexOf(context), 1);
4388                 this.remove(subscription);
4389                 subscription.unsubscribe();
4390             }
4391         };
4392         BufferToggleSubscriber.prototype.trySubscribe = function (closingNotifier) {
4393             var contexts = this.contexts;
4394             var buffer = [];
4395             var subscription = new Subscription();
4396             var context = { buffer: buffer, subscription: subscription };
4397             contexts.push(context);
4398             var innerSubscription = subscribeToResult(this, closingNotifier, context);
4399             if (!innerSubscription || innerSubscription.closed) {
4400                 this.closeBuffer(context);
4401             }
4402             else {
4403                 innerSubscription.context = context;
4404                 this.add(innerSubscription);
4405                 subscription.add(innerSubscription);
4406             }
4407         };
4408         return BufferToggleSubscriber;
4409     }(OuterSubscriber));
4410
4411     function bufferWhen(closingSelector) {
4412         return function (source) {
4413             return source.lift(new BufferWhenOperator(closingSelector));
4414         };
4415     }
4416     var BufferWhenOperator = (function () {
4417         function BufferWhenOperator(closingSelector) {
4418             this.closingSelector = closingSelector;
4419         }
4420         BufferWhenOperator.prototype.call = function (subscriber, source) {
4421             return source.subscribe(new BufferWhenSubscriber(subscriber, this.closingSelector));
4422         };
4423         return BufferWhenOperator;
4424     }());
4425     var BufferWhenSubscriber = (function (_super) {
4426         __extends(BufferWhenSubscriber, _super);
4427         function BufferWhenSubscriber(destination, closingSelector) {
4428             var _this = _super.call(this, destination) || this;
4429             _this.closingSelector = closingSelector;
4430             _this.subscribing = false;
4431             _this.openBuffer();
4432             return _this;
4433         }
4434         BufferWhenSubscriber.prototype._next = function (value) {
4435             this.buffer.push(value);
4436         };
4437         BufferWhenSubscriber.prototype._complete = function () {
4438             var buffer = this.buffer;
4439             if (buffer) {
4440                 this.destination.next(buffer);
4441             }
4442             _super.prototype._complete.call(this);
4443         };
4444         BufferWhenSubscriber.prototype._unsubscribe = function () {
4445             this.buffer = null;
4446             this.subscribing = false;
4447         };
4448         BufferWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
4449             this.openBuffer();
4450         };
4451         BufferWhenSubscriber.prototype.notifyComplete = function () {
4452             if (this.subscribing) {
4453                 this.complete();
4454             }
4455             else {
4456                 this.openBuffer();
4457             }
4458         };
4459         BufferWhenSubscriber.prototype.openBuffer = function () {
4460             var closingSubscription = this.closingSubscription;
4461             if (closingSubscription) {
4462                 this.remove(closingSubscription);
4463                 closingSubscription.unsubscribe();
4464             }
4465             var buffer = this.buffer;
4466             if (this.buffer) {
4467                 this.destination.next(buffer);
4468             }
4469             this.buffer = [];
4470             var closingNotifier;
4471             try {
4472                 var closingSelector = this.closingSelector;
4473                 closingNotifier = closingSelector();
4474             }
4475             catch (err) {
4476                 return this.error(err);
4477             }
4478             closingSubscription = new Subscription();
4479             this.closingSubscription = closingSubscription;
4480             this.add(closingSubscription);
4481             this.subscribing = true;
4482             closingSubscription.add(subscribeToResult(this, closingNotifier));
4483             this.subscribing = false;
4484         };
4485         return BufferWhenSubscriber;
4486     }(OuterSubscriber));
4487
4488     function catchError(selector) {
4489         return function catchErrorOperatorFunction(source) {
4490             var operator = new CatchOperator(selector);
4491             var caught = source.lift(operator);
4492             return (operator.caught = caught);
4493         };
4494     }
4495     var CatchOperator = (function () {
4496         function CatchOperator(selector) {
4497             this.selector = selector;
4498         }
4499         CatchOperator.prototype.call = function (subscriber, source) {
4500             return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
4501         };
4502         return CatchOperator;
4503     }());
4504     var CatchSubscriber = (function (_super) {
4505         __extends(CatchSubscriber, _super);
4506         function CatchSubscriber(destination, selector, caught) {
4507             var _this = _super.call(this, destination) || this;
4508             _this.selector = selector;
4509             _this.caught = caught;
4510             return _this;
4511         }
4512         CatchSubscriber.prototype.error = function (err) {
4513             if (!this.isStopped) {
4514                 var result = void 0;
4515                 try {
4516                     result = this.selector(err, this.caught);
4517                 }
4518                 catch (err2) {
4519                     _super.prototype.error.call(this, err2);
4520                     return;
4521                 }
4522                 this._unsubscribeAndRecycle();
4523                 var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
4524                 this.add(innerSubscriber);
4525                 var innerSubscription = subscribeToResult(this, result, undefined, undefined, innerSubscriber);
4526                 if (innerSubscription !== innerSubscriber) {
4527                     this.add(innerSubscription);
4528                 }
4529             }
4530         };
4531         return CatchSubscriber;
4532     }(OuterSubscriber));
4533
4534     function combineAll(project) {
4535         return function (source) { return source.lift(new CombineLatestOperator(project)); };
4536     }
4537
4538     function combineLatest$1() {
4539         var observables = [];
4540         for (var _i = 0; _i < arguments.length; _i++) {
4541             observables[_i] = arguments[_i];
4542         }
4543         var project = null;
4544         if (typeof observables[observables.length - 1] === 'function') {
4545             project = observables.pop();
4546         }
4547         if (observables.length === 1 && isArray(observables[0])) {
4548             observables = observables[0].slice();
4549         }
4550         return function (source) { return source.lift.call(from([source].concat(observables)), new CombineLatestOperator(project)); };
4551     }
4552
4553     function concat$1() {
4554         var observables = [];
4555         for (var _i = 0; _i < arguments.length; _i++) {
4556             observables[_i] = arguments[_i];
4557         }
4558         return function (source) { return source.lift.call(concat.apply(void 0, [source].concat(observables))); };
4559     }
4560
4561     function concatMap(project, resultSelector) {
4562         return mergeMap(project, resultSelector, 1);
4563     }
4564
4565     function concatMapTo(innerObservable, resultSelector) {
4566         return concatMap(function () { return innerObservable; }, resultSelector);
4567     }
4568
4569     function count(predicate) {
4570         return function (source) { return source.lift(new CountOperator(predicate, source)); };
4571     }
4572     var CountOperator = (function () {
4573         function CountOperator(predicate, source) {
4574             this.predicate = predicate;
4575             this.source = source;
4576         }
4577         CountOperator.prototype.call = function (subscriber, source) {
4578             return source.subscribe(new CountSubscriber(subscriber, this.predicate, this.source));
4579         };
4580         return CountOperator;
4581     }());
4582     var CountSubscriber = (function (_super) {
4583         __extends(CountSubscriber, _super);
4584         function CountSubscriber(destination, predicate, source) {
4585             var _this = _super.call(this, destination) || this;
4586             _this.predicate = predicate;
4587             _this.source = source;
4588             _this.count = 0;
4589             _this.index = 0;
4590             return _this;
4591         }
4592         CountSubscriber.prototype._next = function (value) {
4593             if (this.predicate) {
4594                 this._tryPredicate(value);
4595             }
4596             else {
4597                 this.count++;
4598             }
4599         };
4600         CountSubscriber.prototype._tryPredicate = function (value) {
4601             var result;
4602             try {
4603                 result = this.predicate(value, this.index++, this.source);
4604             }
4605             catch (err) {
4606                 this.destination.error(err);
4607                 return;
4608             }
4609             if (result) {
4610                 this.count++;
4611             }
4612         };
4613         CountSubscriber.prototype._complete = function () {
4614             this.destination.next(this.count);
4615             this.destination.complete();
4616         };
4617         return CountSubscriber;
4618     }(Subscriber));
4619
4620     function debounce(durationSelector) {
4621         return function (source) { return source.lift(new DebounceOperator(durationSelector)); };
4622     }
4623     var DebounceOperator = (function () {
4624         function DebounceOperator(durationSelector) {
4625             this.durationSelector = durationSelector;
4626         }
4627         DebounceOperator.prototype.call = function (subscriber, source) {
4628             return source.subscribe(new DebounceSubscriber(subscriber, this.durationSelector));
4629         };
4630         return DebounceOperator;
4631     }());
4632     var DebounceSubscriber = (function (_super) {
4633         __extends(DebounceSubscriber, _super);
4634         function DebounceSubscriber(destination, durationSelector) {
4635             var _this = _super.call(this, destination) || this;
4636             _this.durationSelector = durationSelector;
4637             _this.hasValue = false;
4638             _this.durationSubscription = null;
4639             return _this;
4640         }
4641         DebounceSubscriber.prototype._next = function (value) {
4642             try {
4643                 var result = this.durationSelector.call(this, value);
4644                 if (result) {
4645                     this._tryNext(value, result);
4646                 }
4647             }
4648             catch (err) {
4649                 this.destination.error(err);
4650             }
4651         };
4652         DebounceSubscriber.prototype._complete = function () {
4653             this.emitValue();
4654             this.destination.complete();
4655         };
4656         DebounceSubscriber.prototype._tryNext = function (value, duration) {
4657             var subscription = this.durationSubscription;
4658             this.value = value;
4659             this.hasValue = true;
4660             if (subscription) {
4661                 subscription.unsubscribe();
4662                 this.remove(subscription);
4663             }
4664             subscription = subscribeToResult(this, duration);
4665             if (subscription && !subscription.closed) {
4666                 this.add(this.durationSubscription = subscription);
4667             }
4668         };
4669         DebounceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
4670             this.emitValue();
4671         };
4672         DebounceSubscriber.prototype.notifyComplete = function () {
4673             this.emitValue();
4674         };
4675         DebounceSubscriber.prototype.emitValue = function () {
4676             if (this.hasValue) {
4677                 var value = this.value;
4678                 var subscription = this.durationSubscription;
4679                 if (subscription) {
4680                     this.durationSubscription = null;
4681                     subscription.unsubscribe();
4682                     this.remove(subscription);
4683                 }
4684                 this.value = null;
4685                 this.hasValue = false;
4686                 _super.prototype._next.call(this, value);
4687             }
4688         };
4689         return DebounceSubscriber;
4690     }(OuterSubscriber));
4691
4692     function debounceTime(dueTime, scheduler) {
4693         if (scheduler === void 0) { scheduler = async; }
4694         return function (source) { return source.lift(new DebounceTimeOperator(dueTime, scheduler)); };
4695     }
4696     var DebounceTimeOperator = (function () {
4697         function DebounceTimeOperator(dueTime, scheduler) {
4698             this.dueTime = dueTime;
4699             this.scheduler = scheduler;
4700         }
4701         DebounceTimeOperator.prototype.call = function (subscriber, source) {
4702             return source.subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler));
4703         };
4704         return DebounceTimeOperator;
4705     }());
4706     var DebounceTimeSubscriber = (function (_super) {
4707         __extends(DebounceTimeSubscriber, _super);
4708         function DebounceTimeSubscriber(destination, dueTime, scheduler) {
4709             var _this = _super.call(this, destination) || this;
4710             _this.dueTime = dueTime;
4711             _this.scheduler = scheduler;
4712             _this.debouncedSubscription = null;
4713             _this.lastValue = null;
4714             _this.hasValue = false;
4715             return _this;
4716         }
4717         DebounceTimeSubscriber.prototype._next = function (value) {
4718             this.clearDebounce();
4719             this.lastValue = value;
4720             this.hasValue = true;
4721             this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext$2, this.dueTime, this));
4722         };
4723         DebounceTimeSubscriber.prototype._complete = function () {
4724             this.debouncedNext();
4725             this.destination.complete();
4726         };
4727         DebounceTimeSubscriber.prototype.debouncedNext = function () {
4728             this.clearDebounce();
4729             if (this.hasValue) {
4730                 var lastValue = this.lastValue;
4731                 this.lastValue = null;
4732                 this.hasValue = false;
4733                 this.destination.next(lastValue);
4734             }
4735         };
4736         DebounceTimeSubscriber.prototype.clearDebounce = function () {
4737             var debouncedSubscription = this.debouncedSubscription;
4738             if (debouncedSubscription !== null) {
4739                 this.remove(debouncedSubscription);
4740                 debouncedSubscription.unsubscribe();
4741                 this.debouncedSubscription = null;
4742             }
4743         };
4744         return DebounceTimeSubscriber;
4745     }(Subscriber));
4746     function dispatchNext$2(subscriber) {
4747         subscriber.debouncedNext();
4748     }
4749
4750     function defaultIfEmpty(defaultValue) {
4751         if (defaultValue === void 0) { defaultValue = null; }
4752         return function (source) { return source.lift(new DefaultIfEmptyOperator(defaultValue)); };
4753     }
4754     var DefaultIfEmptyOperator = (function () {
4755         function DefaultIfEmptyOperator(defaultValue) {
4756             this.defaultValue = defaultValue;
4757         }
4758         DefaultIfEmptyOperator.prototype.call = function (subscriber, source) {
4759             return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue));
4760         };
4761         return DefaultIfEmptyOperator;
4762     }());
4763     var DefaultIfEmptySubscriber = (function (_super) {
4764         __extends(DefaultIfEmptySubscriber, _super);
4765         function DefaultIfEmptySubscriber(destination, defaultValue) {
4766             var _this = _super.call(this, destination) || this;
4767             _this.defaultValue = defaultValue;
4768             _this.isEmpty = true;
4769             return _this;
4770         }
4771         DefaultIfEmptySubscriber.prototype._next = function (value) {
4772             this.isEmpty = false;
4773             this.destination.next(value);
4774         };
4775         DefaultIfEmptySubscriber.prototype._complete = function () {
4776             if (this.isEmpty) {
4777                 this.destination.next(this.defaultValue);
4778             }
4779             this.destination.complete();
4780         };
4781         return DefaultIfEmptySubscriber;
4782     }(Subscriber));
4783
4784     function isDate(value) {
4785         return value instanceof Date && !isNaN(+value);
4786     }
4787
4788     function delay(delay, scheduler) {
4789         if (scheduler === void 0) { scheduler = async; }
4790         var absoluteDelay = isDate(delay);
4791         var delayFor = absoluteDelay ? (+delay - scheduler.now()) : Math.abs(delay);
4792         return function (source) { return source.lift(new DelayOperator(delayFor, scheduler)); };
4793     }
4794     var DelayOperator = (function () {
4795         function DelayOperator(delay, scheduler) {
4796             this.delay = delay;
4797             this.scheduler = scheduler;
4798         }
4799         DelayOperator.prototype.call = function (subscriber, source) {
4800             return source.subscribe(new DelaySubscriber(subscriber, this.delay, this.scheduler));
4801         };
4802         return DelayOperator;
4803     }());
4804     var DelaySubscriber = (function (_super) {
4805         __extends(DelaySubscriber, _super);
4806         function DelaySubscriber(destination, delay, scheduler) {
4807             var _this = _super.call(this, destination) || this;
4808             _this.delay = delay;
4809             _this.scheduler = scheduler;
4810             _this.queue = [];
4811             _this.active = false;
4812             _this.errored = false;
4813             return _this;
4814         }
4815         DelaySubscriber.dispatch = function (state) {
4816             var source = state.source;
4817             var queue = source.queue;
4818             var scheduler = state.scheduler;
4819             var destination = state.destination;
4820             while (queue.length > 0 && (queue[0].time - scheduler.now()) <= 0) {
4821                 queue.shift().notification.observe(destination);
4822             }
4823             if (queue.length > 0) {
4824                 var delay_1 = Math.max(0, queue[0].time - scheduler.now());
4825                 this.schedule(state, delay_1);
4826             }
4827             else {
4828                 this.unsubscribe();
4829                 source.active = false;
4830             }
4831         };
4832         DelaySubscriber.prototype._schedule = function (scheduler) {
4833             this.active = true;
4834             var destination = this.destination;
4835             destination.add(scheduler.schedule(DelaySubscriber.dispatch, this.delay, {
4836                 source: this, destination: this.destination, scheduler: scheduler
4837             }));
4838         };
4839         DelaySubscriber.prototype.scheduleNotification = function (notification) {
4840             if (this.errored === true) {
4841                 return;
4842             }
4843             var scheduler = this.scheduler;
4844             var message = new DelayMessage(scheduler.now() + this.delay, notification);
4845             this.queue.push(message);
4846             if (this.active === false) {
4847                 this._schedule(scheduler);
4848             }
4849         };
4850         DelaySubscriber.prototype._next = function (value) {
4851             this.scheduleNotification(Notification.createNext(value));
4852         };
4853         DelaySubscriber.prototype._error = function (err) {
4854             this.errored = true;
4855             this.queue = [];
4856             this.destination.error(err);
4857             this.unsubscribe();
4858         };
4859         DelaySubscriber.prototype._complete = function () {
4860             this.scheduleNotification(Notification.createComplete());
4861             this.unsubscribe();
4862         };
4863         return DelaySubscriber;
4864     }(Subscriber));
4865     var DelayMessage = (function () {
4866         function DelayMessage(time, notification) {
4867             this.time = time;
4868             this.notification = notification;
4869         }
4870         return DelayMessage;
4871     }());
4872
4873     function delayWhen(delayDurationSelector, subscriptionDelay) {
4874         if (subscriptionDelay) {
4875             return function (source) {
4876                 return new SubscriptionDelayObservable(source, subscriptionDelay)
4877                     .lift(new DelayWhenOperator(delayDurationSelector));
4878             };
4879         }
4880         return function (source) { return source.lift(new DelayWhenOperator(delayDurationSelector)); };
4881     }
4882     var DelayWhenOperator = (function () {
4883         function DelayWhenOperator(delayDurationSelector) {
4884             this.delayDurationSelector = delayDurationSelector;
4885         }
4886         DelayWhenOperator.prototype.call = function (subscriber, source) {
4887             return source.subscribe(new DelayWhenSubscriber(subscriber, this.delayDurationSelector));
4888         };
4889         return DelayWhenOperator;
4890     }());
4891     var DelayWhenSubscriber = (function (_super) {
4892         __extends(DelayWhenSubscriber, _super);
4893         function DelayWhenSubscriber(destination, delayDurationSelector) {
4894             var _this = _super.call(this, destination) || this;
4895             _this.delayDurationSelector = delayDurationSelector;
4896             _this.completed = false;
4897             _this.delayNotifierSubscriptions = [];
4898             _this.index = 0;
4899             return _this;
4900         }
4901         DelayWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
4902             this.destination.next(outerValue);
4903             this.removeSubscription(innerSub);
4904             this.tryComplete();
4905         };
4906         DelayWhenSubscriber.prototype.notifyError = function (error, innerSub) {
4907             this._error(error);
4908         };
4909         DelayWhenSubscriber.prototype.notifyComplete = function (innerSub) {
4910             var value = this.removeSubscription(innerSub);
4911             if (value) {
4912                 this.destination.next(value);
4913             }
4914             this.tryComplete();
4915         };
4916         DelayWhenSubscriber.prototype._next = function (value) {
4917             var index = this.index++;
4918             try {
4919                 var delayNotifier = this.delayDurationSelector(value, index);
4920                 if (delayNotifier) {
4921                     this.tryDelay(delayNotifier, value);
4922                 }
4923             }
4924             catch (err) {
4925                 this.destination.error(err);
4926             }
4927         };
4928         DelayWhenSubscriber.prototype._complete = function () {
4929             this.completed = true;
4930             this.tryComplete();
4931             this.unsubscribe();
4932         };
4933         DelayWhenSubscriber.prototype.removeSubscription = function (subscription) {
4934             subscription.unsubscribe();
4935             var subscriptionIdx = this.delayNotifierSubscriptions.indexOf(subscription);
4936             if (subscriptionIdx !== -1) {
4937                 this.delayNotifierSubscriptions.splice(subscriptionIdx, 1);
4938             }
4939             return subscription.outerValue;
4940         };
4941         DelayWhenSubscriber.prototype.tryDelay = function (delayNotifier, value) {
4942             var notifierSubscription = subscribeToResult(this, delayNotifier, value);
4943             if (notifierSubscription && !notifierSubscription.closed) {
4944                 var destination = this.destination;
4945                 destination.add(notifierSubscription);
4946                 this.delayNotifierSubscriptions.push(notifierSubscription);
4947             }
4948         };
4949         DelayWhenSubscriber.prototype.tryComplete = function () {
4950             if (this.completed && this.delayNotifierSubscriptions.length === 0) {
4951                 this.destination.complete();
4952             }
4953         };
4954         return DelayWhenSubscriber;
4955     }(OuterSubscriber));
4956     var SubscriptionDelayObservable = (function (_super) {
4957         __extends(SubscriptionDelayObservable, _super);
4958         function SubscriptionDelayObservable(source, subscriptionDelay) {
4959             var _this = _super.call(this) || this;
4960             _this.source = source;
4961             _this.subscriptionDelay = subscriptionDelay;
4962             return _this;
4963         }
4964         SubscriptionDelayObservable.prototype._subscribe = function (subscriber) {
4965             this.subscriptionDelay.subscribe(new SubscriptionDelaySubscriber(subscriber, this.source));
4966         };
4967         return SubscriptionDelayObservable;
4968     }(Observable));
4969     var SubscriptionDelaySubscriber = (function (_super) {
4970         __extends(SubscriptionDelaySubscriber, _super);
4971         function SubscriptionDelaySubscriber(parent, source) {
4972             var _this = _super.call(this) || this;
4973             _this.parent = parent;
4974             _this.source = source;
4975             _this.sourceSubscribed = false;
4976             return _this;
4977         }
4978         SubscriptionDelaySubscriber.prototype._next = function (unused) {
4979             this.subscribeToSource();
4980         };
4981         SubscriptionDelaySubscriber.prototype._error = function (err) {
4982             this.unsubscribe();
4983             this.parent.error(err);
4984         };
4985         SubscriptionDelaySubscriber.prototype._complete = function () {
4986             this.unsubscribe();
4987             this.subscribeToSource();
4988         };
4989         SubscriptionDelaySubscriber.prototype.subscribeToSource = function () {
4990             if (!this.sourceSubscribed) {
4991                 this.sourceSubscribed = true;
4992                 this.unsubscribe();
4993                 this.source.subscribe(this.parent);
4994             }
4995         };
4996         return SubscriptionDelaySubscriber;
4997     }(Subscriber));
4998
4999     function dematerialize() {
5000         return function dematerializeOperatorFunction(source) {
5001             return source.lift(new DeMaterializeOperator());
5002         };
5003     }
5004     var DeMaterializeOperator = (function () {
5005         function DeMaterializeOperator() {
5006         }
5007         DeMaterializeOperator.prototype.call = function (subscriber, source) {
5008             return source.subscribe(new DeMaterializeSubscriber(subscriber));
5009         };
5010         return DeMaterializeOperator;
5011     }());
5012     var DeMaterializeSubscriber = (function (_super) {
5013         __extends(DeMaterializeSubscriber, _super);
5014         function DeMaterializeSubscriber(destination) {
5015             return _super.call(this, destination) || this;
5016         }
5017         DeMaterializeSubscriber.prototype._next = function (value) {
5018             value.observe(this.destination);
5019         };
5020         return DeMaterializeSubscriber;
5021     }(Subscriber));
5022
5023     function distinct(keySelector, flushes) {
5024         return function (source) { return source.lift(new DistinctOperator(keySelector, flushes)); };
5025     }
5026     var DistinctOperator = (function () {
5027         function DistinctOperator(keySelector, flushes) {
5028             this.keySelector = keySelector;
5029             this.flushes = flushes;
5030         }
5031         DistinctOperator.prototype.call = function (subscriber, source) {
5032             return source.subscribe(new DistinctSubscriber(subscriber, this.keySelector, this.flushes));
5033         };
5034         return DistinctOperator;
5035     }());
5036     var DistinctSubscriber = (function (_super) {
5037         __extends(DistinctSubscriber, _super);
5038         function DistinctSubscriber(destination, keySelector, flushes) {
5039             var _this = _super.call(this, destination) || this;
5040             _this.keySelector = keySelector;
5041             _this.values = new Set();
5042             if (flushes) {
5043                 _this.add(subscribeToResult(_this, flushes));
5044             }
5045             return _this;
5046         }
5047         DistinctSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
5048             this.values.clear();
5049         };
5050         DistinctSubscriber.prototype.notifyError = function (error, innerSub) {
5051             this._error(error);
5052         };
5053         DistinctSubscriber.prototype._next = function (value) {
5054             if (this.keySelector) {
5055                 this._useKeySelector(value);
5056             }
5057             else {
5058                 this._finalizeNext(value, value);
5059             }
5060         };
5061         DistinctSubscriber.prototype._useKeySelector = function (value) {
5062             var key;
5063             var destination = this.destination;
5064             try {
5065                 key = this.keySelector(value);
5066             }
5067             catch (err) {
5068                 destination.error(err);
5069                 return;
5070             }
5071             this._finalizeNext(key, value);
5072         };
5073         DistinctSubscriber.prototype._finalizeNext = function (key, value) {
5074             var values = this.values;
5075             if (!values.has(key)) {
5076                 values.add(key);
5077                 this.destination.next(value);
5078             }
5079         };
5080         return DistinctSubscriber;
5081     }(OuterSubscriber));
5082
5083     function distinctUntilChanged(compare, keySelector) {
5084         return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); };
5085     }
5086     var DistinctUntilChangedOperator = (function () {
5087         function DistinctUntilChangedOperator(compare, keySelector) {
5088             this.compare = compare;
5089             this.keySelector = keySelector;
5090         }
5091         DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {
5092             return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));
5093         };
5094         return DistinctUntilChangedOperator;
5095     }());
5096     var DistinctUntilChangedSubscriber = (function (_super) {
5097         __extends(DistinctUntilChangedSubscriber, _super);
5098         function DistinctUntilChangedSubscriber(destination, compare, keySelector) {
5099             var _this = _super.call(this, destination) || this;
5100             _this.keySelector = keySelector;
5101             _this.hasKey = false;
5102             if (typeof compare === 'function') {
5103                 _this.compare = compare;
5104             }
5105             return _this;
5106         }
5107         DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {
5108             return x === y;
5109         };
5110         DistinctUntilChangedSubscriber.prototype._next = function (value) {
5111             var key;
5112             try {
5113                 var keySelector = this.keySelector;
5114                 key = keySelector ? keySelector(value) : value;
5115             }
5116             catch (err) {
5117                 return this.destination.error(err);
5118             }
5119             var result = false;
5120             if (this.hasKey) {
5121                 try {
5122                     var compare = this.compare;
5123                     result = compare(this.key, key);
5124                 }
5125                 catch (err) {
5126                     return this.destination.error(err);
5127                 }
5128             }
5129             else {
5130                 this.hasKey = true;
5131             }
5132             if (!result) {
5133                 this.key = key;
5134                 this.destination.next(value);
5135             }
5136         };
5137         return DistinctUntilChangedSubscriber;
5138     }(Subscriber));
5139
5140     function distinctUntilKeyChanged(key, compare) {
5141         return distinctUntilChanged(function (x, y) { return compare ? compare(x[key], y[key]) : x[key] === y[key]; });
5142     }
5143
5144     function throwIfEmpty(errorFactory) {
5145         if (errorFactory === void 0) { errorFactory = defaultErrorFactory; }
5146         return function (source) {
5147             return source.lift(new ThrowIfEmptyOperator(errorFactory));
5148         };
5149     }
5150     var ThrowIfEmptyOperator = (function () {
5151         function ThrowIfEmptyOperator(errorFactory) {
5152             this.errorFactory = errorFactory;
5153         }
5154         ThrowIfEmptyOperator.prototype.call = function (subscriber, source) {
5155             return source.subscribe(new ThrowIfEmptySubscriber(subscriber, this.errorFactory));
5156         };
5157         return ThrowIfEmptyOperator;
5158     }());
5159     var ThrowIfEmptySubscriber = (function (_super) {
5160         __extends(ThrowIfEmptySubscriber, _super);
5161         function ThrowIfEmptySubscriber(destination, errorFactory) {
5162             var _this = _super.call(this, destination) || this;
5163             _this.errorFactory = errorFactory;
5164             _this.hasValue = false;
5165             return _this;
5166         }
5167         ThrowIfEmptySubscriber.prototype._next = function (value) {
5168             this.hasValue = true;
5169             this.destination.next(value);
5170         };
5171         ThrowIfEmptySubscriber.prototype._complete = function () {
5172             if (!this.hasValue) {
5173                 var err = void 0;
5174                 try {
5175                     err = this.errorFactory();
5176                 }
5177                 catch (e) {
5178                     err = e;
5179                 }
5180                 this.destination.error(err);
5181             }
5182             else {
5183                 return this.destination.complete();
5184             }
5185         };
5186         return ThrowIfEmptySubscriber;
5187     }(Subscriber));
5188     function defaultErrorFactory() {
5189         return new EmptyError();
5190     }
5191
5192     function take(count) {
5193         return function (source) {
5194             if (count === 0) {
5195                 return empty$1();
5196             }
5197             else {
5198                 return source.lift(new TakeOperator(count));
5199             }
5200         };
5201     }
5202     var TakeOperator = (function () {
5203         function TakeOperator(total) {
5204             this.total = total;
5205             if (this.total < 0) {
5206                 throw new ArgumentOutOfRangeError;
5207             }
5208         }
5209         TakeOperator.prototype.call = function (subscriber, source) {
5210             return source.subscribe(new TakeSubscriber(subscriber, this.total));
5211         };
5212         return TakeOperator;
5213     }());
5214     var TakeSubscriber = (function (_super) {
5215         __extends(TakeSubscriber, _super);
5216         function TakeSubscriber(destination, total) {
5217             var _this = _super.call(this, destination) || this;
5218             _this.total = total;
5219             _this.count = 0;
5220             return _this;
5221         }
5222         TakeSubscriber.prototype._next = function (value) {
5223             var total = this.total;
5224             var count = ++this.count;
5225             if (count <= total) {
5226                 this.destination.next(value);
5227                 if (count === total) {
5228                     this.destination.complete();
5229                     this.unsubscribe();
5230                 }
5231             }
5232         };
5233         return TakeSubscriber;
5234     }(Subscriber));
5235
5236     function elementAt(index, defaultValue) {
5237         if (index < 0) {
5238             throw new ArgumentOutOfRangeError();
5239         }
5240         var hasDefaultValue = arguments.length >= 2;
5241         return function (source) { return source.pipe(filter(function (v, i) { return i === index; }), take(1), hasDefaultValue
5242             ? defaultIfEmpty(defaultValue)
5243             : throwIfEmpty(function () { return new ArgumentOutOfRangeError(); })); };
5244     }
5245
5246     function endWith() {
5247         var array = [];
5248         for (var _i = 0; _i < arguments.length; _i++) {
5249             array[_i] = arguments[_i];
5250         }
5251         return function (source) { return concat(source, of.apply(void 0, array)); };
5252     }
5253
5254     function every(predicate, thisArg) {
5255         return function (source) { return source.lift(new EveryOperator(predicate, thisArg, source)); };
5256     }
5257     var EveryOperator = (function () {
5258         function EveryOperator(predicate, thisArg, source) {
5259             this.predicate = predicate;
5260             this.thisArg = thisArg;
5261             this.source = source;
5262         }
5263         EveryOperator.prototype.call = function (observer, source) {
5264             return source.subscribe(new EverySubscriber(observer, this.predicate, this.thisArg, this.source));
5265         };
5266         return EveryOperator;
5267     }());
5268     var EverySubscriber = (function (_super) {
5269         __extends(EverySubscriber, _super);
5270         function EverySubscriber(destination, predicate, thisArg, source) {
5271             var _this = _super.call(this, destination) || this;
5272             _this.predicate = predicate;
5273             _this.thisArg = thisArg;
5274             _this.source = source;
5275             _this.index = 0;
5276             _this.thisArg = thisArg || _this;
5277             return _this;
5278         }
5279         EverySubscriber.prototype.notifyComplete = function (everyValueMatch) {
5280             this.destination.next(everyValueMatch);
5281             this.destination.complete();
5282         };
5283         EverySubscriber.prototype._next = function (value) {
5284             var result = false;
5285             try {
5286                 result = this.predicate.call(this.thisArg, value, this.index++, this.source);
5287             }
5288             catch (err) {
5289                 this.destination.error(err);
5290                 return;
5291             }
5292             if (!result) {
5293                 this.notifyComplete(false);
5294             }
5295         };
5296         EverySubscriber.prototype._complete = function () {
5297             this.notifyComplete(true);
5298         };
5299         return EverySubscriber;
5300     }(Subscriber));
5301
5302     function exhaust() {
5303         return function (source) { return source.lift(new SwitchFirstOperator()); };
5304     }
5305     var SwitchFirstOperator = (function () {
5306         function SwitchFirstOperator() {
5307         }
5308         SwitchFirstOperator.prototype.call = function (subscriber, source) {
5309             return source.subscribe(new SwitchFirstSubscriber(subscriber));
5310         };
5311         return SwitchFirstOperator;
5312     }());
5313     var SwitchFirstSubscriber = (function (_super) {
5314         __extends(SwitchFirstSubscriber, _super);
5315         function SwitchFirstSubscriber(destination) {
5316             var _this = _super.call(this, destination) || this;
5317             _this.hasCompleted = false;
5318             _this.hasSubscription = false;
5319             return _this;
5320         }
5321         SwitchFirstSubscriber.prototype._next = function (value) {
5322             if (!this.hasSubscription) {
5323                 this.hasSubscription = true;
5324                 this.add(subscribeToResult(this, value));
5325             }
5326         };
5327         SwitchFirstSubscriber.prototype._complete = function () {
5328             this.hasCompleted = true;
5329             if (!this.hasSubscription) {
5330                 this.destination.complete();
5331             }
5332         };
5333         SwitchFirstSubscriber.prototype.notifyComplete = function (innerSub) {
5334             this.remove(innerSub);
5335             this.hasSubscription = false;
5336             if (this.hasCompleted) {
5337                 this.destination.complete();
5338             }
5339         };
5340         return SwitchFirstSubscriber;
5341     }(OuterSubscriber));
5342
5343     function exhaustMap(project, resultSelector) {
5344         if (resultSelector) {
5345             return function (source) { return source.pipe(exhaustMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
5346         }
5347         return function (source) {
5348             return source.lift(new ExhaustMapOperator(project));
5349         };
5350     }
5351     var ExhaustMapOperator = (function () {
5352         function ExhaustMapOperator(project) {
5353             this.project = project;
5354         }
5355         ExhaustMapOperator.prototype.call = function (subscriber, source) {
5356             return source.subscribe(new ExhaustMapSubscriber(subscriber, this.project));
5357         };
5358         return ExhaustMapOperator;
5359     }());
5360     var ExhaustMapSubscriber = (function (_super) {
5361         __extends(ExhaustMapSubscriber, _super);
5362         function ExhaustMapSubscriber(destination, project) {
5363             var _this = _super.call(this, destination) || this;
5364             _this.project = project;
5365             _this.hasSubscription = false;
5366             _this.hasCompleted = false;
5367             _this.index = 0;
5368             return _this;
5369         }
5370         ExhaustMapSubscriber.prototype._next = function (value) {
5371             if (!this.hasSubscription) {
5372                 this.tryNext(value);
5373             }
5374         };
5375         ExhaustMapSubscriber.prototype.tryNext = function (value) {
5376             var result;
5377             var index = this.index++;
5378             try {
5379                 result = this.project(value, index);
5380             }
5381             catch (err) {
5382                 this.destination.error(err);
5383                 return;
5384             }
5385             this.hasSubscription = true;
5386             this._innerSub(result, value, index);
5387         };
5388         ExhaustMapSubscriber.prototype._innerSub = function (result, value, index) {
5389             var innerSubscriber = new InnerSubscriber(this, value, index);
5390             var destination = this.destination;
5391             destination.add(innerSubscriber);
5392             var innerSubscription = subscribeToResult(this, result, undefined, undefined, innerSubscriber);
5393             if (innerSubscription !== innerSubscriber) {
5394                 destination.add(innerSubscription);
5395             }
5396         };
5397         ExhaustMapSubscriber.prototype._complete = function () {
5398             this.hasCompleted = true;
5399             if (!this.hasSubscription) {
5400                 this.destination.complete();
5401             }
5402             this.unsubscribe();
5403         };
5404         ExhaustMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
5405             this.destination.next(innerValue);
5406         };
5407         ExhaustMapSubscriber.prototype.notifyError = function (err) {
5408             this.destination.error(err);
5409         };
5410         ExhaustMapSubscriber.prototype.notifyComplete = function (innerSub) {
5411             var destination = this.destination;
5412             destination.remove(innerSub);
5413             this.hasSubscription = false;
5414             if (this.hasCompleted) {
5415                 this.destination.complete();
5416             }
5417         };
5418         return ExhaustMapSubscriber;
5419     }(OuterSubscriber));
5420
5421     function expand(project, concurrent, scheduler) {
5422         if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
5423         if (scheduler === void 0) { scheduler = undefined; }
5424         concurrent = (concurrent || 0) < 1 ? Number.POSITIVE_INFINITY : concurrent;
5425         return function (source) { return source.lift(new ExpandOperator(project, concurrent, scheduler)); };
5426     }
5427     var ExpandOperator = (function () {
5428         function ExpandOperator(project, concurrent, scheduler) {
5429             this.project = project;
5430             this.concurrent = concurrent;
5431             this.scheduler = scheduler;
5432         }
5433         ExpandOperator.prototype.call = function (subscriber, source) {
5434             return source.subscribe(new ExpandSubscriber(subscriber, this.project, this.concurrent, this.scheduler));
5435         };
5436         return ExpandOperator;
5437     }());
5438     var ExpandSubscriber = (function (_super) {
5439         __extends(ExpandSubscriber, _super);
5440         function ExpandSubscriber(destination, project, concurrent, scheduler) {
5441             var _this = _super.call(this, destination) || this;
5442             _this.project = project;
5443             _this.concurrent = concurrent;
5444             _this.scheduler = scheduler;
5445             _this.index = 0;
5446             _this.active = 0;
5447             _this.hasCompleted = false;
5448             if (concurrent < Number.POSITIVE_INFINITY) {
5449                 _this.buffer = [];
5450             }
5451             return _this;
5452         }
5453         ExpandSubscriber.dispatch = function (arg) {
5454             var subscriber = arg.subscriber, result = arg.result, value = arg.value, index = arg.index;
5455             subscriber.subscribeToProjection(result, value, index);
5456         };
5457         ExpandSubscriber.prototype._next = function (value) {
5458             var destination = this.destination;
5459             if (destination.closed) {
5460                 this._complete();
5461                 return;
5462             }
5463             var index = this.index++;
5464             if (this.active < this.concurrent) {
5465                 destination.next(value);
5466                 try {
5467                     var project = this.project;
5468                     var result = project(value, index);
5469                     if (!this.scheduler) {
5470                         this.subscribeToProjection(result, value, index);
5471                     }
5472                     else {
5473                         var state = { subscriber: this, result: result, value: value, index: index };
5474                         var destination_1 = this.destination;
5475                         destination_1.add(this.scheduler.schedule(ExpandSubscriber.dispatch, 0, state));
5476                     }
5477                 }
5478                 catch (e) {
5479                     destination.error(e);
5480                 }
5481             }
5482             else {
5483                 this.buffer.push(value);
5484             }
5485         };
5486         ExpandSubscriber.prototype.subscribeToProjection = function (result, value, index) {
5487             this.active++;
5488             var destination = this.destination;
5489             destination.add(subscribeToResult(this, result, value, index));
5490         };
5491         ExpandSubscriber.prototype._complete = function () {
5492             this.hasCompleted = true;
5493             if (this.hasCompleted && this.active === 0) {
5494                 this.destination.complete();
5495             }
5496             this.unsubscribe();
5497         };
5498         ExpandSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
5499             this._next(innerValue);
5500         };
5501         ExpandSubscriber.prototype.notifyComplete = function (innerSub) {
5502             var buffer = this.buffer;
5503             var destination = this.destination;
5504             destination.remove(innerSub);
5505             this.active--;
5506             if (buffer && buffer.length > 0) {
5507                 this._next(buffer.shift());
5508             }
5509             if (this.hasCompleted && this.active === 0) {
5510                 this.destination.complete();
5511             }
5512         };
5513         return ExpandSubscriber;
5514     }(OuterSubscriber));
5515
5516     function finalize(callback) {
5517         return function (source) { return source.lift(new FinallyOperator(callback)); };
5518     }
5519     var FinallyOperator = (function () {
5520         function FinallyOperator(callback) {
5521             this.callback = callback;
5522         }
5523         FinallyOperator.prototype.call = function (subscriber, source) {
5524             return source.subscribe(new FinallySubscriber(subscriber, this.callback));
5525         };
5526         return FinallyOperator;
5527     }());
5528     var FinallySubscriber = (function (_super) {
5529         __extends(FinallySubscriber, _super);
5530         function FinallySubscriber(destination, callback) {
5531             var _this = _super.call(this, destination) || this;
5532             _this.add(new Subscription(callback));
5533             return _this;
5534         }
5535         return FinallySubscriber;
5536     }(Subscriber));
5537
5538     function find(predicate, thisArg) {
5539         if (typeof predicate !== 'function') {
5540             throw new TypeError('predicate is not a function');
5541         }
5542         return function (source) { return source.lift(new FindValueOperator(predicate, source, false, thisArg)); };
5543     }
5544     var FindValueOperator = (function () {
5545         function FindValueOperator(predicate, source, yieldIndex, thisArg) {
5546             this.predicate = predicate;
5547             this.source = source;
5548             this.yieldIndex = yieldIndex;
5549             this.thisArg = thisArg;
5550         }
5551         FindValueOperator.prototype.call = function (observer, source) {
5552             return source.subscribe(new FindValueSubscriber(observer, this.predicate, this.source, this.yieldIndex, this.thisArg));
5553         };
5554         return FindValueOperator;
5555     }());
5556     var FindValueSubscriber = (function (_super) {
5557         __extends(FindValueSubscriber, _super);
5558         function FindValueSubscriber(destination, predicate, source, yieldIndex, thisArg) {
5559             var _this = _super.call(this, destination) || this;
5560             _this.predicate = predicate;
5561             _this.source = source;
5562             _this.yieldIndex = yieldIndex;
5563             _this.thisArg = thisArg;
5564             _this.index = 0;
5565             return _this;
5566         }
5567         FindValueSubscriber.prototype.notifyComplete = function (value) {
5568             var destination = this.destination;
5569             destination.next(value);
5570             destination.complete();
5571             this.unsubscribe();
5572         };
5573         FindValueSubscriber.prototype._next = function (value) {
5574             var _a = this, predicate = _a.predicate, thisArg = _a.thisArg;
5575             var index = this.index++;
5576             try {
5577                 var result = predicate.call(thisArg || this, value, index, this.source);
5578                 if (result) {
5579                     this.notifyComplete(this.yieldIndex ? index : value);
5580                 }
5581             }
5582             catch (err) {
5583                 this.destination.error(err);
5584             }
5585         };
5586         FindValueSubscriber.prototype._complete = function () {
5587             this.notifyComplete(this.yieldIndex ? -1 : undefined);
5588         };
5589         return FindValueSubscriber;
5590     }(Subscriber));
5591
5592     function findIndex(predicate, thisArg) {
5593         return function (source) { return source.lift(new FindValueOperator(predicate, source, true, thisArg)); };
5594     }
5595
5596     function first(predicate, defaultValue) {
5597         var hasDefaultValue = arguments.length >= 2;
5598         return function (source) { return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity, take(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); };
5599     }
5600
5601     function ignoreElements() {
5602         return function ignoreElementsOperatorFunction(source) {
5603             return source.lift(new IgnoreElementsOperator());
5604         };
5605     }
5606     var IgnoreElementsOperator = (function () {
5607         function IgnoreElementsOperator() {
5608         }
5609         IgnoreElementsOperator.prototype.call = function (subscriber, source) {
5610             return source.subscribe(new IgnoreElementsSubscriber(subscriber));
5611         };
5612         return IgnoreElementsOperator;
5613     }());
5614     var IgnoreElementsSubscriber = (function (_super) {
5615         __extends(IgnoreElementsSubscriber, _super);
5616         function IgnoreElementsSubscriber() {
5617             return _super !== null && _super.apply(this, arguments) || this;
5618         }
5619         IgnoreElementsSubscriber.prototype._next = function (unused) {
5620         };
5621         return IgnoreElementsSubscriber;
5622     }(Subscriber));
5623
5624     function isEmpty() {
5625         return function (source) { return source.lift(new IsEmptyOperator()); };
5626     }
5627     var IsEmptyOperator = (function () {
5628         function IsEmptyOperator() {
5629         }
5630         IsEmptyOperator.prototype.call = function (observer, source) {
5631             return source.subscribe(new IsEmptySubscriber(observer));
5632         };
5633         return IsEmptyOperator;
5634     }());
5635     var IsEmptySubscriber = (function (_super) {
5636         __extends(IsEmptySubscriber, _super);
5637         function IsEmptySubscriber(destination) {
5638             return _super.call(this, destination) || this;
5639         }
5640         IsEmptySubscriber.prototype.notifyComplete = function (isEmpty) {
5641             var destination = this.destination;
5642             destination.next(isEmpty);
5643             destination.complete();
5644         };
5645         IsEmptySubscriber.prototype._next = function (value) {
5646             this.notifyComplete(false);
5647         };
5648         IsEmptySubscriber.prototype._complete = function () {
5649             this.notifyComplete(true);
5650         };
5651         return IsEmptySubscriber;
5652     }(Subscriber));
5653
5654     function takeLast(count) {
5655         return function takeLastOperatorFunction(source) {
5656             if (count === 0) {
5657                 return empty$1();
5658             }
5659             else {
5660                 return source.lift(new TakeLastOperator(count));
5661             }
5662         };
5663     }
5664     var TakeLastOperator = (function () {
5665         function TakeLastOperator(total) {
5666             this.total = total;
5667             if (this.total < 0) {
5668                 throw new ArgumentOutOfRangeError;
5669             }
5670         }
5671         TakeLastOperator.prototype.call = function (subscriber, source) {
5672             return source.subscribe(new TakeLastSubscriber(subscriber, this.total));
5673         };
5674         return TakeLastOperator;
5675     }());
5676     var TakeLastSubscriber = (function (_super) {
5677         __extends(TakeLastSubscriber, _super);
5678         function TakeLastSubscriber(destination, total) {
5679             var _this = _super.call(this, destination) || this;
5680             _this.total = total;
5681             _this.ring = new Array();
5682             _this.count = 0;
5683             return _this;
5684         }
5685         TakeLastSubscriber.prototype._next = function (value) {
5686             var ring = this.ring;
5687             var total = this.total;
5688             var count = this.count++;
5689             if (ring.length < total) {
5690                 ring.push(value);
5691             }
5692             else {
5693                 var index = count % total;
5694                 ring[index] = value;
5695             }
5696         };
5697         TakeLastSubscriber.prototype._complete = function () {
5698             var destination = this.destination;
5699             var count = this.count;
5700             if (count > 0) {
5701                 var total = this.count >= this.total ? this.total : this.count;
5702                 var ring = this.ring;
5703                 for (var i = 0; i < total; i++) {
5704                     var idx = (count++) % total;
5705                     destination.next(ring[idx]);
5706                 }
5707             }
5708             destination.complete();
5709         };
5710         return TakeLastSubscriber;
5711     }(Subscriber));
5712
5713     function last(predicate, defaultValue) {
5714         var hasDefaultValue = arguments.length >= 2;
5715         return function (source) { return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity, takeLast(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); };
5716     }
5717
5718     function mapTo(value) {
5719         return function (source) { return source.lift(new MapToOperator(value)); };
5720     }
5721     var MapToOperator = (function () {
5722         function MapToOperator(value) {
5723             this.value = value;
5724         }
5725         MapToOperator.prototype.call = function (subscriber, source) {
5726             return source.subscribe(new MapToSubscriber(subscriber, this.value));
5727         };
5728         return MapToOperator;
5729     }());
5730     var MapToSubscriber = (function (_super) {
5731         __extends(MapToSubscriber, _super);
5732         function MapToSubscriber(destination, value) {
5733             var _this = _super.call(this, destination) || this;
5734             _this.value = value;
5735             return _this;
5736         }
5737         MapToSubscriber.prototype._next = function (x) {
5738             this.destination.next(this.value);
5739         };
5740         return MapToSubscriber;
5741     }(Subscriber));
5742
5743     function materialize() {
5744         return function materializeOperatorFunction(source) {
5745             return source.lift(new MaterializeOperator());
5746         };
5747     }
5748     var MaterializeOperator = (function () {
5749         function MaterializeOperator() {
5750         }
5751         MaterializeOperator.prototype.call = function (subscriber, source) {
5752             return source.subscribe(new MaterializeSubscriber(subscriber));
5753         };
5754         return MaterializeOperator;
5755     }());
5756     var MaterializeSubscriber = (function (_super) {
5757         __extends(MaterializeSubscriber, _super);
5758         function MaterializeSubscriber(destination) {
5759             return _super.call(this, destination) || this;
5760         }
5761         MaterializeSubscriber.prototype._next = function (value) {
5762             this.destination.next(Notification.createNext(value));
5763         };
5764         MaterializeSubscriber.prototype._error = function (err) {
5765             var destination = this.destination;
5766             destination.next(Notification.createError(err));
5767             destination.complete();
5768         };
5769         MaterializeSubscriber.prototype._complete = function () {
5770             var destination = this.destination;
5771             destination.next(Notification.createComplete());
5772             destination.complete();
5773         };
5774         return MaterializeSubscriber;
5775     }(Subscriber));
5776
5777     function scan(accumulator, seed) {
5778         var hasSeed = false;
5779         if (arguments.length >= 2) {
5780             hasSeed = true;
5781         }
5782         return function scanOperatorFunction(source) {
5783             return source.lift(new ScanOperator(accumulator, seed, hasSeed));
5784         };
5785     }
5786     var ScanOperator = (function () {
5787         function ScanOperator(accumulator, seed, hasSeed) {
5788             if (hasSeed === void 0) { hasSeed = false; }
5789             this.accumulator = accumulator;
5790             this.seed = seed;
5791             this.hasSeed = hasSeed;
5792         }
5793         ScanOperator.prototype.call = function (subscriber, source) {
5794             return source.subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed));
5795         };
5796         return ScanOperator;
5797     }());
5798     var ScanSubscriber = (function (_super) {
5799         __extends(ScanSubscriber, _super);
5800         function ScanSubscriber(destination, accumulator, _seed, hasSeed) {
5801             var _this = _super.call(this, destination) || this;
5802             _this.accumulator = accumulator;
5803             _this._seed = _seed;
5804             _this.hasSeed = hasSeed;
5805             _this.index = 0;
5806             return _this;
5807         }
5808         Object.defineProperty(ScanSubscriber.prototype, "seed", {
5809             get: function () {
5810                 return this._seed;
5811             },
5812             set: function (value) {
5813                 this.hasSeed = true;
5814                 this._seed = value;
5815             },
5816             enumerable: true,
5817             configurable: true
5818         });
5819         ScanSubscriber.prototype._next = function (value) {
5820             if (!this.hasSeed) {
5821                 this.seed = value;
5822                 this.destination.next(value);
5823             }
5824             else {
5825                 return this._tryNext(value);
5826             }
5827         };
5828         ScanSubscriber.prototype._tryNext = function (value) {
5829             var index = this.index++;
5830             var result;
5831             try {
5832                 result = this.accumulator(this.seed, value, index);
5833             }
5834             catch (err) {
5835                 this.destination.error(err);
5836             }
5837             this.seed = result;
5838             this.destination.next(result);
5839         };
5840         return ScanSubscriber;
5841     }(Subscriber));
5842
5843     function reduce(accumulator, seed) {
5844         if (arguments.length >= 2) {
5845             return function reduceOperatorFunctionWithSeed(source) {
5846                 return pipe(scan(accumulator, seed), takeLast(1), defaultIfEmpty(seed))(source);
5847             };
5848         }
5849         return function reduceOperatorFunction(source) {
5850             return pipe(scan(function (acc, value, index) { return accumulator(acc, value, index + 1); }), takeLast(1))(source);
5851         };
5852     }
5853
5854     function max(comparer) {
5855         var max = (typeof comparer === 'function')
5856             ? function (x, y) { return comparer(x, y) > 0 ? x : y; }
5857             : function (x, y) { return x > y ? x : y; };
5858         return reduce(max);
5859     }
5860
5861     function merge$1() {
5862         var observables = [];
5863         for (var _i = 0; _i < arguments.length; _i++) {
5864             observables[_i] = arguments[_i];
5865         }
5866         return function (source) { return source.lift.call(merge.apply(void 0, [source].concat(observables))); };
5867     }
5868
5869     function mergeMapTo(innerObservable, resultSelector, concurrent) {
5870         if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
5871         if (typeof resultSelector === 'function') {
5872             return mergeMap(function () { return innerObservable; }, resultSelector, concurrent);
5873         }
5874         if (typeof resultSelector === 'number') {
5875             concurrent = resultSelector;
5876         }
5877         return mergeMap(function () { return innerObservable; }, concurrent);
5878     }
5879
5880     function mergeScan(accumulator, seed, concurrent) {
5881         if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
5882         return function (source) { return source.lift(new MergeScanOperator(accumulator, seed, concurrent)); };
5883     }
5884     var MergeScanOperator = (function () {
5885         function MergeScanOperator(accumulator, seed, concurrent) {
5886             this.accumulator = accumulator;
5887             this.seed = seed;
5888             this.concurrent = concurrent;
5889         }
5890         MergeScanOperator.prototype.call = function (subscriber, source) {
5891             return source.subscribe(new MergeScanSubscriber(subscriber, this.accumulator, this.seed, this.concurrent));
5892         };
5893         return MergeScanOperator;
5894     }());
5895     var MergeScanSubscriber = (function (_super) {
5896         __extends(MergeScanSubscriber, _super);
5897         function MergeScanSubscriber(destination, accumulator, acc, concurrent) {
5898             var _this = _super.call(this, destination) || this;
5899             _this.accumulator = accumulator;
5900             _this.acc = acc;
5901             _this.concurrent = concurrent;
5902             _this.hasValue = false;
5903             _this.hasCompleted = false;
5904             _this.buffer = [];
5905             _this.active = 0;
5906             _this.index = 0;
5907             return _this;
5908         }
5909         MergeScanSubscriber.prototype._next = function (value) {
5910             if (this.active < this.concurrent) {
5911                 var index = this.index++;
5912                 var destination = this.destination;
5913                 var ish = void 0;
5914                 try {
5915                     var accumulator = this.accumulator;
5916                     ish = accumulator(this.acc, value, index);
5917                 }
5918                 catch (e) {
5919                     return destination.error(e);
5920                 }
5921                 this.active++;
5922                 this._innerSub(ish, value, index);
5923             }
5924             else {
5925                 this.buffer.push(value);
5926             }
5927         };
5928         MergeScanSubscriber.prototype._innerSub = function (ish, value, index) {
5929             var innerSubscriber = new InnerSubscriber(this, value, index);
5930             var destination = this.destination;
5931             destination.add(innerSubscriber);
5932             var innerSubscription = subscribeToResult(this, ish, undefined, undefined, innerSubscriber);
5933             if (innerSubscription !== innerSubscriber) {
5934                 destination.add(innerSubscription);
5935             }
5936         };
5937         MergeScanSubscriber.prototype._complete = function () {
5938             this.hasCompleted = true;
5939             if (this.active === 0 && this.buffer.length === 0) {
5940                 if (this.hasValue === false) {
5941                     this.destination.next(this.acc);
5942                 }
5943                 this.destination.complete();
5944             }
5945             this.unsubscribe();
5946         };
5947         MergeScanSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
5948             var destination = this.destination;
5949             this.acc = innerValue;
5950             this.hasValue = true;
5951             destination.next(innerValue);
5952         };
5953         MergeScanSubscriber.prototype.notifyComplete = function (innerSub) {
5954             var buffer = this.buffer;
5955             var destination = this.destination;
5956             destination.remove(innerSub);
5957             this.active--;
5958             if (buffer.length > 0) {
5959                 this._next(buffer.shift());
5960             }
5961             else if (this.active === 0 && this.hasCompleted) {
5962                 if (this.hasValue === false) {
5963                     this.destination.next(this.acc);
5964                 }
5965                 this.destination.complete();
5966             }
5967         };
5968         return MergeScanSubscriber;
5969     }(OuterSubscriber));
5970
5971     function min(comparer) {
5972         var min = (typeof comparer === 'function')
5973             ? function (x, y) { return comparer(x, y) < 0 ? x : y; }
5974             : function (x, y) { return x < y ? x : y; };
5975         return reduce(min);
5976     }
5977
5978     function multicast(subjectOrSubjectFactory, selector) {
5979         return function multicastOperatorFunction(source) {
5980             var subjectFactory;
5981             if (typeof subjectOrSubjectFactory === 'function') {
5982                 subjectFactory = subjectOrSubjectFactory;
5983             }
5984             else {
5985                 subjectFactory = function subjectFactory() {
5986                     return subjectOrSubjectFactory;
5987                 };
5988             }
5989             if (typeof selector === 'function') {
5990                 return source.lift(new MulticastOperator(subjectFactory, selector));
5991             }
5992             var connectable = Object.create(source, connectableObservableDescriptor);
5993             connectable.source = source;
5994             connectable.subjectFactory = subjectFactory;
5995             return connectable;
5996         };
5997     }
5998     var MulticastOperator = (function () {
5999         function MulticastOperator(subjectFactory, selector) {
6000             this.subjectFactory = subjectFactory;
6001             this.selector = selector;
6002         }
6003         MulticastOperator.prototype.call = function (subscriber, source) {
6004             var selector = this.selector;
6005             var subject = this.subjectFactory();
6006             var subscription = selector(subject).subscribe(subscriber);
6007             subscription.add(source.subscribe(subject));
6008             return subscription;
6009         };
6010         return MulticastOperator;
6011     }());
6012
6013     function onErrorResumeNext$1() {
6014         var nextSources = [];
6015         for (var _i = 0; _i < arguments.length; _i++) {
6016             nextSources[_i] = arguments[_i];
6017         }
6018         if (nextSources.length === 1 && isArray(nextSources[0])) {
6019             nextSources = nextSources[0];
6020         }
6021         return function (source) { return source.lift(new OnErrorResumeNextOperator(nextSources)); };
6022     }
6023     var OnErrorResumeNextOperator = (function () {
6024         function OnErrorResumeNextOperator(nextSources) {
6025             this.nextSources = nextSources;
6026         }
6027         OnErrorResumeNextOperator.prototype.call = function (subscriber, source) {
6028             return source.subscribe(new OnErrorResumeNextSubscriber(subscriber, this.nextSources));
6029         };
6030         return OnErrorResumeNextOperator;
6031     }());
6032     var OnErrorResumeNextSubscriber = (function (_super) {
6033         __extends(OnErrorResumeNextSubscriber, _super);
6034         function OnErrorResumeNextSubscriber(destination, nextSources) {
6035             var _this = _super.call(this, destination) || this;
6036             _this.destination = destination;
6037             _this.nextSources = nextSources;
6038             return _this;
6039         }
6040         OnErrorResumeNextSubscriber.prototype.notifyError = function (error, innerSub) {
6041             this.subscribeToNextSource();
6042         };
6043         OnErrorResumeNextSubscriber.prototype.notifyComplete = function (innerSub) {
6044             this.subscribeToNextSource();
6045         };
6046         OnErrorResumeNextSubscriber.prototype._error = function (err) {
6047             this.subscribeToNextSource();
6048             this.unsubscribe();
6049         };
6050         OnErrorResumeNextSubscriber.prototype._complete = function () {
6051             this.subscribeToNextSource();
6052             this.unsubscribe();
6053         };
6054         OnErrorResumeNextSubscriber.prototype.subscribeToNextSource = function () {
6055             var next = this.nextSources.shift();
6056             if (!!next) {
6057                 var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
6058                 var destination = this.destination;
6059                 destination.add(innerSubscriber);
6060                 var innerSubscription = subscribeToResult(this, next, undefined, undefined, innerSubscriber);
6061                 if (innerSubscription !== innerSubscriber) {
6062                     destination.add(innerSubscription);
6063                 }
6064             }
6065             else {
6066                 this.destination.complete();
6067             }
6068         };
6069         return OnErrorResumeNextSubscriber;
6070     }(OuterSubscriber));
6071
6072     function pairwise() {
6073         return function (source) { return source.lift(new PairwiseOperator()); };
6074     }
6075     var PairwiseOperator = (function () {
6076         function PairwiseOperator() {
6077         }
6078         PairwiseOperator.prototype.call = function (subscriber, source) {
6079             return source.subscribe(new PairwiseSubscriber(subscriber));
6080         };
6081         return PairwiseOperator;
6082     }());
6083     var PairwiseSubscriber = (function (_super) {
6084         __extends(PairwiseSubscriber, _super);
6085         function PairwiseSubscriber(destination) {
6086             var _this = _super.call(this, destination) || this;
6087             _this.hasPrev = false;
6088             return _this;
6089         }
6090         PairwiseSubscriber.prototype._next = function (value) {
6091             var pair;
6092             if (this.hasPrev) {
6093                 pair = [this.prev, value];
6094             }
6095             else {
6096                 this.hasPrev = true;
6097             }
6098             this.prev = value;
6099             if (pair) {
6100                 this.destination.next(pair);
6101             }
6102         };
6103         return PairwiseSubscriber;
6104     }(Subscriber));
6105
6106     function partition$1(predicate, thisArg) {
6107         return function (source) { return [
6108             filter(predicate, thisArg)(source),
6109             filter(not(predicate, thisArg))(source)
6110         ]; };
6111     }
6112
6113     function pluck() {
6114         var properties = [];
6115         for (var _i = 0; _i < arguments.length; _i++) {
6116             properties[_i] = arguments[_i];
6117         }
6118         var length = properties.length;
6119         if (length === 0) {
6120             throw new Error('list of properties cannot be empty.');
6121         }
6122         return function (source) { return map(plucker(properties, length))(source); };
6123     }
6124     function plucker(props, length) {
6125         var mapper = function (x) {
6126             var currentProp = x;
6127             for (var i = 0; i < length; i++) {
6128                 var p = currentProp != null ? currentProp[props[i]] : undefined;
6129                 if (p !== void 0) {
6130                     currentProp = p;
6131                 }
6132                 else {
6133                     return undefined;
6134                 }
6135             }
6136             return currentProp;
6137         };
6138         return mapper;
6139     }
6140
6141     function publish(selector) {
6142         return selector ?
6143             multicast(function () { return new Subject(); }, selector) :
6144             multicast(new Subject());
6145     }
6146
6147     function publishBehavior(value) {
6148         return function (source) { return multicast(new BehaviorSubject(value))(source); };
6149     }
6150
6151     function publishLast() {
6152         return function (source) { return multicast(new AsyncSubject())(source); };
6153     }
6154
6155     function publishReplay(bufferSize, windowTime, selectorOrScheduler, scheduler) {
6156         if (selectorOrScheduler && typeof selectorOrScheduler !== 'function') {
6157             scheduler = selectorOrScheduler;
6158         }
6159         var selector = typeof selectorOrScheduler === 'function' ? selectorOrScheduler : undefined;
6160         var subject = new ReplaySubject(bufferSize, windowTime, scheduler);
6161         return function (source) { return multicast(function () { return subject; }, selector)(source); };
6162     }
6163
6164     function race$1() {
6165         var observables = [];
6166         for (var _i = 0; _i < arguments.length; _i++) {
6167             observables[_i] = arguments[_i];
6168         }
6169         return function raceOperatorFunction(source) {
6170             if (observables.length === 1 && isArray(observables[0])) {
6171                 observables = observables[0];
6172             }
6173             return source.lift.call(race.apply(void 0, [source].concat(observables)));
6174         };
6175     }
6176
6177     function repeat(count) {
6178         if (count === void 0) { count = -1; }
6179         return function (source) {
6180             if (count === 0) {
6181                 return empty$1();
6182             }
6183             else if (count < 0) {
6184                 return source.lift(new RepeatOperator(-1, source));
6185             }
6186             else {
6187                 return source.lift(new RepeatOperator(count - 1, source));
6188             }
6189         };
6190     }
6191     var RepeatOperator = (function () {
6192         function RepeatOperator(count, source) {
6193             this.count = count;
6194             this.source = source;
6195         }
6196         RepeatOperator.prototype.call = function (subscriber, source) {
6197             return source.subscribe(new RepeatSubscriber(subscriber, this.count, this.source));
6198         };
6199         return RepeatOperator;
6200     }());
6201     var RepeatSubscriber = (function (_super) {
6202         __extends(RepeatSubscriber, _super);
6203         function RepeatSubscriber(destination, count, source) {
6204             var _this = _super.call(this, destination) || this;
6205             _this.count = count;
6206             _this.source = source;
6207             return _this;
6208         }
6209         RepeatSubscriber.prototype.complete = function () {
6210             if (!this.isStopped) {
6211                 var _a = this, source = _a.source, count = _a.count;
6212                 if (count === 0) {
6213                     return _super.prototype.complete.call(this);
6214                 }
6215                 else if (count > -1) {
6216                     this.count = count - 1;
6217                 }
6218                 source.subscribe(this._unsubscribeAndRecycle());
6219             }
6220         };
6221         return RepeatSubscriber;
6222     }(Subscriber));
6223
6224     function repeatWhen(notifier) {
6225         return function (source) { return source.lift(new RepeatWhenOperator(notifier)); };
6226     }
6227     var RepeatWhenOperator = (function () {
6228         function RepeatWhenOperator(notifier) {
6229             this.notifier = notifier;
6230         }
6231         RepeatWhenOperator.prototype.call = function (subscriber, source) {
6232             return source.subscribe(new RepeatWhenSubscriber(subscriber, this.notifier, source));
6233         };
6234         return RepeatWhenOperator;
6235     }());
6236     var RepeatWhenSubscriber = (function (_super) {
6237         __extends(RepeatWhenSubscriber, _super);
6238         function RepeatWhenSubscriber(destination, notifier, source) {
6239             var _this = _super.call(this, destination) || this;
6240             _this.notifier = notifier;
6241             _this.source = source;
6242             _this.sourceIsBeingSubscribedTo = true;
6243             return _this;
6244         }
6245         RepeatWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
6246             this.sourceIsBeingSubscribedTo = true;
6247             this.source.subscribe(this);
6248         };
6249         RepeatWhenSubscriber.prototype.notifyComplete = function (innerSub) {
6250             if (this.sourceIsBeingSubscribedTo === false) {
6251                 return _super.prototype.complete.call(this);
6252             }
6253         };
6254         RepeatWhenSubscriber.prototype.complete = function () {
6255             this.sourceIsBeingSubscribedTo = false;
6256             if (!this.isStopped) {
6257                 if (!this.retries) {
6258                     this.subscribeToRetries();
6259                 }
6260                 if (!this.retriesSubscription || this.retriesSubscription.closed) {
6261                     return _super.prototype.complete.call(this);
6262                 }
6263                 this._unsubscribeAndRecycle();
6264                 this.notifications.next();
6265             }
6266         };
6267         RepeatWhenSubscriber.prototype._unsubscribe = function () {
6268             var _a = this, notifications = _a.notifications, retriesSubscription = _a.retriesSubscription;
6269             if (notifications) {
6270                 notifications.unsubscribe();
6271                 this.notifications = null;
6272             }
6273             if (retriesSubscription) {
6274                 retriesSubscription.unsubscribe();
6275                 this.retriesSubscription = null;
6276             }
6277             this.retries = null;
6278         };
6279         RepeatWhenSubscriber.prototype._unsubscribeAndRecycle = function () {
6280             var _unsubscribe = this._unsubscribe;
6281             this._unsubscribe = null;
6282             _super.prototype._unsubscribeAndRecycle.call(this);
6283             this._unsubscribe = _unsubscribe;
6284             return this;
6285         };
6286         RepeatWhenSubscriber.prototype.subscribeToRetries = function () {
6287             this.notifications = new Subject();
6288             var retries;
6289             try {
6290                 var notifier = this.notifier;
6291                 retries = notifier(this.notifications);
6292             }
6293             catch (e) {
6294                 return _super.prototype.complete.call(this);
6295             }
6296             this.retries = retries;
6297             this.retriesSubscription = subscribeToResult(this, retries);
6298         };
6299         return RepeatWhenSubscriber;
6300     }(OuterSubscriber));
6301
6302     function retry(count) {
6303         if (count === void 0) { count = -1; }
6304         return function (source) { return source.lift(new RetryOperator(count, source)); };
6305     }
6306     var RetryOperator = (function () {
6307         function RetryOperator(count, source) {
6308             this.count = count;
6309             this.source = source;
6310         }
6311         RetryOperator.prototype.call = function (subscriber, source) {
6312             return source.subscribe(new RetrySubscriber(subscriber, this.count, this.source));
6313         };
6314         return RetryOperator;
6315     }());
6316     var RetrySubscriber = (function (_super) {
6317         __extends(RetrySubscriber, _super);
6318         function RetrySubscriber(destination, count, source) {
6319             var _this = _super.call(this, destination) || this;
6320             _this.count = count;
6321             _this.source = source;
6322             return _this;
6323         }
6324         RetrySubscriber.prototype.error = function (err) {
6325             if (!this.isStopped) {
6326                 var _a = this, source = _a.source, count = _a.count;
6327                 if (count === 0) {
6328                     return _super.prototype.error.call(this, err);
6329                 }
6330                 else if (count > -1) {
6331                     this.count = count - 1;
6332                 }
6333                 source.subscribe(this._unsubscribeAndRecycle());
6334             }
6335         };
6336         return RetrySubscriber;
6337     }(Subscriber));
6338
6339     function retryWhen(notifier) {
6340         return function (source) { return source.lift(new RetryWhenOperator(notifier, source)); };
6341     }
6342     var RetryWhenOperator = (function () {
6343         function RetryWhenOperator(notifier, source) {
6344             this.notifier = notifier;
6345             this.source = source;
6346         }
6347         RetryWhenOperator.prototype.call = function (subscriber, source) {
6348             return source.subscribe(new RetryWhenSubscriber(subscriber, this.notifier, this.source));
6349         };
6350         return RetryWhenOperator;
6351     }());
6352     var RetryWhenSubscriber = (function (_super) {
6353         __extends(RetryWhenSubscriber, _super);
6354         function RetryWhenSubscriber(destination, notifier, source) {
6355             var _this = _super.call(this, destination) || this;
6356             _this.notifier = notifier;
6357             _this.source = source;
6358             return _this;
6359         }
6360         RetryWhenSubscriber.prototype.error = function (err) {
6361             if (!this.isStopped) {
6362                 var errors = this.errors;
6363                 var retries = this.retries;
6364                 var retriesSubscription = this.retriesSubscription;
6365                 if (!retries) {
6366                     errors = new Subject();
6367                     try {
6368                         var notifier = this.notifier;
6369                         retries = notifier(errors);
6370                     }
6371                     catch (e) {
6372                         return _super.prototype.error.call(this, e);
6373                     }
6374                     retriesSubscription = subscribeToResult(this, retries);
6375                 }
6376                 else {
6377                     this.errors = null;
6378                     this.retriesSubscription = null;
6379                 }
6380                 this._unsubscribeAndRecycle();
6381                 this.errors = errors;
6382                 this.retries = retries;
6383                 this.retriesSubscription = retriesSubscription;
6384                 errors.next(err);
6385             }
6386         };
6387         RetryWhenSubscriber.prototype._unsubscribe = function () {
6388             var _a = this, errors = _a.errors, retriesSubscription = _a.retriesSubscription;
6389             if (errors) {
6390                 errors.unsubscribe();
6391                 this.errors = null;
6392             }
6393             if (retriesSubscription) {
6394                 retriesSubscription.unsubscribe();
6395                 this.retriesSubscription = null;
6396             }
6397             this.retries = null;
6398         };
6399         RetryWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
6400             var _unsubscribe = this._unsubscribe;
6401             this._unsubscribe = null;
6402             this._unsubscribeAndRecycle();
6403             this._unsubscribe = _unsubscribe;
6404             this.source.subscribe(this);
6405         };
6406         return RetryWhenSubscriber;
6407     }(OuterSubscriber));
6408
6409     function sample(notifier) {
6410         return function (source) { return source.lift(new SampleOperator(notifier)); };
6411     }
6412     var SampleOperator = (function () {
6413         function SampleOperator(notifier) {
6414             this.notifier = notifier;
6415         }
6416         SampleOperator.prototype.call = function (subscriber, source) {
6417             var sampleSubscriber = new SampleSubscriber(subscriber);
6418             var subscription = source.subscribe(sampleSubscriber);
6419             subscription.add(subscribeToResult(sampleSubscriber, this.notifier));
6420             return subscription;
6421         };
6422         return SampleOperator;
6423     }());
6424     var SampleSubscriber = (function (_super) {
6425         __extends(SampleSubscriber, _super);
6426         function SampleSubscriber() {
6427             var _this = _super !== null && _super.apply(this, arguments) || this;
6428             _this.hasValue = false;
6429             return _this;
6430         }
6431         SampleSubscriber.prototype._next = function (value) {
6432             this.value = value;
6433             this.hasValue = true;
6434         };
6435         SampleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
6436             this.emitValue();
6437         };
6438         SampleSubscriber.prototype.notifyComplete = function () {
6439             this.emitValue();
6440         };
6441         SampleSubscriber.prototype.emitValue = function () {
6442             if (this.hasValue) {
6443                 this.hasValue = false;
6444                 this.destination.next(this.value);
6445             }
6446         };
6447         return SampleSubscriber;
6448     }(OuterSubscriber));
6449
6450     function sampleTime(period, scheduler) {
6451         if (scheduler === void 0) { scheduler = async; }
6452         return function (source) { return source.lift(new SampleTimeOperator(period, scheduler)); };
6453     }
6454     var SampleTimeOperator = (function () {
6455         function SampleTimeOperator(period, scheduler) {
6456             this.period = period;
6457             this.scheduler = scheduler;
6458         }
6459         SampleTimeOperator.prototype.call = function (subscriber, source) {
6460             return source.subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler));
6461         };
6462         return SampleTimeOperator;
6463     }());
6464     var SampleTimeSubscriber = (function (_super) {
6465         __extends(SampleTimeSubscriber, _super);
6466         function SampleTimeSubscriber(destination, period, scheduler) {
6467             var _this = _super.call(this, destination) || this;
6468             _this.period = period;
6469             _this.scheduler = scheduler;
6470             _this.hasValue = false;
6471             _this.add(scheduler.schedule(dispatchNotification, period, { subscriber: _this, period: period }));
6472             return _this;
6473         }
6474         SampleTimeSubscriber.prototype._next = function (value) {
6475             this.lastValue = value;
6476             this.hasValue = true;
6477         };
6478         SampleTimeSubscriber.prototype.notifyNext = function () {
6479             if (this.hasValue) {
6480                 this.hasValue = false;
6481                 this.destination.next(this.lastValue);
6482             }
6483         };
6484         return SampleTimeSubscriber;
6485     }(Subscriber));
6486     function dispatchNotification(state) {
6487         var subscriber = state.subscriber, period = state.period;
6488         subscriber.notifyNext();
6489         this.schedule(state, period);
6490     }
6491
6492     function sequenceEqual(compareTo, comparator) {
6493         return function (source) { return source.lift(new SequenceEqualOperator(compareTo, comparator)); };
6494     }
6495     var SequenceEqualOperator = (function () {
6496         function SequenceEqualOperator(compareTo, comparator) {
6497             this.compareTo = compareTo;
6498             this.comparator = comparator;
6499         }
6500         SequenceEqualOperator.prototype.call = function (subscriber, source) {
6501             return source.subscribe(new SequenceEqualSubscriber(subscriber, this.compareTo, this.comparator));
6502         };
6503         return SequenceEqualOperator;
6504     }());
6505     var SequenceEqualSubscriber = (function (_super) {
6506         __extends(SequenceEqualSubscriber, _super);
6507         function SequenceEqualSubscriber(destination, compareTo, comparator) {
6508             var _this = _super.call(this, destination) || this;
6509             _this.compareTo = compareTo;
6510             _this.comparator = comparator;
6511             _this._a = [];
6512             _this._b = [];
6513             _this._oneComplete = false;
6514             _this.destination.add(compareTo.subscribe(new SequenceEqualCompareToSubscriber(destination, _this)));
6515             return _this;
6516         }
6517         SequenceEqualSubscriber.prototype._next = function (value) {
6518             if (this._oneComplete && this._b.length === 0) {
6519                 this.emit(false);
6520             }
6521             else {
6522                 this._a.push(value);
6523                 this.checkValues();
6524             }
6525         };
6526         SequenceEqualSubscriber.prototype._complete = function () {
6527             if (this._oneComplete) {
6528                 this.emit(this._a.length === 0 && this._b.length === 0);
6529             }
6530             else {
6531                 this._oneComplete = true;
6532             }
6533             this.unsubscribe();
6534         };
6535         SequenceEqualSubscriber.prototype.checkValues = function () {
6536             var _c = this, _a = _c._a, _b = _c._b, comparator = _c.comparator;
6537             while (_a.length > 0 && _b.length > 0) {
6538                 var a = _a.shift();
6539                 var b = _b.shift();
6540                 var areEqual = false;
6541                 try {
6542                     areEqual = comparator ? comparator(a, b) : a === b;
6543                 }
6544                 catch (e) {
6545                     this.destination.error(e);
6546                 }
6547                 if (!areEqual) {
6548                     this.emit(false);
6549                 }
6550             }
6551         };
6552         SequenceEqualSubscriber.prototype.emit = function (value) {
6553             var destination = this.destination;
6554             destination.next(value);
6555             destination.complete();
6556         };
6557         SequenceEqualSubscriber.prototype.nextB = function (value) {
6558             if (this._oneComplete && this._a.length === 0) {
6559                 this.emit(false);
6560             }
6561             else {
6562                 this._b.push(value);
6563                 this.checkValues();
6564             }
6565         };
6566         SequenceEqualSubscriber.prototype.completeB = function () {
6567             if (this._oneComplete) {
6568                 this.emit(this._a.length === 0 && this._b.length === 0);
6569             }
6570             else {
6571                 this._oneComplete = true;
6572             }
6573         };
6574         return SequenceEqualSubscriber;
6575     }(Subscriber));
6576     var SequenceEqualCompareToSubscriber = (function (_super) {
6577         __extends(SequenceEqualCompareToSubscriber, _super);
6578         function SequenceEqualCompareToSubscriber(destination, parent) {
6579             var _this = _super.call(this, destination) || this;
6580             _this.parent = parent;
6581             return _this;
6582         }
6583         SequenceEqualCompareToSubscriber.prototype._next = function (value) {
6584             this.parent.nextB(value);
6585         };
6586         SequenceEqualCompareToSubscriber.prototype._error = function (err) {
6587             this.parent.error(err);
6588             this.unsubscribe();
6589         };
6590         SequenceEqualCompareToSubscriber.prototype._complete = function () {
6591             this.parent.completeB();
6592             this.unsubscribe();
6593         };
6594         return SequenceEqualCompareToSubscriber;
6595     }(Subscriber));
6596
6597     function shareSubjectFactory() {
6598         return new Subject();
6599     }
6600     function share() {
6601         return function (source) { return refCount()(multicast(shareSubjectFactory)(source)); };
6602     }
6603
6604     function shareReplay(configOrBufferSize, windowTime, scheduler) {
6605         var config;
6606         if (configOrBufferSize && typeof configOrBufferSize === 'object') {
6607             config = configOrBufferSize;
6608         }
6609         else {
6610             config = {
6611                 bufferSize: configOrBufferSize,
6612                 windowTime: windowTime,
6613                 refCount: false,
6614                 scheduler: scheduler
6615             };
6616         }
6617         return function (source) { return source.lift(shareReplayOperator(config)); };
6618     }
6619     function shareReplayOperator(_a) {
6620         var _b = _a.bufferSize, bufferSize = _b === void 0 ? Number.POSITIVE_INFINITY : _b, _c = _a.windowTime, windowTime = _c === void 0 ? Number.POSITIVE_INFINITY : _c, useRefCount = _a.refCount, scheduler = _a.scheduler;
6621         var subject;
6622         var refCount = 0;
6623         var subscription;
6624         var hasError = false;
6625         var isComplete = false;
6626         return function shareReplayOperation(source) {
6627             refCount++;
6628             var innerSub;
6629             if (!subject || hasError) {
6630                 hasError = false;
6631                 subject = new ReplaySubject(bufferSize, windowTime, scheduler);
6632                 innerSub = subject.subscribe(this);
6633                 subscription = source.subscribe({
6634                     next: function (value) { subject.next(value); },
6635                     error: function (err) {
6636                         hasError = true;
6637                         subject.error(err);
6638                     },
6639                     complete: function () {
6640                         isComplete = true;
6641                         subscription = undefined;
6642                         subject.complete();
6643                     },
6644                 });
6645             }
6646             else {
6647                 innerSub = subject.subscribe(this);
6648             }
6649             this.add(function () {
6650                 refCount--;
6651                 innerSub.unsubscribe();
6652                 if (subscription && !isComplete && useRefCount && refCount === 0) {
6653                     subscription.unsubscribe();
6654                     subscription = undefined;
6655                     subject = undefined;
6656                 }
6657             });
6658         };
6659     }
6660
6661     function single(predicate) {
6662         return function (source) { return source.lift(new SingleOperator(predicate, source)); };
6663     }
6664     var SingleOperator = (function () {
6665         function SingleOperator(predicate, source) {
6666             this.predicate = predicate;
6667             this.source = source;
6668         }
6669         SingleOperator.prototype.call = function (subscriber, source) {
6670             return source.subscribe(new SingleSubscriber(subscriber, this.predicate, this.source));
6671         };
6672         return SingleOperator;
6673     }());
6674     var SingleSubscriber = (function (_super) {
6675         __extends(SingleSubscriber, _super);
6676         function SingleSubscriber(destination, predicate, source) {
6677             var _this = _super.call(this, destination) || this;
6678             _this.predicate = predicate;
6679             _this.source = source;
6680             _this.seenValue = false;
6681             _this.index = 0;
6682             return _this;
6683         }
6684         SingleSubscriber.prototype.applySingleValue = function (value) {
6685             if (this.seenValue) {
6686                 this.destination.error('Sequence contains more than one element');
6687             }
6688             else {
6689                 this.seenValue = true;
6690                 this.singleValue = value;
6691             }
6692         };
6693         SingleSubscriber.prototype._next = function (value) {
6694             var index = this.index++;
6695             if (this.predicate) {
6696                 this.tryNext(value, index);
6697             }
6698             else {
6699                 this.applySingleValue(value);
6700             }
6701         };
6702         SingleSubscriber.prototype.tryNext = function (value, index) {
6703             try {
6704                 if (this.predicate(value, index, this.source)) {
6705                     this.applySingleValue(value);
6706                 }
6707             }
6708             catch (err) {
6709                 this.destination.error(err);
6710             }
6711         };
6712         SingleSubscriber.prototype._complete = function () {
6713             var destination = this.destination;
6714             if (this.index > 0) {
6715                 destination.next(this.seenValue ? this.singleValue : undefined);
6716                 destination.complete();
6717             }
6718             else {
6719                 destination.error(new EmptyError);
6720             }
6721         };
6722         return SingleSubscriber;
6723     }(Subscriber));
6724
6725     function skip(count) {
6726         return function (source) { return source.lift(new SkipOperator(count)); };
6727     }
6728     var SkipOperator = (function () {
6729         function SkipOperator(total) {
6730             this.total = total;
6731         }
6732         SkipOperator.prototype.call = function (subscriber, source) {
6733             return source.subscribe(new SkipSubscriber(subscriber, this.total));
6734         };
6735         return SkipOperator;
6736     }());
6737     var SkipSubscriber = (function (_super) {
6738         __extends(SkipSubscriber, _super);
6739         function SkipSubscriber(destination, total) {
6740             var _this = _super.call(this, destination) || this;
6741             _this.total = total;
6742             _this.count = 0;
6743             return _this;
6744         }
6745         SkipSubscriber.prototype._next = function (x) {
6746             if (++this.count > this.total) {
6747                 this.destination.next(x);
6748             }
6749         };
6750         return SkipSubscriber;
6751     }(Subscriber));
6752
6753     function skipLast(count) {
6754         return function (source) { return source.lift(new SkipLastOperator(count)); };
6755     }
6756     var SkipLastOperator = (function () {
6757         function SkipLastOperator(_skipCount) {
6758             this._skipCount = _skipCount;
6759             if (this._skipCount < 0) {
6760                 throw new ArgumentOutOfRangeError;
6761             }
6762         }
6763         SkipLastOperator.prototype.call = function (subscriber, source) {
6764             if (this._skipCount === 0) {
6765                 return source.subscribe(new Subscriber(subscriber));
6766             }
6767             else {
6768                 return source.subscribe(new SkipLastSubscriber(subscriber, this._skipCount));
6769             }
6770         };
6771         return SkipLastOperator;
6772     }());
6773     var SkipLastSubscriber = (function (_super) {
6774         __extends(SkipLastSubscriber, _super);
6775         function SkipLastSubscriber(destination, _skipCount) {
6776             var _this = _super.call(this, destination) || this;
6777             _this._skipCount = _skipCount;
6778             _this._count = 0;
6779             _this._ring = new Array(_skipCount);
6780             return _this;
6781         }
6782         SkipLastSubscriber.prototype._next = function (value) {
6783             var skipCount = this._skipCount;
6784             var count = this._count++;
6785             if (count < skipCount) {
6786                 this._ring[count] = value;
6787             }
6788             else {
6789                 var currentIndex = count % skipCount;
6790                 var ring = this._ring;
6791                 var oldValue = ring[currentIndex];
6792                 ring[currentIndex] = value;
6793                 this.destination.next(oldValue);
6794             }
6795         };
6796         return SkipLastSubscriber;
6797     }(Subscriber));
6798
6799     function skipUntil(notifier) {
6800         return function (source) { return source.lift(new SkipUntilOperator(notifier)); };
6801     }
6802     var SkipUntilOperator = (function () {
6803         function SkipUntilOperator(notifier) {
6804             this.notifier = notifier;
6805         }
6806         SkipUntilOperator.prototype.call = function (destination, source) {
6807             return source.subscribe(new SkipUntilSubscriber(destination, this.notifier));
6808         };
6809         return SkipUntilOperator;
6810     }());
6811     var SkipUntilSubscriber = (function (_super) {
6812         __extends(SkipUntilSubscriber, _super);
6813         function SkipUntilSubscriber(destination, notifier) {
6814             var _this = _super.call(this, destination) || this;
6815             _this.hasValue = false;
6816             var innerSubscriber = new InnerSubscriber(_this, undefined, undefined);
6817             _this.add(innerSubscriber);
6818             _this.innerSubscription = innerSubscriber;
6819             var innerSubscription = subscribeToResult(_this, notifier, undefined, undefined, innerSubscriber);
6820             if (innerSubscription !== innerSubscriber) {
6821                 _this.add(innerSubscription);
6822                 _this.innerSubscription = innerSubscription;
6823             }
6824             return _this;
6825         }
6826         SkipUntilSubscriber.prototype._next = function (value) {
6827             if (this.hasValue) {
6828                 _super.prototype._next.call(this, value);
6829             }
6830         };
6831         SkipUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
6832             this.hasValue = true;
6833             if (this.innerSubscription) {
6834                 this.innerSubscription.unsubscribe();
6835             }
6836         };
6837         SkipUntilSubscriber.prototype.notifyComplete = function () {
6838         };
6839         return SkipUntilSubscriber;
6840     }(OuterSubscriber));
6841
6842     function skipWhile(predicate) {
6843         return function (source) { return source.lift(new SkipWhileOperator(predicate)); };
6844     }
6845     var SkipWhileOperator = (function () {
6846         function SkipWhileOperator(predicate) {
6847             this.predicate = predicate;
6848         }
6849         SkipWhileOperator.prototype.call = function (subscriber, source) {
6850             return source.subscribe(new SkipWhileSubscriber(subscriber, this.predicate));
6851         };
6852         return SkipWhileOperator;
6853     }());
6854     var SkipWhileSubscriber = (function (_super) {
6855         __extends(SkipWhileSubscriber, _super);
6856         function SkipWhileSubscriber(destination, predicate) {
6857             var _this = _super.call(this, destination) || this;
6858             _this.predicate = predicate;
6859             _this.skipping = true;
6860             _this.index = 0;
6861             return _this;
6862         }
6863         SkipWhileSubscriber.prototype._next = function (value) {
6864             var destination = this.destination;
6865             if (this.skipping) {
6866                 this.tryCallPredicate(value);
6867             }
6868             if (!this.skipping) {
6869                 destination.next(value);
6870             }
6871         };
6872         SkipWhileSubscriber.prototype.tryCallPredicate = function (value) {
6873             try {
6874                 var result = this.predicate(value, this.index++);
6875                 this.skipping = Boolean(result);
6876             }
6877             catch (err) {
6878                 this.destination.error(err);
6879             }
6880         };
6881         return SkipWhileSubscriber;
6882     }(Subscriber));
6883
6884     function startWith() {
6885         var array = [];
6886         for (var _i = 0; _i < arguments.length; _i++) {
6887             array[_i] = arguments[_i];
6888         }
6889         var scheduler = array[array.length - 1];
6890         if (isScheduler(scheduler)) {
6891             array.pop();
6892             return function (source) { return concat(array, source, scheduler); };
6893         }
6894         else {
6895             return function (source) { return concat(array, source); };
6896         }
6897     }
6898
6899     var SubscribeOnObservable = (function (_super) {
6900         __extends(SubscribeOnObservable, _super);
6901         function SubscribeOnObservable(source, delayTime, scheduler) {
6902             if (delayTime === void 0) { delayTime = 0; }
6903             if (scheduler === void 0) { scheduler = asap; }
6904             var _this = _super.call(this) || this;
6905             _this.source = source;
6906             _this.delayTime = delayTime;
6907             _this.scheduler = scheduler;
6908             if (!isNumeric(delayTime) || delayTime < 0) {
6909                 _this.delayTime = 0;
6910             }
6911             if (!scheduler || typeof scheduler.schedule !== 'function') {
6912                 _this.scheduler = asap;
6913             }
6914             return _this;
6915         }
6916         SubscribeOnObservable.create = function (source, delay, scheduler) {
6917             if (delay === void 0) { delay = 0; }
6918             if (scheduler === void 0) { scheduler = asap; }
6919             return new SubscribeOnObservable(source, delay, scheduler);
6920         };
6921         SubscribeOnObservable.dispatch = function (arg) {
6922             var source = arg.source, subscriber = arg.subscriber;
6923             return this.add(source.subscribe(subscriber));
6924         };
6925         SubscribeOnObservable.prototype._subscribe = function (subscriber) {
6926             var delay = this.delayTime;
6927             var source = this.source;
6928             var scheduler = this.scheduler;
6929             return scheduler.schedule(SubscribeOnObservable.dispatch, delay, {
6930                 source: source, subscriber: subscriber
6931             });
6932         };
6933         return SubscribeOnObservable;
6934     }(Observable));
6935
6936     function subscribeOn(scheduler, delay) {
6937         if (delay === void 0) { delay = 0; }
6938         return function subscribeOnOperatorFunction(source) {
6939             return source.lift(new SubscribeOnOperator(scheduler, delay));
6940         };
6941     }
6942     var SubscribeOnOperator = (function () {
6943         function SubscribeOnOperator(scheduler, delay) {
6944             this.scheduler = scheduler;
6945             this.delay = delay;
6946         }
6947         SubscribeOnOperator.prototype.call = function (subscriber, source) {
6948             return new SubscribeOnObservable(source, this.delay, this.scheduler).subscribe(subscriber);
6949         };
6950         return SubscribeOnOperator;
6951     }());
6952
6953     function switchMap(project, resultSelector) {
6954         if (typeof resultSelector === 'function') {
6955             return function (source) { return source.pipe(switchMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
6956         }
6957         return function (source) { return source.lift(new SwitchMapOperator(project)); };
6958     }
6959     var SwitchMapOperator = (function () {
6960         function SwitchMapOperator(project) {
6961             this.project = project;
6962         }
6963         SwitchMapOperator.prototype.call = function (subscriber, source) {
6964             return source.subscribe(new SwitchMapSubscriber(subscriber, this.project));
6965         };
6966         return SwitchMapOperator;
6967     }());
6968     var SwitchMapSubscriber = (function (_super) {
6969         __extends(SwitchMapSubscriber, _super);
6970         function SwitchMapSubscriber(destination, project) {
6971             var _this = _super.call(this, destination) || this;
6972             _this.project = project;
6973             _this.index = 0;
6974             return _this;
6975         }
6976         SwitchMapSubscriber.prototype._next = function (value) {
6977             var result;
6978             var index = this.index++;
6979             try {
6980                 result = this.project(value, index);
6981             }
6982             catch (error) {
6983                 this.destination.error(error);
6984                 return;
6985             }
6986             this._innerSub(result, value, index);
6987         };
6988         SwitchMapSubscriber.prototype._innerSub = function (result, value, index) {
6989             var innerSubscription = this.innerSubscription;
6990             if (innerSubscription) {
6991                 innerSubscription.unsubscribe();
6992             }
6993             var innerSubscriber = new InnerSubscriber(this, value, index);
6994             var destination = this.destination;
6995             destination.add(innerSubscriber);
6996             this.innerSubscription = subscribeToResult(this, result, undefined, undefined, innerSubscriber);
6997             if (this.innerSubscription !== innerSubscriber) {
6998                 destination.add(this.innerSubscription);
6999             }
7000         };
7001         SwitchMapSubscriber.prototype._complete = function () {
7002             var innerSubscription = this.innerSubscription;
7003             if (!innerSubscription || innerSubscription.closed) {
7004                 _super.prototype._complete.call(this);
7005             }
7006             this.unsubscribe();
7007         };
7008         SwitchMapSubscriber.prototype._unsubscribe = function () {
7009             this.innerSubscription = null;
7010         };
7011         SwitchMapSubscriber.prototype.notifyComplete = function (innerSub) {
7012             var destination = this.destination;
7013             destination.remove(innerSub);
7014             this.innerSubscription = null;
7015             if (this.isStopped) {
7016                 _super.prototype._complete.call(this);
7017             }
7018         };
7019         SwitchMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7020             this.destination.next(innerValue);
7021         };
7022         return SwitchMapSubscriber;
7023     }(OuterSubscriber));
7024
7025     function switchAll() {
7026         return switchMap(identity);
7027     }
7028
7029     function switchMapTo(innerObservable, resultSelector) {
7030         return resultSelector ? switchMap(function () { return innerObservable; }, resultSelector) : switchMap(function () { return innerObservable; });
7031     }
7032
7033     function takeUntil(notifier) {
7034         return function (source) { return source.lift(new TakeUntilOperator(notifier)); };
7035     }
7036     var TakeUntilOperator = (function () {
7037         function TakeUntilOperator(notifier) {
7038             this.notifier = notifier;
7039         }
7040         TakeUntilOperator.prototype.call = function (subscriber, source) {
7041             var takeUntilSubscriber = new TakeUntilSubscriber(subscriber);
7042             var notifierSubscription = subscribeToResult(takeUntilSubscriber, this.notifier);
7043             if (notifierSubscription && !takeUntilSubscriber.seenValue) {
7044                 takeUntilSubscriber.add(notifierSubscription);
7045                 return source.subscribe(takeUntilSubscriber);
7046             }
7047             return takeUntilSubscriber;
7048         };
7049         return TakeUntilOperator;
7050     }());
7051     var TakeUntilSubscriber = (function (_super) {
7052         __extends(TakeUntilSubscriber, _super);
7053         function TakeUntilSubscriber(destination) {
7054             var _this = _super.call(this, destination) || this;
7055             _this.seenValue = false;
7056             return _this;
7057         }
7058         TakeUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7059             this.seenValue = true;
7060             this.complete();
7061         };
7062         TakeUntilSubscriber.prototype.notifyComplete = function () {
7063         };
7064         return TakeUntilSubscriber;
7065     }(OuterSubscriber));
7066
7067     function takeWhile(predicate, inclusive) {
7068         if (inclusive === void 0) { inclusive = false; }
7069         return function (source) {
7070             return source.lift(new TakeWhileOperator(predicate, inclusive));
7071         };
7072     }
7073     var TakeWhileOperator = (function () {
7074         function TakeWhileOperator(predicate, inclusive) {
7075             this.predicate = predicate;
7076             this.inclusive = inclusive;
7077         }
7078         TakeWhileOperator.prototype.call = function (subscriber, source) {
7079             return source.subscribe(new TakeWhileSubscriber(subscriber, this.predicate, this.inclusive));
7080         };
7081         return TakeWhileOperator;
7082     }());
7083     var TakeWhileSubscriber = (function (_super) {
7084         __extends(TakeWhileSubscriber, _super);
7085         function TakeWhileSubscriber(destination, predicate, inclusive) {
7086             var _this = _super.call(this, destination) || this;
7087             _this.predicate = predicate;
7088             _this.inclusive = inclusive;
7089             _this.index = 0;
7090             return _this;
7091         }
7092         TakeWhileSubscriber.prototype._next = function (value) {
7093             var destination = this.destination;
7094             var result;
7095             try {
7096                 result = this.predicate(value, this.index++);
7097             }
7098             catch (err) {
7099                 destination.error(err);
7100                 return;
7101             }
7102             this.nextOrComplete(value, result);
7103         };
7104         TakeWhileSubscriber.prototype.nextOrComplete = function (value, predicateResult) {
7105             var destination = this.destination;
7106             if (Boolean(predicateResult)) {
7107                 destination.next(value);
7108             }
7109             else {
7110                 if (this.inclusive) {
7111                     destination.next(value);
7112                 }
7113                 destination.complete();
7114             }
7115         };
7116         return TakeWhileSubscriber;
7117     }(Subscriber));
7118
7119     function tap(nextOrObserver, error, complete) {
7120         return function tapOperatorFunction(source) {
7121             return source.lift(new DoOperator(nextOrObserver, error, complete));
7122         };
7123     }
7124     var DoOperator = (function () {
7125         function DoOperator(nextOrObserver, error, complete) {
7126             this.nextOrObserver = nextOrObserver;
7127             this.error = error;
7128             this.complete = complete;
7129         }
7130         DoOperator.prototype.call = function (subscriber, source) {
7131             return source.subscribe(new TapSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));
7132         };
7133         return DoOperator;
7134     }());
7135     var TapSubscriber = (function (_super) {
7136         __extends(TapSubscriber, _super);
7137         function TapSubscriber(destination, observerOrNext, error, complete) {
7138             var _this = _super.call(this, destination) || this;
7139             _this._tapNext = noop;
7140             _this._tapError = noop;
7141             _this._tapComplete = noop;
7142             _this._tapError = error || noop;
7143             _this._tapComplete = complete || noop;
7144             if (isFunction(observerOrNext)) {
7145                 _this._context = _this;
7146                 _this._tapNext = observerOrNext;
7147             }
7148             else if (observerOrNext) {
7149                 _this._context = observerOrNext;
7150                 _this._tapNext = observerOrNext.next || noop;
7151                 _this._tapError = observerOrNext.error || noop;
7152                 _this._tapComplete = observerOrNext.complete || noop;
7153             }
7154             return _this;
7155         }
7156         TapSubscriber.prototype._next = function (value) {
7157             try {
7158                 this._tapNext.call(this._context, value);
7159             }
7160             catch (err) {
7161                 this.destination.error(err);
7162                 return;
7163             }
7164             this.destination.next(value);
7165         };
7166         TapSubscriber.prototype._error = function (err) {
7167             try {
7168                 this._tapError.call(this._context, err);
7169             }
7170             catch (err) {
7171                 this.destination.error(err);
7172                 return;
7173             }
7174             this.destination.error(err);
7175         };
7176         TapSubscriber.prototype._complete = function () {
7177             try {
7178                 this._tapComplete.call(this._context);
7179             }
7180             catch (err) {
7181                 this.destination.error(err);
7182                 return;
7183             }
7184             return this.destination.complete();
7185         };
7186         return TapSubscriber;
7187     }(Subscriber));
7188
7189     var defaultThrottleConfig = {
7190         leading: true,
7191         trailing: false
7192     };
7193     function throttle(durationSelector, config) {
7194         if (config === void 0) { config = defaultThrottleConfig; }
7195         return function (source) { return source.lift(new ThrottleOperator(durationSelector, config.leading, config.trailing)); };
7196     }
7197     var ThrottleOperator = (function () {
7198         function ThrottleOperator(durationSelector, leading, trailing) {
7199             this.durationSelector = durationSelector;
7200             this.leading = leading;
7201             this.trailing = trailing;
7202         }
7203         ThrottleOperator.prototype.call = function (subscriber, source) {
7204             return source.subscribe(new ThrottleSubscriber(subscriber, this.durationSelector, this.leading, this.trailing));
7205         };
7206         return ThrottleOperator;
7207     }());
7208     var ThrottleSubscriber = (function (_super) {
7209         __extends(ThrottleSubscriber, _super);
7210         function ThrottleSubscriber(destination, durationSelector, _leading, _trailing) {
7211             var _this = _super.call(this, destination) || this;
7212             _this.destination = destination;
7213             _this.durationSelector = durationSelector;
7214             _this._leading = _leading;
7215             _this._trailing = _trailing;
7216             _this._hasValue = false;
7217             return _this;
7218         }
7219         ThrottleSubscriber.prototype._next = function (value) {
7220             this._hasValue = true;
7221             this._sendValue = value;
7222             if (!this._throttled) {
7223                 if (this._leading) {
7224                     this.send();
7225                 }
7226                 else {
7227                     this.throttle(value);
7228                 }
7229             }
7230         };
7231         ThrottleSubscriber.prototype.send = function () {
7232             var _a = this, _hasValue = _a._hasValue, _sendValue = _a._sendValue;
7233             if (_hasValue) {
7234                 this.destination.next(_sendValue);
7235                 this.throttle(_sendValue);
7236             }
7237             this._hasValue = false;
7238             this._sendValue = null;
7239         };
7240         ThrottleSubscriber.prototype.throttle = function (value) {
7241             var duration = this.tryDurationSelector(value);
7242             if (!!duration) {
7243                 this.add(this._throttled = subscribeToResult(this, duration));
7244             }
7245         };
7246         ThrottleSubscriber.prototype.tryDurationSelector = function (value) {
7247             try {
7248                 return this.durationSelector(value);
7249             }
7250             catch (err) {
7251                 this.destination.error(err);
7252                 return null;
7253             }
7254         };
7255         ThrottleSubscriber.prototype.throttlingDone = function () {
7256             var _a = this, _throttled = _a._throttled, _trailing = _a._trailing;
7257             if (_throttled) {
7258                 _throttled.unsubscribe();
7259             }
7260             this._throttled = null;
7261             if (_trailing) {
7262                 this.send();
7263             }
7264         };
7265         ThrottleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7266             this.throttlingDone();
7267         };
7268         ThrottleSubscriber.prototype.notifyComplete = function () {
7269             this.throttlingDone();
7270         };
7271         return ThrottleSubscriber;
7272     }(OuterSubscriber));
7273
7274     function throttleTime(duration, scheduler, config) {
7275         if (scheduler === void 0) { scheduler = async; }
7276         if (config === void 0) { config = defaultThrottleConfig; }
7277         return function (source) { return source.lift(new ThrottleTimeOperator(duration, scheduler, config.leading, config.trailing)); };
7278     }
7279     var ThrottleTimeOperator = (function () {
7280         function ThrottleTimeOperator(duration, scheduler, leading, trailing) {
7281             this.duration = duration;
7282             this.scheduler = scheduler;
7283             this.leading = leading;
7284             this.trailing = trailing;
7285         }
7286         ThrottleTimeOperator.prototype.call = function (subscriber, source) {
7287             return source.subscribe(new ThrottleTimeSubscriber(subscriber, this.duration, this.scheduler, this.leading, this.trailing));
7288         };
7289         return ThrottleTimeOperator;
7290     }());
7291     var ThrottleTimeSubscriber = (function (_super) {
7292         __extends(ThrottleTimeSubscriber, _super);
7293         function ThrottleTimeSubscriber(destination, duration, scheduler, leading, trailing) {
7294             var _this = _super.call(this, destination) || this;
7295             _this.duration = duration;
7296             _this.scheduler = scheduler;
7297             _this.leading = leading;
7298             _this.trailing = trailing;
7299             _this._hasTrailingValue = false;
7300             _this._trailingValue = null;
7301             return _this;
7302         }
7303         ThrottleTimeSubscriber.prototype._next = function (value) {
7304             if (this.throttled) {
7305                 if (this.trailing) {
7306                     this._trailingValue = value;
7307                     this._hasTrailingValue = true;
7308                 }
7309             }
7310             else {
7311                 this.add(this.throttled = this.scheduler.schedule(dispatchNext$3, this.duration, { subscriber: this }));
7312                 if (this.leading) {
7313                     this.destination.next(value);
7314                 }
7315                 else if (this.trailing) {
7316                     this._trailingValue = value;
7317                     this._hasTrailingValue = true;
7318                 }
7319             }
7320         };
7321         ThrottleTimeSubscriber.prototype._complete = function () {
7322             if (this._hasTrailingValue) {
7323                 this.destination.next(this._trailingValue);
7324                 this.destination.complete();
7325             }
7326             else {
7327                 this.destination.complete();
7328             }
7329         };
7330         ThrottleTimeSubscriber.prototype.clearThrottle = function () {
7331             var throttled = this.throttled;
7332             if (throttled) {
7333                 if (this.trailing && this._hasTrailingValue) {
7334                     this.destination.next(this._trailingValue);
7335                     this._trailingValue = null;
7336                     this._hasTrailingValue = false;
7337                 }
7338                 throttled.unsubscribe();
7339                 this.remove(throttled);
7340                 this.throttled = null;
7341             }
7342         };
7343         return ThrottleTimeSubscriber;
7344     }(Subscriber));
7345     function dispatchNext$3(arg) {
7346         var subscriber = arg.subscriber;
7347         subscriber.clearThrottle();
7348     }
7349
7350     function timeInterval(scheduler) {
7351         if (scheduler === void 0) { scheduler = async; }
7352         return function (source) { return defer(function () {
7353             return source.pipe(scan(function (_a, value) {
7354                 var current = _a.current;
7355                 return ({ value: value, current: scheduler.now(), last: current });
7356             }, { current: scheduler.now(), value: undefined, last: undefined }), map(function (_a) {
7357                 var current = _a.current, last = _a.last, value = _a.value;
7358                 return new TimeInterval(value, current - last);
7359             }));
7360         }); };
7361     }
7362     var TimeInterval = (function () {
7363         function TimeInterval(value, interval) {
7364             this.value = value;
7365             this.interval = interval;
7366         }
7367         return TimeInterval;
7368     }());
7369
7370     function timeoutWith(due, withObservable, scheduler) {
7371         if (scheduler === void 0) { scheduler = async; }
7372         return function (source) {
7373             var absoluteTimeout = isDate(due);
7374             var waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(due);
7375             return source.lift(new TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler));
7376         };
7377     }
7378     var TimeoutWithOperator = (function () {
7379         function TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler) {
7380             this.waitFor = waitFor;
7381             this.absoluteTimeout = absoluteTimeout;
7382             this.withObservable = withObservable;
7383             this.scheduler = scheduler;
7384         }
7385         TimeoutWithOperator.prototype.call = function (subscriber, source) {
7386             return source.subscribe(new TimeoutWithSubscriber(subscriber, this.absoluteTimeout, this.waitFor, this.withObservable, this.scheduler));
7387         };
7388         return TimeoutWithOperator;
7389     }());
7390     var TimeoutWithSubscriber = (function (_super) {
7391         __extends(TimeoutWithSubscriber, _super);
7392         function TimeoutWithSubscriber(destination, absoluteTimeout, waitFor, withObservable, scheduler) {
7393             var _this = _super.call(this, destination) || this;
7394             _this.absoluteTimeout = absoluteTimeout;
7395             _this.waitFor = waitFor;
7396             _this.withObservable = withObservable;
7397             _this.scheduler = scheduler;
7398             _this.action = null;
7399             _this.scheduleTimeout();
7400             return _this;
7401         }
7402         TimeoutWithSubscriber.dispatchTimeout = function (subscriber) {
7403             var withObservable = subscriber.withObservable;
7404             subscriber._unsubscribeAndRecycle();
7405             subscriber.add(subscribeToResult(subscriber, withObservable));
7406         };
7407         TimeoutWithSubscriber.prototype.scheduleTimeout = function () {
7408             var action = this.action;
7409             if (action) {
7410                 this.action = action.schedule(this, this.waitFor);
7411             }
7412             else {
7413                 this.add(this.action = this.scheduler.schedule(TimeoutWithSubscriber.dispatchTimeout, this.waitFor, this));
7414             }
7415         };
7416         TimeoutWithSubscriber.prototype._next = function (value) {
7417             if (!this.absoluteTimeout) {
7418                 this.scheduleTimeout();
7419             }
7420             _super.prototype._next.call(this, value);
7421         };
7422         TimeoutWithSubscriber.prototype._unsubscribe = function () {
7423             this.action = null;
7424             this.scheduler = null;
7425             this.withObservable = null;
7426         };
7427         return TimeoutWithSubscriber;
7428     }(OuterSubscriber));
7429
7430     function timeout(due, scheduler) {
7431         if (scheduler === void 0) { scheduler = async; }
7432         return timeoutWith(due, throwError(new TimeoutError()), scheduler);
7433     }
7434
7435     function timestamp(scheduler) {
7436         if (scheduler === void 0) { scheduler = async; }
7437         return map(function (value) { return new Timestamp(value, scheduler.now()); });
7438     }
7439     var Timestamp = (function () {
7440         function Timestamp(value, timestamp) {
7441             this.value = value;
7442             this.timestamp = timestamp;
7443         }
7444         return Timestamp;
7445     }());
7446
7447     function toArrayReducer(arr, item, index) {
7448         if (index === 0) {
7449             return [item];
7450         }
7451         arr.push(item);
7452         return arr;
7453     }
7454     function toArray() {
7455         return reduce(toArrayReducer, []);
7456     }
7457
7458     function window$1(windowBoundaries) {
7459         return function windowOperatorFunction(source) {
7460             return source.lift(new WindowOperator(windowBoundaries));
7461         };
7462     }
7463     var WindowOperator = (function () {
7464         function WindowOperator(windowBoundaries) {
7465             this.windowBoundaries = windowBoundaries;
7466         }
7467         WindowOperator.prototype.call = function (subscriber, source) {
7468             var windowSubscriber = new WindowSubscriber(subscriber);
7469             var sourceSubscription = source.subscribe(windowSubscriber);
7470             if (!sourceSubscription.closed) {
7471                 windowSubscriber.add(subscribeToResult(windowSubscriber, this.windowBoundaries));
7472             }
7473             return sourceSubscription;
7474         };
7475         return WindowOperator;
7476     }());
7477     var WindowSubscriber = (function (_super) {
7478         __extends(WindowSubscriber, _super);
7479         function WindowSubscriber(destination) {
7480             var _this = _super.call(this, destination) || this;
7481             _this.window = new Subject();
7482             destination.next(_this.window);
7483             return _this;
7484         }
7485         WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7486             this.openWindow();
7487         };
7488         WindowSubscriber.prototype.notifyError = function (error, innerSub) {
7489             this._error(error);
7490         };
7491         WindowSubscriber.prototype.notifyComplete = function (innerSub) {
7492             this._complete();
7493         };
7494         WindowSubscriber.prototype._next = function (value) {
7495             this.window.next(value);
7496         };
7497         WindowSubscriber.prototype._error = function (err) {
7498             this.window.error(err);
7499             this.destination.error(err);
7500         };
7501         WindowSubscriber.prototype._complete = function () {
7502             this.window.complete();
7503             this.destination.complete();
7504         };
7505         WindowSubscriber.prototype._unsubscribe = function () {
7506             this.window = null;
7507         };
7508         WindowSubscriber.prototype.openWindow = function () {
7509             var prevWindow = this.window;
7510             if (prevWindow) {
7511                 prevWindow.complete();
7512             }
7513             var destination = this.destination;
7514             var newWindow = this.window = new Subject();
7515             destination.next(newWindow);
7516         };
7517         return WindowSubscriber;
7518     }(OuterSubscriber));
7519
7520     function windowCount(windowSize, startWindowEvery) {
7521         if (startWindowEvery === void 0) { startWindowEvery = 0; }
7522         return function windowCountOperatorFunction(source) {
7523             return source.lift(new WindowCountOperator(windowSize, startWindowEvery));
7524         };
7525     }
7526     var WindowCountOperator = (function () {
7527         function WindowCountOperator(windowSize, startWindowEvery) {
7528             this.windowSize = windowSize;
7529             this.startWindowEvery = startWindowEvery;
7530         }
7531         WindowCountOperator.prototype.call = function (subscriber, source) {
7532             return source.subscribe(new WindowCountSubscriber(subscriber, this.windowSize, this.startWindowEvery));
7533         };
7534         return WindowCountOperator;
7535     }());
7536     var WindowCountSubscriber = (function (_super) {
7537         __extends(WindowCountSubscriber, _super);
7538         function WindowCountSubscriber(destination, windowSize, startWindowEvery) {
7539             var _this = _super.call(this, destination) || this;
7540             _this.destination = destination;
7541             _this.windowSize = windowSize;
7542             _this.startWindowEvery = startWindowEvery;
7543             _this.windows = [new Subject()];
7544             _this.count = 0;
7545             destination.next(_this.windows[0]);
7546             return _this;
7547         }
7548         WindowCountSubscriber.prototype._next = function (value) {
7549             var startWindowEvery = (this.startWindowEvery > 0) ? this.startWindowEvery : this.windowSize;
7550             var destination = this.destination;
7551             var windowSize = this.windowSize;
7552             var windows = this.windows;
7553             var len = windows.length;
7554             for (var i = 0; i < len && !this.closed; i++) {
7555                 windows[i].next(value);
7556             }
7557             var c = this.count - windowSize + 1;
7558             if (c >= 0 && c % startWindowEvery === 0 && !this.closed) {
7559                 windows.shift().complete();
7560             }
7561             if (++this.count % startWindowEvery === 0 && !this.closed) {
7562                 var window_1 = new Subject();
7563                 windows.push(window_1);
7564                 destination.next(window_1);
7565             }
7566         };
7567         WindowCountSubscriber.prototype._error = function (err) {
7568             var windows = this.windows;
7569             if (windows) {
7570                 while (windows.length > 0 && !this.closed) {
7571                     windows.shift().error(err);
7572                 }
7573             }
7574             this.destination.error(err);
7575         };
7576         WindowCountSubscriber.prototype._complete = function () {
7577             var windows = this.windows;
7578             if (windows) {
7579                 while (windows.length > 0 && !this.closed) {
7580                     windows.shift().complete();
7581                 }
7582             }
7583             this.destination.complete();
7584         };
7585         WindowCountSubscriber.prototype._unsubscribe = function () {
7586             this.count = 0;
7587             this.windows = null;
7588         };
7589         return WindowCountSubscriber;
7590     }(Subscriber));
7591
7592     function windowTime(windowTimeSpan) {
7593         var scheduler = async;
7594         var windowCreationInterval = null;
7595         var maxWindowSize = Number.POSITIVE_INFINITY;
7596         if (isScheduler(arguments[3])) {
7597             scheduler = arguments[3];
7598         }
7599         if (isScheduler(arguments[2])) {
7600             scheduler = arguments[2];
7601         }
7602         else if (isNumeric(arguments[2])) {
7603             maxWindowSize = Number(arguments[2]);
7604         }
7605         if (isScheduler(arguments[1])) {
7606             scheduler = arguments[1];
7607         }
7608         else if (isNumeric(arguments[1])) {
7609             windowCreationInterval = Number(arguments[1]);
7610         }
7611         return function windowTimeOperatorFunction(source) {
7612             return source.lift(new WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler));
7613         };
7614     }
7615     var WindowTimeOperator = (function () {
7616         function WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
7617             this.windowTimeSpan = windowTimeSpan;
7618             this.windowCreationInterval = windowCreationInterval;
7619             this.maxWindowSize = maxWindowSize;
7620             this.scheduler = scheduler;
7621         }
7622         WindowTimeOperator.prototype.call = function (subscriber, source) {
7623             return source.subscribe(new WindowTimeSubscriber(subscriber, this.windowTimeSpan, this.windowCreationInterval, this.maxWindowSize, this.scheduler));
7624         };
7625         return WindowTimeOperator;
7626     }());
7627     var CountedSubject = (function (_super) {
7628         __extends(CountedSubject, _super);
7629         function CountedSubject() {
7630             var _this = _super !== null && _super.apply(this, arguments) || this;
7631             _this._numberOfNextedValues = 0;
7632             return _this;
7633         }
7634         CountedSubject.prototype.next = function (value) {
7635             this._numberOfNextedValues++;
7636             _super.prototype.next.call(this, value);
7637         };
7638         Object.defineProperty(CountedSubject.prototype, "numberOfNextedValues", {
7639             get: function () {
7640                 return this._numberOfNextedValues;
7641             },
7642             enumerable: true,
7643             configurable: true
7644         });
7645         return CountedSubject;
7646     }(Subject));
7647     var WindowTimeSubscriber = (function (_super) {
7648         __extends(WindowTimeSubscriber, _super);
7649         function WindowTimeSubscriber(destination, windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
7650             var _this = _super.call(this, destination) || this;
7651             _this.destination = destination;
7652             _this.windowTimeSpan = windowTimeSpan;
7653             _this.windowCreationInterval = windowCreationInterval;
7654             _this.maxWindowSize = maxWindowSize;
7655             _this.scheduler = scheduler;
7656             _this.windows = [];
7657             var window = _this.openWindow();
7658             if (windowCreationInterval !== null && windowCreationInterval >= 0) {
7659                 var closeState = { subscriber: _this, window: window, context: null };
7660                 var creationState = { windowTimeSpan: windowTimeSpan, windowCreationInterval: windowCreationInterval, subscriber: _this, scheduler: scheduler };
7661                 _this.add(scheduler.schedule(dispatchWindowClose, windowTimeSpan, closeState));
7662                 _this.add(scheduler.schedule(dispatchWindowCreation, windowCreationInterval, creationState));
7663             }
7664             else {
7665                 var timeSpanOnlyState = { subscriber: _this, window: window, windowTimeSpan: windowTimeSpan };
7666                 _this.add(scheduler.schedule(dispatchWindowTimeSpanOnly, windowTimeSpan, timeSpanOnlyState));
7667             }
7668             return _this;
7669         }
7670         WindowTimeSubscriber.prototype._next = function (value) {
7671             var windows = this.windows;
7672             var len = windows.length;
7673             for (var i = 0; i < len; i++) {
7674                 var window_1 = windows[i];
7675                 if (!window_1.closed) {
7676                     window_1.next(value);
7677                     if (window_1.numberOfNextedValues >= this.maxWindowSize) {
7678                         this.closeWindow(window_1);
7679                     }
7680                 }
7681             }
7682         };
7683         WindowTimeSubscriber.prototype._error = function (err) {
7684             var windows = this.windows;
7685             while (windows.length > 0) {
7686                 windows.shift().error(err);
7687             }
7688             this.destination.error(err);
7689         };
7690         WindowTimeSubscriber.prototype._complete = function () {
7691             var windows = this.windows;
7692             while (windows.length > 0) {
7693                 var window_2 = windows.shift();
7694                 if (!window_2.closed) {
7695                     window_2.complete();
7696                 }
7697             }
7698             this.destination.complete();
7699         };
7700         WindowTimeSubscriber.prototype.openWindow = function () {
7701             var window = new CountedSubject();
7702             this.windows.push(window);
7703             var destination = this.destination;
7704             destination.next(window);
7705             return window;
7706         };
7707         WindowTimeSubscriber.prototype.closeWindow = function (window) {
7708             window.complete();
7709             var windows = this.windows;
7710             windows.splice(windows.indexOf(window), 1);
7711         };
7712         return WindowTimeSubscriber;
7713     }(Subscriber));
7714     function dispatchWindowTimeSpanOnly(state) {
7715         var subscriber = state.subscriber, windowTimeSpan = state.windowTimeSpan, window = state.window;
7716         if (window) {
7717             subscriber.closeWindow(window);
7718         }
7719         state.window = subscriber.openWindow();
7720         this.schedule(state, windowTimeSpan);
7721     }
7722     function dispatchWindowCreation(state) {
7723         var windowTimeSpan = state.windowTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler, windowCreationInterval = state.windowCreationInterval;
7724         var window = subscriber.openWindow();
7725         var action = this;
7726         var context = { action: action, subscription: null };
7727         var timeSpanState = { subscriber: subscriber, window: window, context: context };
7728         context.subscription = scheduler.schedule(dispatchWindowClose, windowTimeSpan, timeSpanState);
7729         action.add(context.subscription);
7730         action.schedule(state, windowCreationInterval);
7731     }
7732     function dispatchWindowClose(state) {
7733         var subscriber = state.subscriber, window = state.window, context = state.context;
7734         if (context && context.action && context.subscription) {
7735             context.action.remove(context.subscription);
7736         }
7737         subscriber.closeWindow(window);
7738     }
7739
7740     function windowToggle(openings, closingSelector) {
7741         return function (source) { return source.lift(new WindowToggleOperator(openings, closingSelector)); };
7742     }
7743     var WindowToggleOperator = (function () {
7744         function WindowToggleOperator(openings, closingSelector) {
7745             this.openings = openings;
7746             this.closingSelector = closingSelector;
7747         }
7748         WindowToggleOperator.prototype.call = function (subscriber, source) {
7749             return source.subscribe(new WindowToggleSubscriber(subscriber, this.openings, this.closingSelector));
7750         };
7751         return WindowToggleOperator;
7752     }());
7753     var WindowToggleSubscriber = (function (_super) {
7754         __extends(WindowToggleSubscriber, _super);
7755         function WindowToggleSubscriber(destination, openings, closingSelector) {
7756             var _this = _super.call(this, destination) || this;
7757             _this.openings = openings;
7758             _this.closingSelector = closingSelector;
7759             _this.contexts = [];
7760             _this.add(_this.openSubscription = subscribeToResult(_this, openings, openings));
7761             return _this;
7762         }
7763         WindowToggleSubscriber.prototype._next = function (value) {
7764             var contexts = this.contexts;
7765             if (contexts) {
7766                 var len = contexts.length;
7767                 for (var i = 0; i < len; i++) {
7768                     contexts[i].window.next(value);
7769                 }
7770             }
7771         };
7772         WindowToggleSubscriber.prototype._error = function (err) {
7773             var contexts = this.contexts;
7774             this.contexts = null;
7775             if (contexts) {
7776                 var len = contexts.length;
7777                 var index = -1;
7778                 while (++index < len) {
7779                     var context_1 = contexts[index];
7780                     context_1.window.error(err);
7781                     context_1.subscription.unsubscribe();
7782                 }
7783             }
7784             _super.prototype._error.call(this, err);
7785         };
7786         WindowToggleSubscriber.prototype._complete = function () {
7787             var contexts = this.contexts;
7788             this.contexts = null;
7789             if (contexts) {
7790                 var len = contexts.length;
7791                 var index = -1;
7792                 while (++index < len) {
7793                     var context_2 = contexts[index];
7794                     context_2.window.complete();
7795                     context_2.subscription.unsubscribe();
7796                 }
7797             }
7798             _super.prototype._complete.call(this);
7799         };
7800         WindowToggleSubscriber.prototype._unsubscribe = function () {
7801             var contexts = this.contexts;
7802             this.contexts = null;
7803             if (contexts) {
7804                 var len = contexts.length;
7805                 var index = -1;
7806                 while (++index < len) {
7807                     var context_3 = contexts[index];
7808                     context_3.window.unsubscribe();
7809                     context_3.subscription.unsubscribe();
7810                 }
7811             }
7812         };
7813         WindowToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7814             if (outerValue === this.openings) {
7815                 var closingNotifier = void 0;
7816                 try {
7817                     var closingSelector = this.closingSelector;
7818                     closingNotifier = closingSelector(innerValue);
7819                 }
7820                 catch (e) {
7821                     return this.error(e);
7822                 }
7823                 var window_1 = new Subject();
7824                 var subscription = new Subscription();
7825                 var context_4 = { window: window_1, subscription: subscription };
7826                 this.contexts.push(context_4);
7827                 var innerSubscription = subscribeToResult(this, closingNotifier, context_4);
7828                 if (innerSubscription.closed) {
7829                     this.closeWindow(this.contexts.length - 1);
7830                 }
7831                 else {
7832                     innerSubscription.context = context_4;
7833                     subscription.add(innerSubscription);
7834                 }
7835                 this.destination.next(window_1);
7836             }
7837             else {
7838                 this.closeWindow(this.contexts.indexOf(outerValue));
7839             }
7840         };
7841         WindowToggleSubscriber.prototype.notifyError = function (err) {
7842             this.error(err);
7843         };
7844         WindowToggleSubscriber.prototype.notifyComplete = function (inner) {
7845             if (inner !== this.openSubscription) {
7846                 this.closeWindow(this.contexts.indexOf(inner.context));
7847             }
7848         };
7849         WindowToggleSubscriber.prototype.closeWindow = function (index) {
7850             if (index === -1) {
7851                 return;
7852             }
7853             var contexts = this.contexts;
7854             var context = contexts[index];
7855             var window = context.window, subscription = context.subscription;
7856             contexts.splice(index, 1);
7857             window.complete();
7858             subscription.unsubscribe();
7859         };
7860         return WindowToggleSubscriber;
7861     }(OuterSubscriber));
7862
7863     function windowWhen(closingSelector) {
7864         return function windowWhenOperatorFunction(source) {
7865             return source.lift(new WindowOperator$1(closingSelector));
7866         };
7867     }
7868     var WindowOperator$1 = (function () {
7869         function WindowOperator(closingSelector) {
7870             this.closingSelector = closingSelector;
7871         }
7872         WindowOperator.prototype.call = function (subscriber, source) {
7873             return source.subscribe(new WindowSubscriber$1(subscriber, this.closingSelector));
7874         };
7875         return WindowOperator;
7876     }());
7877     var WindowSubscriber$1 = (function (_super) {
7878         __extends(WindowSubscriber, _super);
7879         function WindowSubscriber(destination, closingSelector) {
7880             var _this = _super.call(this, destination) || this;
7881             _this.destination = destination;
7882             _this.closingSelector = closingSelector;
7883             _this.openWindow();
7884             return _this;
7885         }
7886         WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7887             this.openWindow(innerSub);
7888         };
7889         WindowSubscriber.prototype.notifyError = function (error, innerSub) {
7890             this._error(error);
7891         };
7892         WindowSubscriber.prototype.notifyComplete = function (innerSub) {
7893             this.openWindow(innerSub);
7894         };
7895         WindowSubscriber.prototype._next = function (value) {
7896             this.window.next(value);
7897         };
7898         WindowSubscriber.prototype._error = function (err) {
7899             this.window.error(err);
7900             this.destination.error(err);
7901             this.unsubscribeClosingNotification();
7902         };
7903         WindowSubscriber.prototype._complete = function () {
7904             this.window.complete();
7905             this.destination.complete();
7906             this.unsubscribeClosingNotification();
7907         };
7908         WindowSubscriber.prototype.unsubscribeClosingNotification = function () {
7909             if (this.closingNotification) {
7910                 this.closingNotification.unsubscribe();
7911             }
7912         };
7913         WindowSubscriber.prototype.openWindow = function (innerSub) {
7914             if (innerSub === void 0) { innerSub = null; }
7915             if (innerSub) {
7916                 this.remove(innerSub);
7917                 innerSub.unsubscribe();
7918             }
7919             var prevWindow = this.window;
7920             if (prevWindow) {
7921                 prevWindow.complete();
7922             }
7923             var window = this.window = new Subject();
7924             this.destination.next(window);
7925             var closingNotifier;
7926             try {
7927                 var closingSelector = this.closingSelector;
7928                 closingNotifier = closingSelector();
7929             }
7930             catch (e) {
7931                 this.destination.error(e);
7932                 this.window.error(e);
7933                 return;
7934             }
7935             this.add(this.closingNotification = subscribeToResult(this, closingNotifier));
7936         };
7937         return WindowSubscriber;
7938     }(OuterSubscriber));
7939
7940     function withLatestFrom() {
7941         var args = [];
7942         for (var _i = 0; _i < arguments.length; _i++) {
7943             args[_i] = arguments[_i];
7944         }
7945         return function (source) {
7946             var project;
7947             if (typeof args[args.length - 1] === 'function') {
7948                 project = args.pop();
7949             }
7950             var observables = args;
7951             return source.lift(new WithLatestFromOperator(observables, project));
7952         };
7953     }
7954     var WithLatestFromOperator = (function () {
7955         function WithLatestFromOperator(observables, project) {
7956             this.observables = observables;
7957             this.project = project;
7958         }
7959         WithLatestFromOperator.prototype.call = function (subscriber, source) {
7960             return source.subscribe(new WithLatestFromSubscriber(subscriber, this.observables, this.project));
7961         };
7962         return WithLatestFromOperator;
7963     }());
7964     var WithLatestFromSubscriber = (function (_super) {
7965         __extends(WithLatestFromSubscriber, _super);
7966         function WithLatestFromSubscriber(destination, observables, project) {
7967             var _this = _super.call(this, destination) || this;
7968             _this.observables = observables;
7969             _this.project = project;
7970             _this.toRespond = [];
7971             var len = observables.length;
7972             _this.values = new Array(len);
7973             for (var i = 0; i < len; i++) {
7974                 _this.toRespond.push(i);
7975             }
7976             for (var i = 0; i < len; i++) {
7977                 var observable = observables[i];
7978                 _this.add(subscribeToResult(_this, observable, observable, i));
7979             }
7980             return _this;
7981         }
7982         WithLatestFromSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7983             this.values[outerIndex] = innerValue;
7984             var toRespond = this.toRespond;
7985             if (toRespond.length > 0) {
7986                 var found = toRespond.indexOf(outerIndex);
7987                 if (found !== -1) {
7988                     toRespond.splice(found, 1);
7989                 }
7990             }
7991         };
7992         WithLatestFromSubscriber.prototype.notifyComplete = function () {
7993         };
7994         WithLatestFromSubscriber.prototype._next = function (value) {
7995             if (this.toRespond.length === 0) {
7996                 var args = [value].concat(this.values);
7997                 if (this.project) {
7998                     this._tryProject(args);
7999                 }
8000                 else {
8001                     this.destination.next(args);
8002                 }
8003             }
8004         };
8005         WithLatestFromSubscriber.prototype._tryProject = function (args) {
8006             var result;
8007             try {
8008                 result = this.project.apply(this, args);
8009             }
8010             catch (err) {
8011                 this.destination.error(err);
8012                 return;
8013             }
8014             this.destination.next(result);
8015         };
8016         return WithLatestFromSubscriber;
8017     }(OuterSubscriber));
8018
8019     function zip$1() {
8020         var observables = [];
8021         for (var _i = 0; _i < arguments.length; _i++) {
8022             observables[_i] = arguments[_i];
8023         }
8024         return function zipOperatorFunction(source) {
8025             return source.lift.call(zip.apply(void 0, [source].concat(observables)));
8026         };
8027     }
8028
8029     function zipAll(project) {
8030         return function (source) { return source.lift(new ZipOperator(project)); };
8031     }
8032
8033
8034
8035     var _operators = /*#__PURE__*/Object.freeze({
8036         audit: audit,
8037         auditTime: auditTime,
8038         buffer: buffer,
8039         bufferCount: bufferCount,
8040         bufferTime: bufferTime,
8041         bufferToggle: bufferToggle,
8042         bufferWhen: bufferWhen,
8043         catchError: catchError,
8044         combineAll: combineAll,
8045         combineLatest: combineLatest$1,
8046         concat: concat$1,
8047         concatAll: concatAll,
8048         concatMap: concatMap,
8049         concatMapTo: concatMapTo,
8050         count: count,
8051         debounce: debounce,
8052         debounceTime: debounceTime,
8053         defaultIfEmpty: defaultIfEmpty,
8054         delay: delay,
8055         delayWhen: delayWhen,
8056         dematerialize: dematerialize,
8057         distinct: distinct,
8058         distinctUntilChanged: distinctUntilChanged,
8059         distinctUntilKeyChanged: distinctUntilKeyChanged,
8060         elementAt: elementAt,
8061         endWith: endWith,
8062         every: every,
8063         exhaust: exhaust,
8064         exhaustMap: exhaustMap,
8065         expand: expand,
8066         filter: filter,
8067         finalize: finalize,
8068         find: find,
8069         findIndex: findIndex,
8070         first: first,
8071         groupBy: groupBy,
8072         ignoreElements: ignoreElements,
8073         isEmpty: isEmpty,
8074         last: last,
8075         map: map,
8076         mapTo: mapTo,
8077         materialize: materialize,
8078         max: max,
8079         merge: merge$1,
8080         mergeAll: mergeAll,
8081         mergeMap: mergeMap,
8082         flatMap: flatMap,
8083         mergeMapTo: mergeMapTo,
8084         mergeScan: mergeScan,
8085         min: min,
8086         multicast: multicast,
8087         observeOn: observeOn,
8088         onErrorResumeNext: onErrorResumeNext$1,
8089         pairwise: pairwise,
8090         partition: partition$1,
8091         pluck: pluck,
8092         publish: publish,
8093         publishBehavior: publishBehavior,
8094         publishLast: publishLast,
8095         publishReplay: publishReplay,
8096         race: race$1,
8097         reduce: reduce,
8098         repeat: repeat,
8099         repeatWhen: repeatWhen,
8100         retry: retry,
8101         retryWhen: retryWhen,
8102         refCount: refCount,
8103         sample: sample,
8104         sampleTime: sampleTime,
8105         scan: scan,
8106         sequenceEqual: sequenceEqual,
8107         share: share,
8108         shareReplay: shareReplay,
8109         single: single,
8110         skip: skip,
8111         skipLast: skipLast,
8112         skipUntil: skipUntil,
8113         skipWhile: skipWhile,
8114         startWith: startWith,
8115         subscribeOn: subscribeOn,
8116         switchAll: switchAll,
8117         switchMap: switchMap,
8118         switchMapTo: switchMapTo,
8119         take: take,
8120         takeLast: takeLast,
8121         takeUntil: takeUntil,
8122         takeWhile: takeWhile,
8123         tap: tap,
8124         throttle: throttle,
8125         throttleTime: throttleTime,
8126         throwIfEmpty: throwIfEmpty,
8127         timeInterval: timeInterval,
8128         timeout: timeout,
8129         timeoutWith: timeoutWith,
8130         timestamp: timestamp,
8131         toArray: toArray,
8132         window: window$1,
8133         windowCount: windowCount,
8134         windowTime: windowTime,
8135         windowToggle: windowToggle,
8136         windowWhen: windowWhen,
8137         withLatestFrom: withLatestFrom,
8138         zip: zip$1,
8139         zipAll: zipAll
8140     });
8141
8142     var SubscriptionLog = (function () {
8143         function SubscriptionLog(subscribedFrame, unsubscribedFrame) {
8144             if (unsubscribedFrame === void 0) { unsubscribedFrame = Number.POSITIVE_INFINITY; }
8145             this.subscribedFrame = subscribedFrame;
8146             this.unsubscribedFrame = unsubscribedFrame;
8147         }
8148         return SubscriptionLog;
8149     }());
8150
8151     var SubscriptionLoggable = (function () {
8152         function SubscriptionLoggable() {
8153             this.subscriptions = [];
8154         }
8155         SubscriptionLoggable.prototype.logSubscribedFrame = function () {
8156             this.subscriptions.push(new SubscriptionLog(this.scheduler.now()));
8157             return this.subscriptions.length - 1;
8158         };
8159         SubscriptionLoggable.prototype.logUnsubscribedFrame = function (index) {
8160             var subscriptionLogs = this.subscriptions;
8161             var oldSubscriptionLog = subscriptionLogs[index];
8162             subscriptionLogs[index] = new SubscriptionLog(oldSubscriptionLog.subscribedFrame, this.scheduler.now());
8163         };
8164         return SubscriptionLoggable;
8165     }());
8166
8167     function applyMixins(derivedCtor, baseCtors) {
8168         for (var i = 0, len = baseCtors.length; i < len; i++) {
8169             var baseCtor = baseCtors[i];
8170             var propertyKeys = Object.getOwnPropertyNames(baseCtor.prototype);
8171             for (var j = 0, len2 = propertyKeys.length; j < len2; j++) {
8172                 var name_1 = propertyKeys[j];
8173                 derivedCtor.prototype[name_1] = baseCtor.prototype[name_1];
8174             }
8175         }
8176     }
8177
8178     var ColdObservable = (function (_super) {
8179         __extends(ColdObservable, _super);
8180         function ColdObservable(messages, scheduler) {
8181             var _this = _super.call(this, function (subscriber) {
8182                 var observable = this;
8183                 var index = observable.logSubscribedFrame();
8184                 var subscription = new Subscription();
8185                 subscription.add(new Subscription(function () {
8186                     observable.logUnsubscribedFrame(index);
8187                 }));
8188                 observable.scheduleMessages(subscriber);
8189                 return subscription;
8190             }) || this;
8191             _this.messages = messages;
8192             _this.subscriptions = [];
8193             _this.scheduler = scheduler;
8194             return _this;
8195         }
8196         ColdObservable.prototype.scheduleMessages = function (subscriber) {
8197             var messagesLength = this.messages.length;
8198             for (var i = 0; i < messagesLength; i++) {
8199                 var message = this.messages[i];
8200                 subscriber.add(this.scheduler.schedule(function (_a) {
8201                     var message = _a.message, subscriber = _a.subscriber;
8202                     message.notification.observe(subscriber);
8203                 }, message.frame, { message: message, subscriber: subscriber }));
8204             }
8205         };
8206         return ColdObservable;
8207     }(Observable));
8208     applyMixins(ColdObservable, [SubscriptionLoggable]);
8209
8210     var HotObservable = (function (_super) {
8211         __extends(HotObservable, _super);
8212         function HotObservable(messages, scheduler) {
8213             var _this = _super.call(this) || this;
8214             _this.messages = messages;
8215             _this.subscriptions = [];
8216             _this.scheduler = scheduler;
8217             return _this;
8218         }
8219         HotObservable.prototype._subscribe = function (subscriber) {
8220             var subject = this;
8221             var index = subject.logSubscribedFrame();
8222             var subscription = new Subscription();
8223             subscription.add(new Subscription(function () {
8224                 subject.logUnsubscribedFrame(index);
8225             }));
8226             subscription.add(_super.prototype._subscribe.call(this, subscriber));
8227             return subscription;
8228         };
8229         HotObservable.prototype.setup = function () {
8230             var subject = this;
8231             var messagesLength = subject.messages.length;
8232             for (var i = 0; i < messagesLength; i++) {
8233                 (function () {
8234                     var message = subject.messages[i];
8235                     subject.scheduler.schedule(function () { message.notification.observe(subject); }, message.frame);
8236                 })();
8237             }
8238         };
8239         return HotObservable;
8240     }(Subject));
8241     applyMixins(HotObservable, [SubscriptionLoggable]);
8242
8243     var defaultMaxFrame = 750;
8244     var TestScheduler = (function (_super) {
8245         __extends(TestScheduler, _super);
8246         function TestScheduler(assertDeepEqual) {
8247             var _this = _super.call(this, VirtualAction, defaultMaxFrame) || this;
8248             _this.assertDeepEqual = assertDeepEqual;
8249             _this.hotObservables = [];
8250             _this.coldObservables = [];
8251             _this.flushTests = [];
8252             _this.runMode = false;
8253             return _this;
8254         }
8255         TestScheduler.prototype.createTime = function (marbles) {
8256             var indexOf = marbles.indexOf('|');
8257             if (indexOf === -1) {
8258                 throw new Error('marble diagram for time should have a completion marker "|"');
8259             }
8260             return indexOf * TestScheduler.frameTimeFactor;
8261         };
8262         TestScheduler.prototype.createColdObservable = function (marbles, values, error) {
8263             if (marbles.indexOf('^') !== -1) {
8264                 throw new Error('cold observable cannot have subscription offset "^"');
8265             }
8266             if (marbles.indexOf('!') !== -1) {
8267                 throw new Error('cold observable cannot have unsubscription marker "!"');
8268             }
8269             var messages = TestScheduler.parseMarbles(marbles, values, error, undefined, this.runMode);
8270             var cold = new ColdObservable(messages, this);
8271             this.coldObservables.push(cold);
8272             return cold;
8273         };
8274         TestScheduler.prototype.createHotObservable = function (marbles, values, error) {
8275             if (marbles.indexOf('!') !== -1) {
8276                 throw new Error('hot observable cannot have unsubscription marker "!"');
8277             }
8278             var messages = TestScheduler.parseMarbles(marbles, values, error, undefined, this.runMode);
8279             var subject = new HotObservable(messages, this);
8280             this.hotObservables.push(subject);
8281             return subject;
8282         };
8283         TestScheduler.prototype.materializeInnerObservable = function (observable, outerFrame) {
8284             var _this = this;
8285             var messages = [];
8286             observable.subscribe(function (value) {
8287                 messages.push({ frame: _this.frame - outerFrame, notification: Notification.createNext(value) });
8288             }, function (err) {
8289                 messages.push({ frame: _this.frame - outerFrame, notification: Notification.createError(err) });
8290             }, function () {
8291                 messages.push({ frame: _this.frame - outerFrame, notification: Notification.createComplete() });
8292             });
8293             return messages;
8294         };
8295         TestScheduler.prototype.expectObservable = function (observable, subscriptionMarbles) {
8296             var _this = this;
8297             if (subscriptionMarbles === void 0) { subscriptionMarbles = null; }
8298             var actual = [];
8299             var flushTest = { actual: actual, ready: false };
8300             var subscriptionParsed = TestScheduler.parseMarblesAsSubscriptions(subscriptionMarbles, this.runMode);
8301             var subscriptionFrame = subscriptionParsed.subscribedFrame === Number.POSITIVE_INFINITY ?
8302                 0 : subscriptionParsed.subscribedFrame;
8303             var unsubscriptionFrame = subscriptionParsed.unsubscribedFrame;
8304             var subscription;
8305             this.schedule(function () {
8306                 subscription = observable.subscribe(function (x) {
8307                     var value = x;
8308                     if (x instanceof Observable) {
8309                         value = _this.materializeInnerObservable(value, _this.frame);
8310                     }
8311                     actual.push({ frame: _this.frame, notification: Notification.createNext(value) });
8312                 }, function (err) {
8313                     actual.push({ frame: _this.frame, notification: Notification.createError(err) });
8314                 }, function () {
8315                     actual.push({ frame: _this.frame, notification: Notification.createComplete() });
8316                 });
8317             }, subscriptionFrame);
8318             if (unsubscriptionFrame !== Number.POSITIVE_INFINITY) {
8319                 this.schedule(function () { return subscription.unsubscribe(); }, unsubscriptionFrame);
8320             }
8321             this.flushTests.push(flushTest);
8322             var runMode = this.runMode;
8323             return {
8324                 toBe: function (marbles, values, errorValue) {
8325                     flushTest.ready = true;
8326                     flushTest.expected = TestScheduler.parseMarbles(marbles, values, errorValue, true, runMode);
8327                 }
8328             };
8329         };
8330         TestScheduler.prototype.expectSubscriptions = function (actualSubscriptionLogs) {
8331             var flushTest = { actual: actualSubscriptionLogs, ready: false };
8332             this.flushTests.push(flushTest);
8333             var runMode = this.runMode;
8334             return {
8335                 toBe: function (marbles) {
8336                     var marblesArray = (typeof marbles === 'string') ? [marbles] : marbles;
8337                     flushTest.ready = true;
8338                     flushTest.expected = marblesArray.map(function (marbles) {
8339                         return TestScheduler.parseMarblesAsSubscriptions(marbles, runMode);
8340                     });
8341                 }
8342             };
8343         };
8344         TestScheduler.prototype.flush = function () {
8345             var _this = this;
8346             var hotObservables = this.hotObservables;
8347             while (hotObservables.length > 0) {
8348                 hotObservables.shift().setup();
8349             }
8350             _super.prototype.flush.call(this);
8351             this.flushTests = this.flushTests.filter(function (test) {
8352                 if (test.ready) {
8353                     _this.assertDeepEqual(test.actual, test.expected);
8354                     return false;
8355                 }
8356                 return true;
8357             });
8358         };
8359         TestScheduler.parseMarblesAsSubscriptions = function (marbles, runMode) {
8360             var _this = this;
8361             if (runMode === void 0) { runMode = false; }
8362             if (typeof marbles !== 'string') {
8363                 return new SubscriptionLog(Number.POSITIVE_INFINITY);
8364             }
8365             var len = marbles.length;
8366             var groupStart = -1;
8367             var subscriptionFrame = Number.POSITIVE_INFINITY;
8368             var unsubscriptionFrame = Number.POSITIVE_INFINITY;
8369             var frame = 0;
8370             var _loop_1 = function (i) {
8371                 var nextFrame = frame;
8372                 var advanceFrameBy = function (count) {
8373                     nextFrame += count * _this.frameTimeFactor;
8374                 };
8375                 var c = marbles[i];
8376                 switch (c) {
8377                     case ' ':
8378                         if (!runMode) {
8379                             advanceFrameBy(1);
8380                         }
8381                         break;
8382                     case '-':
8383                         advanceFrameBy(1);
8384                         break;
8385                     case '(':
8386                         groupStart = frame;
8387                         advanceFrameBy(1);
8388                         break;
8389                     case ')':
8390                         groupStart = -1;
8391                         advanceFrameBy(1);
8392                         break;
8393                     case '^':
8394                         if (subscriptionFrame !== Number.POSITIVE_INFINITY) {
8395                             throw new Error('found a second subscription point \'^\' in a ' +
8396                                 'subscription marble diagram. There can only be one.');
8397                         }
8398                         subscriptionFrame = groupStart > -1 ? groupStart : frame;
8399                         advanceFrameBy(1);
8400                         break;
8401                     case '!':
8402                         if (unsubscriptionFrame !== Number.POSITIVE_INFINITY) {
8403                             throw new Error('found a second subscription point \'^\' in a ' +
8404                                 'subscription marble diagram. There can only be one.');
8405                         }
8406                         unsubscriptionFrame = groupStart > -1 ? groupStart : frame;
8407                         break;
8408                     default:
8409                         if (runMode && c.match(/^[0-9]$/)) {
8410                             if (i === 0 || marbles[i - 1] === ' ') {
8411                                 var buffer = marbles.slice(i);
8412                                 var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /);
8413                                 if (match) {
8414                                     i += match[0].length - 1;
8415                                     var duration = parseFloat(match[1]);
8416                                     var unit = match[2];
8417                                     var durationInMs = void 0;
8418                                     switch (unit) {
8419                                         case 'ms':
8420                                             durationInMs = duration;
8421                                             break;
8422                                         case 's':
8423                                             durationInMs = duration * 1000;
8424                                             break;
8425                                         case 'm':
8426                                             durationInMs = duration * 1000 * 60;
8427                                             break;
8428                                         default:
8429                                             break;
8430                                     }
8431                                     advanceFrameBy(durationInMs / this_1.frameTimeFactor);
8432                                     break;
8433                                 }
8434                             }
8435                         }
8436                         throw new Error('there can only be \'^\' and \'!\' markers in a ' +
8437                             'subscription marble diagram. Found instead \'' + c + '\'.');
8438                 }
8439                 frame = nextFrame;
8440                 out_i_1 = i;
8441             };
8442             var this_1 = this, out_i_1;
8443             for (var i = 0; i < len; i++) {
8444                 _loop_1(i);
8445                 i = out_i_1;
8446             }
8447             if (unsubscriptionFrame < 0) {
8448                 return new SubscriptionLog(subscriptionFrame);
8449             }
8450             else {
8451                 return new SubscriptionLog(subscriptionFrame, unsubscriptionFrame);
8452             }
8453         };
8454         TestScheduler.parseMarbles = function (marbles, values, errorValue, materializeInnerObservables, runMode) {
8455             var _this = this;
8456             if (materializeInnerObservables === void 0) { materializeInnerObservables = false; }
8457             if (runMode === void 0) { runMode = false; }
8458             if (marbles.indexOf('!') !== -1) {
8459                 throw new Error('conventional marble diagrams cannot have the ' +
8460                     'unsubscription marker "!"');
8461             }
8462             var len = marbles.length;
8463             var testMessages = [];
8464             var subIndex = runMode ? marbles.replace(/^[ ]+/, '').indexOf('^') : marbles.indexOf('^');
8465             var frame = subIndex === -1 ? 0 : (subIndex * -this.frameTimeFactor);
8466             var getValue = typeof values !== 'object' ?
8467                 function (x) { return x; } :
8468                 function (x) {
8469                     if (materializeInnerObservables && values[x] instanceof ColdObservable) {
8470                         return values[x].messages;
8471                     }
8472                     return values[x];
8473                 };
8474             var groupStart = -1;
8475             var _loop_2 = function (i) {
8476                 var nextFrame = frame;
8477                 var advanceFrameBy = function (count) {
8478                     nextFrame += count * _this.frameTimeFactor;
8479                 };
8480                 var notification = void 0;
8481                 var c = marbles[i];
8482                 switch (c) {
8483                     case ' ':
8484                         if (!runMode) {
8485                             advanceFrameBy(1);
8486                         }
8487                         break;
8488                     case '-':
8489                         advanceFrameBy(1);
8490                         break;
8491                     case '(':
8492                         groupStart = frame;
8493                         advanceFrameBy(1);
8494                         break;
8495                     case ')':
8496                         groupStart = -1;
8497                         advanceFrameBy(1);
8498                         break;
8499                     case '|':
8500                         notification = Notification.createComplete();
8501                         advanceFrameBy(1);
8502                         break;
8503                     case '^':
8504                         advanceFrameBy(1);
8505                         break;
8506                     case '#':
8507                         notification = Notification.createError(errorValue || 'error');
8508                         advanceFrameBy(1);
8509                         break;
8510                     default:
8511                         if (runMode && c.match(/^[0-9]$/)) {
8512                             if (i === 0 || marbles[i - 1] === ' ') {
8513                                 var buffer = marbles.slice(i);
8514                                 var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /);
8515                                 if (match) {
8516                                     i += match[0].length - 1;
8517                                     var duration = parseFloat(match[1]);
8518                                     var unit = match[2];
8519                                     var durationInMs = void 0;
8520                                     switch (unit) {
8521                                         case 'ms':
8522                                             durationInMs = duration;
8523                                             break;
8524                                         case 's':
8525                                             durationInMs = duration * 1000;
8526                                             break;
8527                                         case 'm':
8528                                             durationInMs = duration * 1000 * 60;
8529                                             break;
8530                                         default:
8531                                             break;
8532                                     }
8533                                     advanceFrameBy(durationInMs / this_2.frameTimeFactor);
8534                                     break;
8535                                 }
8536                             }
8537                         }
8538                         notification = Notification.createNext(getValue(c));
8539                         advanceFrameBy(1);
8540                         break;
8541                 }
8542                 if (notification) {
8543                     testMessages.push({ frame: groupStart > -1 ? groupStart : frame, notification: notification });
8544                 }
8545                 frame = nextFrame;
8546                 out_i_2 = i;
8547             };
8548             var this_2 = this, out_i_2;
8549             for (var i = 0; i < len; i++) {
8550                 _loop_2(i);
8551                 i = out_i_2;
8552             }
8553             return testMessages;
8554         };
8555         TestScheduler.prototype.run = function (callback) {
8556             var prevFrameTimeFactor = TestScheduler.frameTimeFactor;
8557             var prevMaxFrames = this.maxFrames;
8558             TestScheduler.frameTimeFactor = 1;
8559             this.maxFrames = Number.POSITIVE_INFINITY;
8560             this.runMode = true;
8561             AsyncScheduler.delegate = this;
8562             var helpers = {
8563                 cold: this.createColdObservable.bind(this),
8564                 hot: this.createHotObservable.bind(this),
8565                 flush: this.flush.bind(this),
8566                 expectObservable: this.expectObservable.bind(this),
8567                 expectSubscriptions: this.expectSubscriptions.bind(this),
8568             };
8569             try {
8570                 var ret = callback(helpers);
8571                 this.flush();
8572                 return ret;
8573             }
8574             finally {
8575                 TestScheduler.frameTimeFactor = prevFrameTimeFactor;
8576                 this.maxFrames = prevMaxFrames;
8577                 this.runMode = false;
8578                 AsyncScheduler.delegate = undefined;
8579             }
8580         };
8581         return TestScheduler;
8582     }(VirtualTimeScheduler));
8583
8584
8585
8586     var _testing = /*#__PURE__*/Object.freeze({
8587         TestScheduler: TestScheduler
8588     });
8589
8590     var __window = typeof window !== 'undefined' && window;
8591     var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
8592         self instanceof WorkerGlobalScope && self;
8593     var __global = typeof global !== 'undefined' && global;
8594     var _root = __window || __global || __self;
8595     (function () {
8596         if (!_root) {
8597             throw new Error('RxJS could not find any global context (window, self, global)');
8598         }
8599     })();
8600
8601     function getCORSRequest() {
8602         if (_root.XMLHttpRequest) {
8603             return new _root.XMLHttpRequest();
8604         }
8605         else if (!!_root.XDomainRequest) {
8606             return new _root.XDomainRequest();
8607         }
8608         else {
8609             throw new Error('CORS is not supported by your browser');
8610         }
8611     }
8612     function getXMLHttpRequest() {
8613         if (_root.XMLHttpRequest) {
8614             return new _root.XMLHttpRequest();
8615         }
8616         else {
8617             var progId = void 0;
8618             try {
8619                 var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
8620                 for (var i = 0; i < 3; i++) {
8621                     try {
8622                         progId = progIds[i];
8623                         if (new _root.ActiveXObject(progId)) {
8624                             break;
8625                         }
8626                     }
8627                     catch (e) {
8628                     }
8629                 }
8630                 return new _root.ActiveXObject(progId);
8631             }
8632             catch (e) {
8633                 throw new Error('XMLHttpRequest is not supported by your browser');
8634             }
8635         }
8636     }
8637     function ajaxGet(url, headers) {
8638         if (headers === void 0) { headers = null; }
8639         return new AjaxObservable({ method: 'GET', url: url, headers: headers });
8640     }
8641     function ajaxPost(url, body, headers) {
8642         return new AjaxObservable({ method: 'POST', url: url, body: body, headers: headers });
8643     }
8644     function ajaxDelete(url, headers) {
8645         return new AjaxObservable({ method: 'DELETE', url: url, headers: headers });
8646     }
8647     function ajaxPut(url, body, headers) {
8648         return new AjaxObservable({ method: 'PUT', url: url, body: body, headers: headers });
8649     }
8650     function ajaxPatch(url, body, headers) {
8651         return new AjaxObservable({ method: 'PATCH', url: url, body: body, headers: headers });
8652     }
8653     var mapResponse = map(function (x, index) { return x.response; });
8654     function ajaxGetJSON(url, headers) {
8655         return mapResponse(new AjaxObservable({
8656             method: 'GET',
8657             url: url,
8658             responseType: 'json',
8659             headers: headers
8660         }));
8661     }
8662     var AjaxObservable = (function (_super) {
8663         __extends(AjaxObservable, _super);
8664         function AjaxObservable(urlOrRequest) {
8665             var _this = _super.call(this) || this;
8666             var request = {
8667                 async: true,
8668                 createXHR: function () {
8669                     return this.crossDomain ? getCORSRequest() : getXMLHttpRequest();
8670                 },
8671                 crossDomain: true,
8672                 withCredentials: false,
8673                 headers: {},
8674                 method: 'GET',
8675                 responseType: 'json',
8676                 timeout: 0
8677             };
8678             if (typeof urlOrRequest === 'string') {
8679                 request.url = urlOrRequest;
8680             }
8681             else {
8682                 for (var prop in urlOrRequest) {
8683                     if (urlOrRequest.hasOwnProperty(prop)) {
8684                         request[prop] = urlOrRequest[prop];
8685                     }
8686                 }
8687             }
8688             _this.request = request;
8689             return _this;
8690         }
8691         AjaxObservable.prototype._subscribe = function (subscriber) {
8692             return new AjaxSubscriber(subscriber, this.request);
8693         };
8694         AjaxObservable.create = (function () {
8695             var create = function (urlOrRequest) {
8696                 return new AjaxObservable(urlOrRequest);
8697             };
8698             create.get = ajaxGet;
8699             create.post = ajaxPost;
8700             create.delete = ajaxDelete;
8701             create.put = ajaxPut;
8702             create.patch = ajaxPatch;
8703             create.getJSON = ajaxGetJSON;
8704             return create;
8705         })();
8706         return AjaxObservable;
8707     }(Observable));
8708     var AjaxSubscriber = (function (_super) {
8709         __extends(AjaxSubscriber, _super);
8710         function AjaxSubscriber(destination, request) {
8711             var _this = _super.call(this, destination) || this;
8712             _this.request = request;
8713             _this.done = false;
8714             var headers = request.headers = request.headers || {};
8715             if (!request.crossDomain && !_this.getHeader(headers, 'X-Requested-With')) {
8716                 headers['X-Requested-With'] = 'XMLHttpRequest';
8717             }
8718             var contentTypeHeader = _this.getHeader(headers, 'Content-Type');
8719             if (!contentTypeHeader && !(_root.FormData && request.body instanceof _root.FormData) && typeof request.body !== 'undefined') {
8720                 headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
8721             }
8722             request.body = _this.serializeBody(request.body, _this.getHeader(request.headers, 'Content-Type'));
8723             _this.send();
8724             return _this;
8725         }
8726         AjaxSubscriber.prototype.next = function (e) {
8727             this.done = true;
8728             var _a = this, xhr = _a.xhr, request = _a.request, destination = _a.destination;
8729             var result;
8730             try {
8731                 result = new AjaxResponse(e, xhr, request);
8732             }
8733             catch (err) {
8734                 return destination.error(err);
8735             }
8736             destination.next(result);
8737         };
8738         AjaxSubscriber.prototype.send = function () {
8739             var _a = this, request = _a.request, _b = _a.request, user = _b.user, method = _b.method, url = _b.url, async = _b.async, password = _b.password, headers = _b.headers, body = _b.body;
8740             try {
8741                 var xhr = this.xhr = request.createXHR();
8742                 this.setupEvents(xhr, request);
8743                 if (user) {
8744                     xhr.open(method, url, async, user, password);
8745                 }
8746                 else {
8747                     xhr.open(method, url, async);
8748                 }
8749                 if (async) {
8750                     xhr.timeout = request.timeout;
8751                     xhr.responseType = request.responseType;
8752                 }
8753                 if ('withCredentials' in xhr) {
8754                     xhr.withCredentials = !!request.withCredentials;
8755                 }
8756                 this.setHeaders(xhr, headers);
8757                 if (body) {
8758                     xhr.send(body);
8759                 }
8760                 else {
8761                     xhr.send();
8762                 }
8763             }
8764             catch (err) {
8765                 this.error(err);
8766             }
8767         };
8768         AjaxSubscriber.prototype.serializeBody = function (body, contentType) {
8769             if (!body || typeof body === 'string') {
8770                 return body;
8771             }
8772             else if (_root.FormData && body instanceof _root.FormData) {
8773                 return body;
8774             }
8775             if (contentType) {
8776                 var splitIndex = contentType.indexOf(';');
8777                 if (splitIndex !== -1) {
8778                     contentType = contentType.substring(0, splitIndex);
8779                 }
8780             }
8781             switch (contentType) {
8782                 case 'application/x-www-form-urlencoded':
8783                     return Object.keys(body).map(function (key) { return encodeURIComponent(key) + "=" + encodeURIComponent(body[key]); }).join('&');
8784                 case 'application/json':
8785                     return JSON.stringify(body);
8786                 default:
8787                     return body;
8788             }
8789         };
8790         AjaxSubscriber.prototype.setHeaders = function (xhr, headers) {
8791             for (var key in headers) {
8792                 if (headers.hasOwnProperty(key)) {
8793                     xhr.setRequestHeader(key, headers[key]);
8794                 }
8795             }
8796         };
8797         AjaxSubscriber.prototype.getHeader = function (headers, headerName) {
8798             for (var key in headers) {
8799                 if (key.toLowerCase() === headerName.toLowerCase()) {
8800                     return headers[key];
8801                 }
8802             }
8803             return undefined;
8804         };
8805         AjaxSubscriber.prototype.setupEvents = function (xhr, request) {
8806             var progressSubscriber = request.progressSubscriber;
8807             function xhrTimeout(e) {
8808                 var _a = xhrTimeout, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request;
8809                 if (progressSubscriber) {
8810                     progressSubscriber.error(e);
8811                 }
8812                 var error;
8813                 try {
8814                     error = new AjaxTimeoutError(this, request);
8815                 }
8816                 catch (err) {
8817                     error = err;
8818                 }
8819                 subscriber.error(error);
8820             }
8821             xhr.ontimeout = xhrTimeout;
8822             xhrTimeout.request = request;
8823             xhrTimeout.subscriber = this;
8824             xhrTimeout.progressSubscriber = progressSubscriber;
8825             if (xhr.upload && 'withCredentials' in xhr) {
8826                 if (progressSubscriber) {
8827                     var xhrProgress_1;
8828                     xhrProgress_1 = function (e) {
8829                         var progressSubscriber = xhrProgress_1.progressSubscriber;
8830                         progressSubscriber.next(e);
8831                     };
8832                     if (_root.XDomainRequest) {
8833                         xhr.onprogress = xhrProgress_1;
8834                     }
8835                     else {
8836                         xhr.upload.onprogress = xhrProgress_1;
8837                     }
8838                     xhrProgress_1.progressSubscriber = progressSubscriber;
8839                 }
8840                 var xhrError_1;
8841                 xhrError_1 = function (e) {
8842                     var _a = xhrError_1, progressSubscriber = _a.progressSubscriber, subscriber = _a.subscriber, request = _a.request;
8843                     if (progressSubscriber) {
8844                         progressSubscriber.error(e);
8845                     }
8846                     var error;
8847                     try {
8848                         error = new AjaxError('ajax error', this, request);
8849                     }
8850                     catch (err) {
8851                         error = err;
8852                     }
8853                     subscriber.error(error);
8854                 };
8855                 xhr.onerror = xhrError_1;
8856                 xhrError_1.request = request;
8857                 xhrError_1.subscriber = this;
8858                 xhrError_1.progressSubscriber = progressSubscriber;
8859             }
8860             function xhrReadyStateChange(e) {
8861                 return;
8862             }
8863             xhr.onreadystatechange = xhrReadyStateChange;
8864             xhrReadyStateChange.subscriber = this;
8865             xhrReadyStateChange.progressSubscriber = progressSubscriber;
8866             xhrReadyStateChange.request = request;
8867             function xhrLoad(e) {
8868                 var _a = xhrLoad, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request;
8869                 if (this.readyState === 4) {
8870                     var status_1 = this.status === 1223 ? 204 : this.status;
8871                     var response = (this.responseType === 'text' ? (this.response || this.responseText) : this.response);
8872                     if (status_1 === 0) {
8873                         status_1 = response ? 200 : 0;
8874                     }
8875                     if (status_1 < 400) {
8876                         if (progressSubscriber) {
8877                             progressSubscriber.complete();
8878                         }
8879                         subscriber.next(e);
8880                         subscriber.complete();
8881                     }
8882                     else {
8883                         if (progressSubscriber) {
8884                             progressSubscriber.error(e);
8885                         }
8886                         var error = void 0;
8887                         try {
8888                             error = new AjaxError('ajax error ' + status_1, this, request);
8889                         }
8890                         catch (err) {
8891                             error = err;
8892                         }
8893                         subscriber.error(error);
8894                     }
8895                 }
8896             }
8897             xhr.onload = xhrLoad;
8898             xhrLoad.subscriber = this;
8899             xhrLoad.progressSubscriber = progressSubscriber;
8900             xhrLoad.request = request;
8901         };
8902         AjaxSubscriber.prototype.unsubscribe = function () {
8903             var _a = this, done = _a.done, xhr = _a.xhr;
8904             if (!done && xhr && xhr.readyState !== 4 && typeof xhr.abort === 'function') {
8905                 xhr.abort();
8906             }
8907             _super.prototype.unsubscribe.call(this);
8908         };
8909         return AjaxSubscriber;
8910     }(Subscriber));
8911     var AjaxResponse = (function () {
8912         function AjaxResponse(originalEvent, xhr, request) {
8913             this.originalEvent = originalEvent;
8914             this.xhr = xhr;
8915             this.request = request;
8916             this.status = xhr.status;
8917             this.responseType = xhr.responseType || request.responseType;
8918             this.response = parseXhrResponse(this.responseType, xhr);
8919         }
8920         return AjaxResponse;
8921     }());
8922     var AjaxErrorImpl = (function () {
8923         function AjaxErrorImpl(message, xhr, request) {
8924             Error.call(this);
8925             this.message = message;
8926             this.name = 'AjaxError';
8927             this.xhr = xhr;
8928             this.request = request;
8929             this.status = xhr.status;
8930             this.responseType = xhr.responseType || request.responseType;
8931             this.response = parseXhrResponse(this.responseType, xhr);
8932             return this;
8933         }
8934         AjaxErrorImpl.prototype = Object.create(Error.prototype);
8935         return AjaxErrorImpl;
8936     })();
8937     var AjaxError = AjaxErrorImpl;
8938     function parseJson(xhr) {
8939         if ('response' in xhr) {
8940             return xhr.responseType ? xhr.response : JSON.parse(xhr.response || xhr.responseText || 'null');
8941         }
8942         else {
8943             return JSON.parse(xhr.responseText || 'null');
8944         }
8945     }
8946     function parseXhrResponse(responseType, xhr) {
8947         switch (responseType) {
8948             case 'json':
8949                 return parseJson(xhr);
8950             case 'xml':
8951                 return xhr.responseXML;
8952             case 'text':
8953             default:
8954                 return ('response' in xhr) ? xhr.response : xhr.responseText;
8955         }
8956     }
8957     function AjaxTimeoutErrorImpl(xhr, request) {
8958         AjaxError.call(this, 'ajax timeout', xhr, request);
8959         this.name = 'AjaxTimeoutError';
8960         return this;
8961     }
8962     var AjaxTimeoutError = AjaxTimeoutErrorImpl;
8963
8964     var ajax = (function () { return AjaxObservable.create; })();
8965
8966
8967
8968     var _ajax = /*#__PURE__*/Object.freeze({
8969         ajax: ajax,
8970         AjaxResponse: AjaxResponse,
8971         AjaxError: AjaxError,
8972         AjaxTimeoutError: AjaxTimeoutError
8973     });
8974
8975     var DEFAULT_WEBSOCKET_CONFIG = {
8976         url: '',
8977         deserializer: function (e) { return JSON.parse(e.data); },
8978         serializer: function (value) { return JSON.stringify(value); },
8979     };
8980     var WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT = 'WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }';
8981     var WebSocketSubject = (function (_super) {
8982         __extends(WebSocketSubject, _super);
8983         function WebSocketSubject(urlConfigOrSource, destination) {
8984             var _this = _super.call(this) || this;
8985             if (urlConfigOrSource instanceof Observable) {
8986                 _this.destination = destination;
8987                 _this.source = urlConfigOrSource;
8988             }
8989             else {
8990                 var config = _this._config = __assign({}, DEFAULT_WEBSOCKET_CONFIG);
8991                 _this._output = new Subject();
8992                 if (typeof urlConfigOrSource === 'string') {
8993                     config.url = urlConfigOrSource;
8994                 }
8995                 else {
8996                     for (var key in urlConfigOrSource) {
8997                         if (urlConfigOrSource.hasOwnProperty(key)) {
8998                             config[key] = urlConfigOrSource[key];
8999                         }
9000                     }
9001                 }
9002                 if (!config.WebSocketCtor && WebSocket) {
9003                     config.WebSocketCtor = WebSocket;
9004                 }
9005                 else if (!config.WebSocketCtor) {
9006                     throw new Error('no WebSocket constructor can be found');
9007                 }
9008                 _this.destination = new ReplaySubject();
9009             }
9010             return _this;
9011         }
9012         WebSocketSubject.prototype.lift = function (operator) {
9013             var sock = new WebSocketSubject(this._config, this.destination);
9014             sock.operator = operator;
9015             sock.source = this;
9016             return sock;
9017         };
9018         WebSocketSubject.prototype._resetState = function () {
9019             this._socket = null;
9020             if (!this.source) {
9021                 this.destination = new ReplaySubject();
9022             }
9023             this._output = new Subject();
9024         };
9025         WebSocketSubject.prototype.multiplex = function (subMsg, unsubMsg, messageFilter) {
9026             var self = this;
9027             return new Observable(function (observer) {
9028                 try {
9029                     self.next(subMsg());
9030                 }
9031                 catch (err) {
9032                     observer.error(err);
9033                 }
9034                 var subscription = self.subscribe(function (x) {
9035                     try {
9036                         if (messageFilter(x)) {
9037                             observer.next(x);
9038                         }
9039                     }
9040                     catch (err) {
9041                         observer.error(err);
9042                     }
9043                 }, function (err) { return observer.error(err); }, function () { return observer.complete(); });
9044                 return function () {
9045                     try {
9046                         self.next(unsubMsg());
9047                     }
9048                     catch (err) {
9049                         observer.error(err);
9050                     }
9051                     subscription.unsubscribe();
9052                 };
9053             });
9054         };
9055         WebSocketSubject.prototype._connectSocket = function () {
9056             var _this = this;
9057             var _a = this._config, WebSocketCtor = _a.WebSocketCtor, protocol = _a.protocol, url = _a.url, binaryType = _a.binaryType;
9058             var observer = this._output;
9059             var socket = null;
9060             try {
9061                 socket = protocol ?
9062                     new WebSocketCtor(url, protocol) :
9063                     new WebSocketCtor(url);
9064                 this._socket = socket;
9065                 if (binaryType) {
9066                     this._socket.binaryType = binaryType;
9067                 }
9068             }
9069             catch (e) {
9070                 observer.error(e);
9071                 return;
9072             }
9073             var subscription = new Subscription(function () {
9074                 _this._socket = null;
9075                 if (socket && socket.readyState === 1) {
9076                     socket.close();
9077                 }
9078             });
9079             socket.onopen = function (e) {
9080                 var _socket = _this._socket;
9081                 if (!_socket) {
9082                     socket.close();
9083                     _this._resetState();
9084                     return;
9085                 }
9086                 var openObserver = _this._config.openObserver;
9087                 if (openObserver) {
9088                     openObserver.next(e);
9089                 }
9090                 var queue = _this.destination;
9091                 _this.destination = Subscriber.create(function (x) {
9092                     if (socket.readyState === 1) {
9093                         try {
9094                             var serializer = _this._config.serializer;
9095                             socket.send(serializer(x));
9096                         }
9097                         catch (e) {
9098                             _this.destination.error(e);
9099                         }
9100                     }
9101                 }, function (e) {
9102                     var closingObserver = _this._config.closingObserver;
9103                     if (closingObserver) {
9104                         closingObserver.next(undefined);
9105                     }
9106                     if (e && e.code) {
9107                         socket.close(e.code, e.reason);
9108                     }
9109                     else {
9110                         observer.error(new TypeError(WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT));
9111                     }
9112                     _this._resetState();
9113                 }, function () {
9114                     var closingObserver = _this._config.closingObserver;
9115                     if (closingObserver) {
9116                         closingObserver.next(undefined);
9117                     }
9118                     socket.close();
9119                     _this._resetState();
9120                 });
9121                 if (queue && queue instanceof ReplaySubject) {
9122                     subscription.add(queue.subscribe(_this.destination));
9123                 }
9124             };
9125             socket.onerror = function (e) {
9126                 _this._resetState();
9127                 observer.error(e);
9128             };
9129             socket.onclose = function (e) {
9130                 _this._resetState();
9131                 var closeObserver = _this._config.closeObserver;
9132                 if (closeObserver) {
9133                     closeObserver.next(e);
9134                 }
9135                 if (e.wasClean) {
9136                     observer.complete();
9137                 }
9138                 else {
9139                     observer.error(e);
9140                 }
9141             };
9142             socket.onmessage = function (e) {
9143                 try {
9144                     var deserializer = _this._config.deserializer;
9145                     observer.next(deserializer(e));
9146                 }
9147                 catch (err) {
9148                     observer.error(err);
9149                 }
9150             };
9151         };
9152         WebSocketSubject.prototype._subscribe = function (subscriber) {
9153             var _this = this;
9154             var source = this.source;
9155             if (source) {
9156                 return source.subscribe(subscriber);
9157             }
9158             if (!this._socket) {
9159                 this._connectSocket();
9160             }
9161             this._output.subscribe(subscriber);
9162             subscriber.add(function () {
9163                 var _socket = _this._socket;
9164                 if (_this._output.observers.length === 0) {
9165                     if (_socket && _socket.readyState === 1) {
9166                         _socket.close();
9167                     }
9168                     _this._resetState();
9169                 }
9170             });
9171             return subscriber;
9172         };
9173         WebSocketSubject.prototype.unsubscribe = function () {
9174             var _socket = this._socket;
9175             if (_socket && _socket.readyState === 1) {
9176                 _socket.close();
9177             }
9178             this._resetState();
9179             _super.prototype.unsubscribe.call(this);
9180         };
9181         return WebSocketSubject;
9182     }(AnonymousSubject));
9183
9184     function webSocket(urlConfigOrSource) {
9185         return new WebSocketSubject(urlConfigOrSource);
9186     }
9187
9188
9189
9190     var _webSocket = /*#__PURE__*/Object.freeze({
9191         webSocket: webSocket,
9192         WebSocketSubject: WebSocketSubject
9193     });
9194
9195     function fromFetch(input, initWithSelector) {
9196         if (initWithSelector === void 0) { initWithSelector = {}; }
9197         var selector = initWithSelector.selector, init = __rest(initWithSelector, ["selector"]);
9198         return new Observable(function (subscriber) {
9199             var controller = new AbortController();
9200             var signal = controller.signal;
9201             var abortable = true;
9202             var unsubscribed = false;
9203             var subscription = new Subscription();
9204             subscription.add(function () {
9205                 unsubscribed = true;
9206                 if (abortable) {
9207                     controller.abort();
9208                 }
9209             });
9210             var perSubscriberInit;
9211             if (init) {
9212                 if (init.signal) {
9213                     if (init.signal.aborted) {
9214                         controller.abort();
9215                     }
9216                     else {
9217                         var outerSignal_1 = init.signal;
9218                         var outerSignalHandler_1 = function () {
9219                             if (!signal.aborted) {
9220                                 controller.abort();
9221                             }
9222                         };
9223                         outerSignal_1.addEventListener('abort', outerSignalHandler_1);
9224                         subscription.add(function () { return outerSignal_1.removeEventListener('abort', outerSignalHandler_1); });
9225                     }
9226                 }
9227                 perSubscriberInit = __assign({}, init, { signal: signal });
9228             }
9229             else {
9230                 perSubscriberInit = { signal: signal };
9231             }
9232             fetch(input, perSubscriberInit).then(function (response) {
9233                 if (selector) {
9234                     subscription.add(from(selector(response)).subscribe(function (value) { return subscriber.next(value); }, function (err) {
9235                         abortable = false;
9236                         if (!unsubscribed) {
9237                             subscriber.error(err);
9238                         }
9239                     }, function () {
9240                         abortable = false;
9241                         subscriber.complete();
9242                     }));
9243                 }
9244                 else {
9245                     abortable = false;
9246                     subscriber.next(response);
9247                     subscriber.complete();
9248                 }
9249             }).catch(function (err) {
9250                 abortable = false;
9251                 if (!unsubscribed) {
9252                     subscriber.error(err);
9253                 }
9254             });
9255             return subscription;
9256         });
9257     }
9258
9259
9260
9261     var _fetch = /*#__PURE__*/Object.freeze({
9262         fromFetch: fromFetch
9263     });
9264
9265     var operators = _operators;
9266     var testing = _testing;
9267     var ajax$1 = _ajax;
9268     var webSocket$1 = _webSocket;
9269     var fetch$1 = _fetch;
9270
9271     exports.operators = operators;
9272     exports.testing = testing;
9273     exports.ajax = ajax$1;
9274     exports.webSocket = webSocket$1;
9275     exports.fetch = fetch$1;
9276     exports.Observable = Observable;
9277     exports.ConnectableObservable = ConnectableObservable;
9278     exports.GroupedObservable = GroupedObservable;
9279     exports.observable = observable;
9280     exports.Subject = Subject;
9281     exports.BehaviorSubject = BehaviorSubject;
9282     exports.ReplaySubject = ReplaySubject;
9283     exports.AsyncSubject = AsyncSubject;
9284     exports.asap = asap;
9285     exports.asapScheduler = asapScheduler;
9286     exports.async = async;
9287     exports.asyncScheduler = asyncScheduler;
9288     exports.queue = queue;
9289     exports.queueScheduler = queueScheduler;
9290     exports.animationFrame = animationFrame;
9291     exports.animationFrameScheduler = animationFrameScheduler;
9292     exports.VirtualTimeScheduler = VirtualTimeScheduler;
9293     exports.VirtualAction = VirtualAction;
9294     exports.Scheduler = Scheduler;
9295     exports.Subscription = Subscription;
9296     exports.Subscriber = Subscriber;
9297     exports.Notification = Notification;
9298     exports.pipe = pipe;
9299     exports.noop = noop;
9300     exports.identity = identity;
9301     exports.isObservable = isObservable;
9302     exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError;
9303     exports.EmptyError = EmptyError;
9304     exports.ObjectUnsubscribedError = ObjectUnsubscribedError;
9305     exports.UnsubscriptionError = UnsubscriptionError;
9306     exports.TimeoutError = TimeoutError;
9307     exports.bindCallback = bindCallback;
9308     exports.bindNodeCallback = bindNodeCallback;
9309     exports.combineLatest = combineLatest;
9310     exports.concat = concat;
9311     exports.defer = defer;
9312     exports.empty = empty$1;
9313     exports.forkJoin = forkJoin;
9314     exports.from = from;
9315     exports.fromEvent = fromEvent;
9316     exports.fromEventPattern = fromEventPattern;
9317     exports.generate = generate;
9318     exports.iif = iif;
9319     exports.interval = interval;
9320     exports.merge = merge;
9321     exports.never = never;
9322     exports.of = of;
9323     exports.onErrorResumeNext = onErrorResumeNext;
9324     exports.pairs = pairs;
9325     exports.partition = partition;
9326     exports.race = race;
9327     exports.range = range;
9328     exports.throwError = throwError;
9329     exports.timer = timer;
9330     exports.using = using;
9331     exports.zip = zip;
9332     exports.scheduled = scheduled;
9333     exports.EMPTY = EMPTY;
9334     exports.NEVER = NEVER;
9335     exports.config = config;
9336
9337     Object.defineProperty(exports, '__esModule', { value: true });
9338
9339 })));
9340
9341 //# sourceMappingURL=rxjs.umd.js.map
9342