rxjs-rails 0.0.1 → 2.2.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -42,16 +42,6 @@
42
42
  }
43
43
  }
44
44
 
45
- /** Used to determine if values are of the language type Object */
46
- var objectTypes = {
47
- 'boolean': false,
48
- 'function': true,
49
- 'object': true,
50
- 'number': false,
51
- 'string': false,
52
- 'undefined': false
53
- };
54
-
55
45
  /** `Object#toString` result shortcuts */
56
46
  var argsClass = '[object Arguments]',
57
47
  arrayClass = '[object Array]',
@@ -319,13 +309,13 @@
319
309
  if (!Array.prototype.every) {
320
310
  Array.prototype.every = function every(fun /*, thisp */) {
321
311
  var object = Object(this),
322
- self = splitString && {}.toString.call(this) == "[object String]" ?
312
+ self = splitString && {}.toString.call(this) == stringClass ?
323
313
  this.split("") :
324
314
  object,
325
315
  length = self.length >>> 0,
326
316
  thisp = arguments[1];
327
317
 
328
- if ({}.toString.call(fun) != "[object Function]") {
318
+ if ({}.toString.call(fun) != funcClass) {
329
319
  throw new TypeError(fun + " is not a function");
330
320
  }
331
321
 
@@ -341,14 +331,14 @@
341
331
  if (!Array.prototype.map) {
342
332
  Array.prototype.map = function map(fun /*, thisp*/) {
343
333
  var object = Object(this),
344
- self = splitString && {}.toString.call(this) == "[object String]" ?
334
+ self = splitString && {}.toString.call(this) == stringClass ?
345
335
  this.split("") :
346
336
  object,
347
337
  length = self.length >>> 0,
348
338
  result = Array(length),
349
339
  thisp = arguments[1];
350
340
 
351
- if ({}.toString.call(fun) != "[object Function]") {
341
+ if ({}.toString.call(fun) != funcClass) {
352
342
  throw new TypeError(fun + " is not a function");
353
343
  }
354
344
 
@@ -375,10 +365,10 @@
375
365
 
376
366
  if (!Array.isArray) {
377
367
  Array.isArray = function (arg) {
378
- return Object.prototype.toString.call(arg) == '[object Array]';
368
+ return Object.prototype.toString.call(arg) == arrayClass;
379
369
  };
380
370
  }
381
-
371
+
382
372
  if (!Array.prototype.indexOf) {
383
373
  Array.prototype.indexOf = function indexOf(searchElement) {
384
374
  var t = Object(this);
@@ -1132,44 +1122,38 @@
1132
1122
  var currentThreadScheduler = Scheduler.currentThread = (function () {
1133
1123
  var queue;
1134
1124
 
1135
- function Trampoline() {
1136
- queue = new PriorityQueue(4);
1137
- }
1138
-
1139
- Trampoline.prototype.dispose = function () {
1140
- queue = null;
1141
- };
1142
-
1143
- Trampoline.prototype.run = function () {
1125
+ function runTrampoline (q) {
1144
1126
  var item;
1145
- while (queue.length > 0) {
1146
- item = queue.dequeue();
1127
+ while (q.length > 0) {
1128
+ item = q.dequeue();
1147
1129
  if (!item.isCancelled()) {
1148
- while (item.dueTime - Scheduler.now() > 0) { }
1130
+ // Note, do not schedule blocking work!
1131
+ while (item.dueTime - Scheduler.now() > 0) {
1132
+ }
1149
1133
  if (!item.isCancelled()) {
1150
1134
  item.invoke();
1151
1135
  }
1152
1136
  }
1153
- }
1154
- };
1137
+ }
1138
+ }
1155
1139
 
1156
1140
  function scheduleNow(state, action) {
1157
1141
  return this.scheduleWithRelativeAndState(state, 0, action);
1158
1142
  }
1159
1143
 
1160
1144
  function scheduleRelative(state, dueTime, action) {
1161
- var dt = this.now() + normalizeTime(dueTime),
1145
+ var dt = this.now() + Scheduler.normalize(dueTime),
1162
1146
  si = new ScheduledItem(this, state, action, dt),
1163
1147
  t;
1164
1148
  if (!queue) {
1165
- t = new Trampoline();
1149
+ queue = new PriorityQueue(4);
1150
+ queue.enqueue(si);
1166
1151
  try {
1167
- queue.enqueue(si);
1168
- t.run();
1152
+ runTrampoline(queue);
1169
1153
  } catch (e) {
1170
1154
  throw e;
1171
1155
  } finally {
1172
- t.dispose();
1156
+ queue = null;
1173
1157
  }
1174
1158
  } else {
1175
1159
  queue.enqueue(si);
@@ -1195,19 +1179,22 @@
1195
1179
  }());
1196
1180
 
1197
1181
 
1198
- var reNative = RegExp('^' +
1199
- String(toString)
1200
- .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
1201
- .replace(/toString| for [^\]]+/g, '.*?') + '$'
1202
- );
1203
-
1204
- var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&
1205
- !reNative.test(setImmediate) && setImmediate,
1206
- clearImmediate = typeof (clearImmediate = freeGlobal && moduleExports && freeGlobal.clearImmediate) == 'function' &&
1207
- !reNative.test(clearImmediate) && clearImmediate;
1208
-
1209
1182
  var scheduleMethod, clearMethod = noop;
1210
1183
  (function () {
1184
+
1185
+ var reNative = RegExp('^' +
1186
+ String(toString)
1187
+ .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
1188
+ .replace(/toString| for [^\]]+/g, '.*?') + '$'
1189
+ );
1190
+
1191
+ var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&
1192
+ !reNative.test(setImmediate) && setImmediate,
1193
+ clearImmediate = typeof (clearImmediate = freeGlobal && moduleExports && freeGlobal.clearImmediate) == 'function' &&
1194
+ !reNative.test(clearImmediate) && clearImmediate;
1195
+
1196
+ var BrowserMutationObserver = root.MutationObserver || root.WebKitMutationObserver;
1197
+
1211
1198
  function postMessageSupported () {
1212
1199
  // Ensure not in a worker
1213
1200
  if (!root.postMessage || root.importScripts) { return false; }
@@ -1221,12 +1208,44 @@
1221
1208
  return isAsync;
1222
1209
  }
1223
1210
 
1224
- // Check for setImmediate first for Node v0.11+
1225
- if (typeof setImmediate === 'function') {
1226
- scheduleMethod = setImmediate;
1227
- clearMethod = clearImmediate;
1211
+ // Use in order, MutationObserver, nextTick, setImmediate, postMessage, MessageChannel, script readystatechanged, setTimeout
1212
+ if (!!BrowserMutationObserver) {
1213
+
1214
+ var mutationQueue = {}, mutationId = 0;
1215
+
1216
+ function drainQueue (mutations) {
1217
+ for (var i = 0, len = mutations.length; i < len; i++) {
1218
+ var id = mutations[i].target.getAttribute('drainQueue');
1219
+ mutationQueue[id]();
1220
+ delete mutationQueue[id];
1221
+ }
1222
+ }
1223
+
1224
+ var observer = new BrowserMutationObserver(drainQueue),
1225
+ elem = document.createElement('div');
1226
+ observer.observe(elem, { attributes: true });
1227
+
1228
+ root.addEventListener('unload', function () {
1229
+ observer.disconnect();
1230
+ observer = null;
1231
+ });
1232
+
1233
+ scheduleMethod = function (action) {
1234
+ var id = mutationId++;
1235
+ mutationQueue[id] = action;
1236
+ elem.setAttribute('drainQueue', id);
1237
+ return id;
1238
+ };
1239
+
1240
+ clearMethod = function (id) {
1241
+ delete mutationQueue[id];
1242
+ }
1243
+
1228
1244
  } else if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
1229
1245
  scheduleMethod = process.nextTick;
1246
+ } else if (typeof setImmediate === 'function') {
1247
+ scheduleMethod = setImmediate;
1248
+ clearMethod = clearImmediate;
1230
1249
  } else if (postMessageSupported()) {
1231
1250
  var MSG_PREFIX = 'ms.rx.schedule' + Math.random(),
1232
1251
  tasks = {},
@@ -3012,7 +3031,7 @@
3012
3031
  * @returns {Observable} An observable sequence containing lists of elements at corresponding indexes.
3013
3032
  */
3014
3033
  Observable.zipArray = function () {
3015
- var sources = slice.call(arguments);
3034
+ var sources = argsOrArray(arguments, 0);
3016
3035
  return new AnonymousObservable(function (observer) {
3017
3036
  var n = sources.length,
3018
3037
  queues = arrayInitialize(n, function () { return []; }),
@@ -4173,13 +4192,16 @@
4173
4192
 
4174
4193
  function subscribe(observer) {
4175
4194
  checkDisposed.call(this);
4195
+
4176
4196
  if (!this.isStopped) {
4177
4197
  this.observers.push(observer);
4178
4198
  return new InnerSubscription(this, observer);
4179
4199
  }
4180
- var ex = this.exception;
4181
- var hv = this.hasValue;
4182
- var v = this.value;
4200
+
4201
+ var ex = this.exception,
4202
+ hv = this.hasValue,
4203
+ v = this.value;
4204
+
4183
4205
  if (ex) {
4184
4206
  observer.onError(ex);
4185
4207
  } else if (hv) {
@@ -4188,6 +4210,7 @@
4188
4210
  } else {
4189
4211
  observer.onCompleted();
4190
4212
  }
4213
+
4191
4214
  return disposableEmpty;
4192
4215
  }
4193
4216
 
@@ -4200,11 +4223,11 @@
4200
4223
  function AsyncSubject() {
4201
4224
  _super.call(this, subscribe);
4202
4225
 
4203
- this.isDisposed = false,
4204
- this.isStopped = false,
4205
- this.value = null,
4206
- this.hasValue = false,
4207
- this.observers = [],
4226
+ this.isDisposed = false;
4227
+ this.isStopped = false;
4228
+ this.value = null;
4229
+ this.hasValue = false;
4230
+ this.observers = [];
4208
4231
  this.exception = null;
4209
4232
  }
4210
4233
 
@@ -4214,6 +4237,7 @@
4214
4237
  * @returns {Boolean} Indicates whether the subject has observers subscribed to it.
4215
4238
  */
4216
4239
  hasObservers: function () {
4240
+ checkDisposed.call(this);
4217
4241
  return this.observers.length > 0;
4218
4242
  },
4219
4243
  /**
@@ -4223,10 +4247,10 @@
4223
4247
  var o, i, len;
4224
4248
  checkDisposed.call(this);
4225
4249
  if (!this.isStopped) {
4226
- var os = this.observers.slice(0);
4227
4250
  this.isStopped = true;
4228
- var v = this.value;
4229
- var hv = this.hasValue;
4251
+ var os = this.observers.slice(0),
4252
+ v = this.value,
4253
+ hv = this.hasValue;
4230
4254
 
4231
4255
  if (hv) {
4232
4256
  for (i = 0, len = os.length; i < len; i++) {
@@ -1,2 +1,2 @@
1
- (function(a){function b(){}function c(a){return a}function d(a,b){return R(a,b)}function e(a,b){return a-b}function f(a){return a.toString()}function g(a){throw a}function h(){if(this.isDisposed)throw new Error(D)}function i(a){return"function"!=typeof a.toString&&"string"==typeof(a+"")}function j(a){return a&&"object"==typeof a?N.call(a)==E:!1}function k(a){return"function"==typeof a}function l(a,b,c,d){var e;if(a===b)return 0!==a||1/a==1/b;var f=typeof a,g=typeof b;if(!(a!==a||a&&s[f]||b&&s[g]))return!1;if(null==a||null==b)return a===b;var h=N.call(a),m=N.call(b);if(h==E&&(h=K),m==E&&(m=K),h!=m)return!1;switch(h){case G:case H:return+a==+b;case J:return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case L:case M:return a==String(b)}var n=h==F;if(!n){if(h!=K||!y&&(i(a)||i(b)))return!1;var o=!P&&j(a)?Object:a.constructor,p=!P&&j(b)?Object:b.constructor;if(o!=p&&!(k(o)&&o instanceof o&&k(p)&&p instanceof p))return!1}for(var q=c.length;q--;)if(c[q]==a)return d[q]==b;var r=0;if(e=!0,c.push(a),d.push(b),n){for(q=a.length,r=b.length,e=r==a.length;r--;){var t=b[r];if(!(e=l(a[r],t,c,d)))break}return e}for(var u in b)if(O.call(b,u))return r++,e=O.call(a,u)&&l(a[u],b[u],c,d);if(e)for(var u in a)if(O.call(a,u))return e=--r>-1;return c.pop(),d.pop(),e}function m(a,b){return 1===a.length&&Array.isArray(a[b])?a[b]:S.call(a)}function n(a,b){for(var c=new Array(a),d=0;a>d;d++)c[d]=b();return c}function o(a,b){this.scheduler=a,this.disposable=b,this.isDisposed=!1}function p(a,b){return new Vb(function(c){var d=new fb,e=new gb;return e.setDisposable(d),d.setDisposable(a.subscribe(c.onNext.bind(c),function(a){var d,f;try{f=b(a)}catch(g){return c.onError(g),void 0}d=new fb,e.setDisposable(d),d.setDisposable(f.subscribe(c))},c.onCompleted.bind(c))),e})}function q(a,b){var c=this;return new Vb(function(d){var e=0,f=a.length;return c.subscribe(function(c){if(f>e){var g,h=a[e++];try{g=b(c,h)}catch(i){return d.onError(i),void 0}d.onNext(g)}else d.onCompleted()},d.onError.bind(d),d.onCompleted.bind(d))})}function r(a){return this.select(a).mergeObservable()}var s={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},t=s[typeof window]&&window||this,u=s[typeof exports]&&exports&&!exports.nodeType&&exports,v=s[typeof module]&&module&&!module.nodeType&&module,w=v&&v.exports===u&&u,x=s[typeof global]&&global;!x||x.global!==x&&x.window!==x||(t=x);var y,z={Internals:{}},A=function(){return Date.now?Date.now:function(){return+new Date}}(),B="Sequence contains no elements.",C="Argument out of range",D="Object has been disposed",s={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},E="[object Arguments]",F="[object Array]",G="[object Boolean]",H="[object Date]",I="[object Function]",J="[object Number]",K="[object Object]",L="[object RegExp]",M="[object String]",N=Object.prototype.toString,O=Object.prototype.hasOwnProperty,P=N.call(arguments)==E;try{y=!(N.call(document)==K&&!({toString:0}+""))}catch(Q){y=!0}P||(j=function(a){return a&&"object"==typeof a?O.call(a,"callee"):!1}),k(/x/)&&(k=function(a){return"function"==typeof a&&N.call(a)==I});var R=z.Internals.isEqual=function(a,b){return l(a,b,[],[])},S=Array.prototype.slice,T=({}.hasOwnProperty,this.inherits=z.Internals.inherits=function(a,b){function c(){this.constructor=a}c.prototype=b.prototype,a.prototype=new c}),U=z.Internals.addProperties=function(a){for(var b=S.call(arguments,1),c=0,d=b.length;d>c;c++){var e=b[c];for(var f in e)a[f]=e[f]}},V=z.Internals.addRef=function(a,b){return new Vb(function(c){return new _(b.getDisposable(),a.subscribe(c))})};Function.prototype.bind||(Function.prototype.bind=function(a){var b=this,c=S.call(arguments,1),d=function(){function e(){}if(this instanceof d){e.prototype=b.prototype;var f=new e,g=b.apply(f,c.concat(S.call(arguments)));return Object(g)===g?g:f}return b.apply(a,c.concat(S.call(arguments)))};return d});var W=Object("a"),X="a"!=W[0]||!(0 in W);Array.prototype.every||(Array.prototype.every=function(a){var b=Object(this),c=X&&"[object String]"=={}.toString.call(this)?this.split(""):b,d=c.length>>>0,e=arguments[1];if("[object Function]"!={}.toString.call(a))throw new TypeError(a+" is not a function");for(var f=0;d>f;f++)if(f in c&&!a.call(e,c[f],f,b))return!1;return!0}),Array.prototype.map||(Array.prototype.map=function(a){var b=Object(this),c=X&&"[object String]"=={}.toString.call(this)?this.split(""):b,d=c.length>>>0,e=Array(d),f=arguments[1];if("[object Function]"!={}.toString.call(a))throw new TypeError(a+" is not a function");for(var g=0;d>g;g++)g in c&&(e[g]=a.call(f,c[g],g,b));return e}),Array.prototype.filter||(Array.prototype.filter=function(a){for(var b,c=[],d=new Object(this),e=0,f=d.length>>>0;f>e;e++)b=d[e],e in d&&a.call(arguments[1],b,e,d)&&c.push(b);return c}),Array.isArray||(Array.isArray=function(a){return"[object Array]"==Object.prototype.toString.call(a)}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a){var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>1&&(d=Number(arguments[1]),d!==d?d=0:0!==d&&1/0!=d&&d!==-1/0&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1});var Y=function(a,b){this.id=a,this.value=b};Y.prototype.compareTo=function(a){var b=this.value.compareTo(a.value);return 0===b&&(b=this.id-a.id),b};var Z=z.Internals.PriorityQueue=function(a){this.items=new Array(a),this.length=0},$=Z.prototype;$.isHigherPriority=function(a,b){return this.items[a].compareTo(this.items[b])<0},$.percolate=function(a){if(!(a>=this.length||0>a)){var b=a-1>>1;if(!(0>b||b===a)&&this.isHigherPriority(a,b)){var c=this.items[a];this.items[a]=this.items[b],this.items[b]=c,this.percolate(b)}}},$.heapify=function(b){if(b===a&&(b=0),!(b>=this.length||0>b)){var c=2*b+1,d=2*b+2,e=b;if(c<this.length&&this.isHigherPriority(c,e)&&(e=c),d<this.length&&this.isHigherPriority(d,e)&&(e=d),e!==b){var f=this.items[b];this.items[b]=this.items[e],this.items[e]=f,this.heapify(e)}}},$.peek=function(){return this.items[0].value},$.removeAt=function(a){this.items[a]=this.items[--this.length],delete this.items[this.length],this.heapify()},$.dequeue=function(){var a=this.peek();return this.removeAt(0),a},$.enqueue=function(a){var b=this.length++;this.items[b]=new Y(Z.count++,a),this.percolate(b)},$.remove=function(a){for(var b=0;b<this.length;b++)if(this.items[b].value===a)return this.removeAt(b),!0;return!1},Z.count=0;var _=z.CompositeDisposable=function(){this.disposables=m(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},ab=_.prototype;ab.add=function(a){this.isDisposed?a.dispose():(this.disposables.push(a),this.length++)},ab.remove=function(a){var b=!1;if(!this.isDisposed){var c=this.disposables.indexOf(a);-1!==c&&(b=!0,this.disposables.splice(c,1),this.length--,a.dispose())}return b},ab.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var a=this.disposables.slice(0);this.disposables=[],this.length=0;for(var b=0,c=a.length;c>b;b++)a[b].dispose()}},ab.clear=function(){var a=this.disposables.slice(0);this.disposables=[],this.length=0;for(var b=0,c=a.length;c>b;b++)a[b].dispose()},ab.contains=function(a){return-1!==this.disposables.indexOf(a)},ab.toArray=function(){return this.disposables.slice(0)};var bb=z.Disposable=function(a){this.isDisposed=!1,this.action=a||b};bb.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var cb=bb.create=function(a){return new bb(a)},db=bb.empty={dispose:b},eb=function(){function a(a){this.isSingle=a,this.isDisposed=!1,this.current=null}var b=a.prototype;return b.getDisposable=function(){return this.current},b.setDisposable=function(a){if(this.current&&this.isSingle)throw new Error("Disposable has already been assigned");var b,c=this.isDisposed;c||(b=this.current,this.current=a),b&&b.dispose(),c&&a&&a.dispose()},b.dispose=function(){var a;this.isDisposed||(this.isDisposed=!0,a=this.current,this.current=null),a&&a.dispose()},a}(),fb=z.SingleAssignmentDisposable=function(a){function b(){a.call(this,!0)}return T(b,a),b}(eb),gb=z.SerialDisposable=function(a){function b(){a.call(this,!1)}return T(b,a),b}(eb),hb=z.RefCountDisposable=function(){function a(a){this.disposable=a,this.disposable.count++,this.isInnerDisposed=!1}function b(a){this.underlyingDisposable=a,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return a.prototype.dispose=function(){this.disposable.isDisposed||this.isInnerDisposed||(this.isInnerDisposed=!0,this.disposable.count--,0===this.disposable.count&&this.disposable.isPrimaryDisposed&&(this.disposable.isDisposed=!0,this.disposable.underlyingDisposable.dispose()))},b.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},b.prototype.getDisposable=function(){return this.isDisposed?db:new a(this)},b}();o.prototype.dispose=function(){var a=this;this.scheduler.schedule(function(){a.isDisposed||(a.isDisposed=!0,a.disposable.dispose())})};var ib=z.Internals.ScheduledItem=function(a,b,c,d,f){this.scheduler=a,this.state=b,this.action=c,this.dueTime=d,this.comparer=f||e,this.disposable=new fb};ib.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},ib.prototype.compareTo=function(a){return this.comparer(this.dueTime,a.dueTime)},ib.prototype.isCancelled=function(){return this.disposable.isDisposed},ib.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var jb,kb=z.Scheduler=function(){function a(a,b,c,d){this.now=a,this._schedule=b,this._scheduleRelative=c,this._scheduleAbsolute=d}function b(a,b){var c=b.first,d=b.second,e=new _,f=function(b){d(b,function(b){var c=!1,d=!1,g=a.scheduleWithState(b,function(a,b){return c?e.remove(g):d=!0,f(b),db});d||(e.add(g),c=!0)})};return f(c),e}function c(a,b,c){var d=b.first,e=b.second,f=new _,g=function(b){e(b,function(b,d){var e=!1,h=!1,i=a[c].call(a,b,d,function(a,b){return e?f.remove(i):h=!0,g(b),db});h||(f.add(i),e=!0)})};return g(d),f}function d(a,b){return b(),db}var e=a.prototype;return e.catchException=e["catch"]=function(a){return new sb(this,a)},e.schedulePeriodic=function(a,b){return this.schedulePeriodicWithState(null,a,function(){b()})},e.schedulePeriodicWithState=function(a,b,c){var d=a,e=setInterval(function(){d=c(d)},b);return cb(function(){clearInterval(e)})},e.schedule=function(a){return this._schedule(a,d)},e.scheduleWithState=function(a,b){return this._schedule(a,b)},e.scheduleWithRelative=function(a,b){return this._scheduleRelative(b,a,d)},e.scheduleWithRelativeAndState=function(a,b,c){return this._scheduleRelative(a,b,c)},e.scheduleWithAbsolute=function(a,b){return this._scheduleAbsolute(b,a,d)},e.scheduleWithAbsoluteAndState=function(a,b,c){return this._scheduleAbsolute(a,b,c)},e.scheduleRecursive=function(a){return this.scheduleRecursiveWithState(a,function(a,b){a(function(){b(a)})})},e.scheduleRecursiveWithState=function(a,c){return this.scheduleWithState({first:a,second:c},function(a,c){return b(a,c)})},e.scheduleRecursiveWithRelative=function(a,b){return this.scheduleRecursiveWithRelativeAndState(b,a,function(a,b){a(function(c){b(a,c)})})},e.scheduleRecursiveWithRelativeAndState=function(a,b,d){return this._scheduleRelative({first:a,second:d},b,function(a,b){return c(a,b,"scheduleWithRelativeAndState")})},e.scheduleRecursiveWithAbsolute=function(a,b){return this.scheduleRecursiveWithAbsoluteAndState(b,a,function(a,b){a(function(c){b(a,c)})})},e.scheduleRecursiveWithAbsoluteAndState=function(a,b,d){return this._scheduleAbsolute({first:a,second:d},b,function(a,b){return c(a,b,"scheduleWithAbsoluteAndState")})},a.now=A,a.normalize=function(a){return 0>a&&(a=0),a},a}(),lb=kb.normalize,mb=(z.Internals.SchedulePeriodicRecursive=function(){function a(a,b){b(0,this._period);try{this._state=this._action(this._state)}catch(c){throw this._cancel.dispose(),c}}function b(a,b,c,d){this._scheduler=a,this._state=b,this._period=c,this._action=d}return b.prototype.start=function(){var b=new fb;return this._cancel=b,b.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,a.bind(this))),b},b}(),kb.immediate=function(){function a(a,b){return b(this,a)}function b(a,b,c){for(var d=lb(d);d-this.now()>0;);return c(this,a)}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new kb(A,a,b,c)}()),nb=kb.currentThread=function(){function a(){e=new Z(4)}function b(a,b){return this.scheduleWithRelativeAndState(a,0,b)}function c(b,c,d){var f,g=this.now()+lb(c),h=new ib(this,b,d,g);if(e)e.enqueue(h);else{f=new a;try{e.enqueue(h),f.run()}catch(i){throw i}finally{f.dispose()}}return h.disposable}function d(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}var e;a.prototype.dispose=function(){e=null},a.prototype.run=function(){for(var a;e.length>0;)if(a=e.dequeue(),!a.isCancelled()){for(;a.dueTime-kb.now()>0;);a.isCancelled()||a.invoke()}};var f=new kb(A,b,c,d);return f.scheduleRequired=function(){return null===e},f.ensureTrampoline=function(a){return null===e?this.schedule(a):a()},f}(),ob=RegExp("^"+String(N).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),pb="function"==typeof(pb=x&&w&&x.setImmediate)&&!ob.test(pb)&&pb,qb="function"==typeof(qb=x&&w&&x.clearImmediate)&&!ob.test(qb)&&qb,rb=b;!function(){function a(){if(!t.postMessage||t.importScripts)return!1;var a=!1,b=t.onmessage;return t.onmessage=function(){a=!0},t.postMessage("","*"),t.onmessage=b,a}function b(a){if("string"==typeof a.data&&a.data.substring(0,c.length)===c){var b=a.data.substring(c.length),e=d[b];e(),delete d[b]}}if("function"==typeof pb)jb=pb,rb=qb;else if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))jb=process.nextTick;else if(a()){var c="ms.rx.schedule"+Math.random(),d={},e=0;t.addEventListener?t.addEventListener("message",b,!1):t.attachEvent("onmessage",b,!1),jb=function(a){var b=e++;d[b]=a,t.postMessage(c+b,"*")}}else if(t.MessageChannel){var f=new t.MessageChannel,g={},h=0;f.port1.onmessage=function(a){var b=a.data,c=g[b];c(),delete g[b]},jb=function(a){var b=h++;g[b]=a,f.port2.postMessage(b)}}else"document"in t&&"onreadystatechange"in t.document.createElement("script")?jb=function(a){var b=t.document.createElement("script");b.onreadystatechange=function(){a(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},t.document.documentElement.appendChild(b)}:(jb=function(a){return setTimeout(a,0)},rb=clearTimeout)}();var sb=(kb.timeout=function(){function a(a,b){var c=this,d=new fb,e=jb(function(){d.isDisposed||d.setDisposable(b(c,a))});return new _(d,cb(function(){rb(e)}))}function b(a,b,c){var d=this,e=kb.normalize(b);if(0===e)return d.scheduleWithState(a,c);var f=new fb,g=setTimeout(function(){f.isDisposed||f.setDisposable(c(d,a))},e);return new _(f,cb(function(){clearTimeout(g)}))}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new kb(A,a,b,c)}(),function(a){function b(){return this._scheduler.now()}function c(a,b){return this._scheduler.scheduleWithState(a,this._wrap(b))}function d(a,b,c){return this._scheduler.scheduleWithRelativeAndState(a,b,this._wrap(c))}function e(a,b,c){return this._scheduler.scheduleWithAbsoluteAndState(a,b,this._wrap(c))}function f(f,g){this._scheduler=f,this._handler=g,this._recursiveOriginal=null,this._recursiveWrapper=null,a.call(this,b,c,d,e)}return T(f,a),f.prototype._clone=function(a){return new f(a,this._handler)},f.prototype._wrap=function(a){var b=this;return function(c,d){try{return a(b._getRecursiveWrapper(c),d)}catch(e){if(!b._handler(e))throw e;return db}}},f.prototype._getRecursiveWrapper=function(a){if(this._recursiveOriginal!==a){this._recursiveOriginal=a;var b=this._clone(a);b._recursiveOriginal=a,b._recursiveWrapper=b,this._recursiveWrapper=b}return this._recursiveWrapper},f.prototype.schedulePeriodicWithState=function(a,b,c){var d=this,e=!1,f=new fb;return f.setDisposable(this._scheduler.schedulePeriodicWithState(a,b,function(a){if(e)return null;try{return c(a)}catch(b){if(e=!0,!d._handler(b))throw b;return f.dispose(),null}})),f},f}(kb)),tb=z.Notification=function(){function a(a,b){this.hasValue=null==b?!1:b,this.kind=a}var b=a.prototype;return b.accept=function(a,b,c){return 1===arguments.length&&"object"==typeof a?this._acceptObservable(a):this._accept(a,b,c)},b.toObservable=function(a){var b=this;return a||(a=mb),new Vb(function(c){return a.schedule(function(){b._acceptObservable(c),"N"===b.kind&&c.onCompleted()})})},a}(),ub=tb.createOnNext=function(){function a(a){return a(this.value)}function b(a){return a.onNext(this.value)}function c(){return"OnNext("+this.value+")"}return function(d){var e=new tb("N",!0);return e.value=d,e._accept=a,e._acceptObservable=b,e.toString=c,e}}(),vb=tb.createOnError=function(){function a(a,b){return b(this.exception)}function b(a){return a.onError(this.exception)}function c(){return"OnError("+this.exception+")"}return function(d){var e=new tb("E");return e.exception=d,e._accept=a,e._acceptObservable=b,e.toString=c,e}}(),wb=tb.createOnCompleted=function(){function a(a,b,c){return c()}function b(a){return a.onCompleted()}function c(){return"OnCompleted()"}return function(){var d=new tb("C");return d._accept=a,d._acceptObservable=b,d.toString=c,d}}(),xb=z.Internals.Enumerator=function(a,b){this.moveNext=a,this.getCurrent=b},yb=xb.create=function(a,b){var c=!1;return new xb(function(){if(c)return!1;var b=a();return b||(c=!0),b},function(){return b()})},zb=z.Internals.Enumerable=function(a){this.getEnumerator=a};zb.prototype.concat=function(){var a=this;return new Vb(function(b){var c,d=a.getEnumerator(),e=new gb,f=mb.scheduleRecursive(function(a){var f,g;if(!c){try{g=d.moveNext(),g&&(f=d.getCurrent())}catch(h){return b.onError(h),void 0}if(!g)return b.onCompleted(),void 0;var i=new fb;e.setDisposable(i),i.setDisposable(f.subscribe(b.onNext.bind(b),b.onError.bind(b),function(){a()}))}});return new _(e,f,cb(function(){c=!0}))})},zb.prototype.catchException=function(){var a=this;return new Vb(function(b){var c,d,e=a.getEnumerator(),f=new gb,g=mb.scheduleRecursive(function(a){var g,h;if(!c){try{h=e.moveNext(),h&&(g=e.getCurrent())}catch(i){return b.onError(i),void 0}if(!h)return d?b.onError(d):b.onCompleted(),void 0;var j=new fb;f.setDisposable(j),j.setDisposable(g.subscribe(b.onNext.bind(b),function(b){d=b,a()},b.onCompleted.bind(b)))}});return new _(f,g,cb(function(){c=!0}))})};var Ab=zb.repeat=function(a,b){return 1===arguments.length&&(b=-1),new zb(function(){var c,d=b;return yb(function(){return 0===d?!1:(d>0&&d--,c=a,!0)},function(){return c})})},Bb=zb.forEach=function(a,b,d){return b||(b=c),new zb(function(){var c,e=-1;return yb(function(){return++e<a.length?(c=b.call(d,a[e],e,a),!0):!1},function(){return c})})},Cb=z.Observer=function(){};Cb.prototype.toNotifier=function(){var a=this;return function(b){return b.accept(a)}},Cb.prototype.asObserver=function(){return new Gb(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},Cb.prototype.checked=function(){return new Hb(this)};var Db=Cb.create=function(a,c,d){return a||(a=b),c||(c=g),d||(d=b),new Gb(a,c,d)};Cb.fromNotifier=function(a){return new Gb(function(b){return a(ub(b))},function(b){return a(vb(b))},function(){return a(wb())})},Cb.notifyOn=function(a){return new Jb(a,this)};var Eb,Fb=z.Internals.AbstractObserver=function(a){function b(){this.isStopped=!1,a.call(this)}return T(b,a),b.prototype.onNext=function(a){this.isStopped||this.next(a)},b.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.error(a))},b.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},b.prototype.dispose=function(){this.isStopped=!0},b.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.error(a),!0)},b}(Cb),Gb=z.AnonymousObserver=function(a){function b(b,c,d){a.call(this),this._onNext=b,this._onError=c,this._onCompleted=d}return T(b,a),b.prototype.next=function(a){this._onNext(a)},b.prototype.error=function(a){this._onError(a)},b.prototype.completed=function(){this._onCompleted()},b}(Fb),Hb=function(a){function b(b){a.call(this),this._observer=b,this._state=0}T(b,a);var c=b.prototype;return c.onNext=function(a){this.checkAccess();try{this._observer.onNext(a)}catch(b){throw b}finally{this._state=0}},c.onError=function(a){this.checkAccess();try{this._observer.onError(a)}catch(b){throw b}finally{this._state=2}},c.onCompleted=function(){this.checkAccess();try{this._observer.onCompleted()}catch(a){throw a}finally{this._state=2}},c.checkAccess=function(){if(1===this._state)throw new Error("Re-entrancy detected");if(2===this._state)throw new Error("Observer completed");0===this._state&&(this._state=1)},b}(Cb),Ib=z.Internals.ScheduledObserver=function(a){function b(b,c){a.call(this),this.scheduler=b,this.observer=c,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new gb}return T(b,a),b.prototype.next=function(a){var b=this;this.queue.push(function(){b.observer.onNext(a)})},b.prototype.error=function(a){var b=this;this.queue.push(function(){b.observer.onError(a)})},b.prototype.completed=function(){var a=this;this.queue.push(function(){a.observer.onCompleted()})},b.prototype.ensureActive=function(){var a=!1,b=this;!this.hasFaulted&&this.queue.length>0&&(a=!this.isAcquired,this.isAcquired=!0),a&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(a){var c;if(!(b.queue.length>0))return b.isAcquired=!1,void 0;c=b.queue.shift();try{c()}catch(d){throw b.queue=[],b.hasFaulted=!0,d}a()}))},b.prototype.dispose=function(){a.prototype.dispose.call(this),this.disposable.dispose()},b}(Fb),Jb=function(a){function b(){a.apply(this,arguments)}return T(b,a),b.prototype.next=function(b){a.prototype.next.call(this,b),this.ensureActive()},b.prototype.error=function(b){a.prototype.error.call(this,b),this.ensureActive()},b.prototype.completed=function(){a.prototype.completed.call(this),this.ensureActive()},b}(Ib),Kb=z.Observable=function(){function a(a){this._subscribe=a}return Eb=a.prototype,Eb.finalValue=function(){var a=this;return new Vb(function(b){var c,d=!1;return a.subscribe(function(a){d=!0,c=a},b.onError.bind(b),function(){d?(b.onNext(c),b.onCompleted()):b.onError(new Error(B))})})},Eb.subscribe=Eb.forEach=function(a,b,c){var d;return d="object"==typeof a?a:Db(a,b,c),this._subscribe(d)},Eb.toArray=function(){function a(a,b){var c=a.slice(0);return c.push(b),c}return this.scan([],a).startWith([]).finalValue()},a}();Eb.observeOn=function(a){var b=this;return new Vb(function(c){return b.subscribe(new Jb(a,c))})},Eb.subscribeOn=function(a){var b=this;return new Vb(function(c){var d=new fb,e=new gb;return e.setDisposable(d),d.setDisposable(a.schedule(function(){e.setDisposable(new o(a,b.subscribe(c)))})),e})},Kb.create=Kb.createWithDisposable=function(a){return new Vb(a)};var Lb=(Kb.defer=function(a){return new Vb(function(b){var c;try{c=a()}catch(d){return Pb(d).subscribe(b)}return c.subscribe(b)})},Kb.empty=function(a){return a||(a=mb),new Vb(function(b){return a.schedule(function(){b.onCompleted()})})}),Mb=Kb.fromArray=function(a,b){return b||(b=nb),new Vb(function(c){var d=0;return b.scheduleRecursive(function(b){d<a.length?(c.onNext(a[d++]),b()):c.onCompleted()})})};Kb.generate=function(a,b,c,d,e){return e||(e=nb),new Vb(function(f){var g=!0,h=a;return e.scheduleRecursive(function(a){var e,i;try{g?g=!1:h=c(h),e=b(h),e&&(i=d(h))}catch(j){return f.onError(j),void 0}e?(f.onNext(i),a()):f.onCompleted()})})};var Nb=Kb.never=function(){return new Vb(function(){return db})};Kb.range=function(a,b,c){return c||(c=nb),new Vb(function(d){return c.scheduleRecursiveWithState(0,function(c,e){b>c?(d.onNext(a+c),e(c+1)):d.onCompleted()})})},Kb.repeat=function(a,b,c){return c||(c=nb),null==b&&(b=-1),Ob(a,c).repeat(b)};var Ob=Kb["return"]=Kb.returnValue=function(a,b){return b||(b=mb),new Vb(function(c){return b.schedule(function(){c.onNext(a),c.onCompleted()})})},Pb=Kb["throw"]=Kb.throwException=function(a,b){return b||(b=mb),new Vb(function(c){return b.schedule(function(){c.onError(a)})})};Kb.using=function(a,b){return new Vb(function(c){var d,e,f=db;try{d=a(),d&&(f=d),e=b(d)}catch(g){return new _(Pb(g).subscribe(c),f)}return new _(e.subscribe(c),f)})},Eb.amb=function(a){var b=this;return new Vb(function(c){function d(){f||(f=g,j.dispose())}function e(){f||(f=h,i.dispose())}var f,g="L",h="R",i=new fb,j=new fb;return i.setDisposable(b.subscribe(function(a){d(),f===g&&c.onNext(a)},function(a){d(),f===g&&c.onError(a)},function(){d(),f===g&&c.onCompleted()})),j.setDisposable(a.subscribe(function(a){e(),f===h&&c.onNext(a)},function(a){e(),f===h&&c.onError(a)},function(){e(),f===h&&c.onCompleted()})),new _(i,j)})},Kb.amb=function(){function a(a,b){return a.amb(b)}for(var b=Nb(),c=m(arguments,0),d=0,e=c.length;e>d;d++)b=a(b,c[d]);return b},Eb["catch"]=Eb.catchException=function(a){return"function"==typeof a?p(this,a):Qb([this,a])};var Qb=Kb.catchException=Kb["catch"]=function(){var a=m(arguments,0);return Bb(a).catchException()};Eb.combineLatest=function(){var a=S.call(arguments);return Array.isArray(a[0])?a[0].unshift(this):a.unshift(this),Rb.apply(this,a)};var Rb=Kb.combineLatest=function(){var a=S.call(arguments),b=a.pop();return Array.isArray(a[0])&&(a=a[0]),new Vb(function(d){function e(a){var e;if(i[a]=!0,j||(j=i.every(c))){try{e=b.apply(null,l)}catch(f){return d.onError(f),void 0}d.onNext(e)}else k.filter(function(b,c){return c!==a}).every(c)&&d.onCompleted()}function f(a){k[a]=!0,k.every(c)&&d.onCompleted()}for(var g=function(){return!1},h=a.length,i=n(h,g),j=!1,k=n(h,g),l=new Array(h),m=new Array(h),o=0;h>o;o++)!function(b){m[b]=new fb,m[b].setDisposable(a[b].subscribe(function(a){l[b]=a,e(b)},d.onError.bind(d),function(){f(b)}))}(o);return new _(m)})};Eb.concat=function(){var a=S.call(arguments,0);return a.unshift(this),Sb.apply(this,a)};var Sb=Kb.concat=function(){var a=m(arguments,0);return Bb(a).concat()};Eb.concatObservable=Eb.concatAll=function(){return this.merge(1)},Eb.merge=function(a){if("number"!=typeof a)return Tb(this,a);var b=this;return new Vb(function(c){var d=0,e=new _,f=!1,g=[],h=function(a){var b=new fb;e.add(b),b.setDisposable(a.subscribe(c.onNext.bind(c),c.onError.bind(c),function(){var a;e.remove(b),g.length>0?(a=g.shift(),h(a)):(d--,f&&0===d&&c.onCompleted())}))};return e.add(b.subscribe(function(b){a>d?(d++,h(b)):g.push(b)},c.onError.bind(c),function(){f=!0,0===d&&c.onCompleted()})),e})};var Tb=Kb.merge=function(){var a,b;return arguments[0]?arguments[0].now?(a=arguments[0],b=S.call(arguments,1)):(a=mb,b=S.call(arguments,0)):(a=mb,b=S.call(arguments,1)),Array.isArray(b[0])&&(b=b[0]),Mb(b,a).mergeObservable()};Eb.mergeObservable=Eb.mergeAll=function(){var a=this;return new Vb(function(b){var c=new _,d=!1,e=new fb;return c.add(e),e.setDisposable(a.subscribe(function(a){var e=new fb;c.add(e),e.setDisposable(a.subscribe(function(a){b.onNext(a)},b.onError.bind(b),function(){c.remove(e),d&&1===c.length&&b.onCompleted()}))},b.onError.bind(b),function(){d=!0,1===c.length&&b.onCompleted()})),c})},Eb.onErrorResumeNext=function(a){if(!a)throw new Error("Second observable is required");return Ub([this,a])};var Ub=Kb.onErrorResumeNext=function(){var a=m(arguments,0);return new Vb(function(b){var c=0,d=new gb,e=mb.scheduleRecursive(function(e){var f,g;c<a.length?(f=a[c++],g=new fb,d.setDisposable(g),g.setDisposable(f.subscribe(b.onNext.bind(b),function(){e()},function(){e()}))):b.onCompleted()});return new _(d,e)})};Eb.skipUntil=function(a){var b=this;return new Vb(function(c){var d=!1,e=new _(b.subscribe(function(a){d&&c.onNext(a)},c.onError.bind(c),function(){d&&c.onCompleted()})),f=new fb;return e.add(f),f.setDisposable(a.subscribe(function(){d=!0,f.dispose()},c.onError.bind(c),function(){f.dispose()})),e})},Eb["switch"]=Eb.switchLatest=function(){var a=this;return new Vb(function(b){var c=!1,d=new gb,e=!1,f=0,g=a.subscribe(function(a){var g=new fb,h=++f;c=!0,d.setDisposable(g),g.setDisposable(a.subscribe(function(a){f===h&&b.onNext(a)},function(a){f===h&&b.onError(a)},function(){f===h&&(c=!1,e&&b.onCompleted())}))},b.onError.bind(b),function(){e=!0,c||b.onCompleted()});return new _(g,d)})},Eb.takeUntil=function(a){var c=this;return new Vb(function(d){return new _(c.subscribe(d),a.subscribe(d.onCompleted.bind(d),d.onError.bind(d),b))})},Eb.zip=function(){if(Array.isArray(arguments[0]))return q.apply(this,arguments);var a=this,b=S.call(arguments),d=b.pop();return b.unshift(a),new Vb(function(e){function f(a){i[a]=!0,i.every(function(a){return a})&&e.onCompleted()}for(var g=b.length,h=n(g,function(){return[]}),i=n(g,function(){return!1}),j=function(b){var f,g;if(h.every(function(a){return a.length>0})){try{g=h.map(function(a){return a.shift()}),f=d.apply(a,g)}catch(j){return e.onError(j),void 0}e.onNext(f)}else i.filter(function(a,c){return c!==b}).every(c)&&e.onCompleted()},k=new Array(g),l=0;g>l;l++)!function(a){k[a]=new fb,k[a].setDisposable(b[a].subscribe(function(b){h[a].push(b),j(a)},e.onError.bind(e),function(){f(a)}))}(l);return new _(k)})},Kb.zip=function(){var a=S.call(arguments,0),b=a.shift();return b.zip.apply(b,a)},Kb.zipArray=function(){var a=S.call(arguments);return new Vb(function(b){function d(a){if(g.every(function(a){return a.length>0})){var d=g.map(function(a){return a.shift()});b.onNext(d)}else if(h.filter(function(b,c){return c!==a}).every(c))return b.onCompleted(),void 0}function e(a){return h[a]=!0,h.every(c)?(b.onCompleted(),void 0):void 0}for(var f=a.length,g=n(f,function(){return[]}),h=n(f,function(){return!1}),i=new Array(f),j=0;f>j;j++)!function(c){i[c]=new fb,i[c].setDisposable(a[c].subscribe(function(a){g[c].push(a),d(c)},b.onError.bind(b),function(){e(c)}))}(j);var k=new _(i);return k.add(cb(function(){for(var a=0,b=g.length;b>a;a++)g[a]=[]})),k})},Eb.asObservable=function(){var a=this;return new Vb(function(b){return a.subscribe(b)})},Eb.bufferWithCount=function(a,b){return 1===arguments.length&&(b=a),this.windowWithCount(a,b).selectMany(function(a){return a.toArray()}).where(function(a){return a.length>0})},Eb.dematerialize=function(){var a=this;return new Vb(function(b){return a.subscribe(function(a){return a.accept(b)},b.onError.bind(b),b.onCompleted.bind(b))})},Eb.distinctUntilChanged=function(a,b){var e=this;return a||(a=c),b||(b=d),new Vb(function(c){var d,f=!1;return e.subscribe(function(e){var g,h=!1;try{g=a(e)}catch(i){return c.onError(i),void 0}if(f)try{h=b(d,g)}catch(i){return c.onError(i),void 0}f&&h||(f=!0,d=g,c.onNext(e))},c.onError.bind(c),c.onCompleted.bind(c))})},Eb["do"]=Eb.doAction=function(a,b,c){var d,e=this;return"function"==typeof a?d=a:(d=a.onNext.bind(a),b=a.onError.bind(a),c=a.onCompleted.bind(a)),new Vb(function(a){return e.subscribe(function(b){try{d(b)}catch(c){a.onError(c)}a.onNext(b)},function(c){if(b){try{b(c)}catch(d){a.onError(d)}a.onError(c)}else a.onError(c)},function(){if(c){try{c()}catch(b){a.onError(b)}a.onCompleted()}else a.onCompleted()})})},Eb["finally"]=Eb.finallyAction=function(a){var b=this;return new Vb(function(c){var d=b.subscribe(c);return cb(function(){try{d.dispose()}catch(b){throw b}finally{a()}})})},Eb.ignoreElements=function(){var a=this;return new Vb(function(c){return a.subscribe(b,c.onError.bind(c),c.onCompleted.bind(c))})},Eb.materialize=function(){var a=this;return new Vb(function(b){return a.subscribe(function(a){b.onNext(ub(a))},function(a){b.onNext(vb(a)),b.onCompleted()},function(){b.onNext(wb()),b.onCompleted()})})},Eb.repeat=function(a){return Ab(this,a).concat()},Eb.retry=function(a){return Ab(this,a).catchException()},Eb.scan=function(){var a,b,c=!1,d=this;return 2===arguments.length?(c=!0,a=arguments[0],b=arguments[1]):b=arguments[0],new Vb(function(e){var f,g,h;return d.subscribe(function(d){try{h||(h=!0),f?g=b(g,d):(g=c?b(a,d):d,f=!0)}catch(i){return e.onError(i),void 0}e.onNext(g)},e.onError.bind(e),function(){!h&&c&&e.onNext(a),e.onCompleted()})})},Eb.skipLast=function(a){var b=this;return new Vb(function(c){var d=[];
2
- return b.subscribe(function(b){d.push(b),d.length>a&&c.onNext(d.shift())},c.onError.bind(c),c.onCompleted.bind(c))})},Eb.startWith=function(){var a,b,c=0;return arguments.length&&"now"in Object(arguments[0])?(b=arguments[0],c=1):b=mb,a=S.call(arguments,c),Bb([Mb(a,b),this]).concat()},Eb.takeLast=function(a,b){return this.takeLastBuffer(a).selectMany(function(a){return Mb(a,b)})},Eb.takeLastBuffer=function(a){var b=this;return new Vb(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&d.shift()},c.onError.bind(c),function(){c.onNext(d),c.onCompleted()})})},Eb.windowWithCount=function(a,b){var c=this;if(0>=a)throw new Error(C);if(1===arguments.length&&(b=a),0>=b)throw new Error(C);return new Vb(function(d){var e=new fb,f=new hb(e),g=0,h=[],i=function(){var a=new Zb;h.push(a),d.onNext(V(a,f))};return i(),e.setDisposable(c.subscribe(function(c){for(var d,e=0,f=h.length;f>e;e++)h[e].onNext(c);var j=g-a+1;j>=0&&j%b===0&&(d=h.shift(),d.onCompleted()),g++,g%b===0&&i()},function(a){for(;h.length>0;)h.shift().onError(a);d.onError(a)},function(){for(;h.length>0;)h.shift().onCompleted();d.onCompleted()})),f})},Eb.defaultIfEmpty=function(b){var c=this;return b===a&&(b=null),new Vb(function(a){var d=!1;return c.subscribe(function(b){d=!0,a.onNext(b)},a.onError.bind(a),function(){d||a.onNext(b),a.onCompleted()})})},Eb.distinct=function(a,b){var d=this;return a||(a=c),b||(b=f),new Vb(function(c){var e={};return d.subscribe(function(d){var f,g,h,i=!1;try{f=a(d),g=b(f)}catch(j){return c.onError(j),void 0}for(h in e)if(g===h){i=!0;break}i||(e[g]=null,c.onNext(d))},c.onError.bind(c),c.onCompleted.bind(c))})},Eb.groupBy=function(a,b,c){return this.groupByUntil(a,b,function(){return Nb()},c)},Eb.groupByUntil=function(a,d,e,g){var h=this;return d||(d=c),g||(g=f),new Vb(function(c){var f={},i=new _,j=new hb(i);return i.add(h.subscribe(function(h){var k,l,m,n,o,p,q,r,s,t;try{p=a(h),q=g(p)}catch(u){for(t in f)f[t].onError(u);return c.onError(u),void 0}n=!1;try{s=f[q],s||(s=new Zb,f[q]=s,n=!0)}catch(u){for(t in f)f[t].onError(u);return c.onError(u),void 0}if(n){o=new Xb(p,s,j),l=new Xb(p,s);try{k=e(l)}catch(u){for(t in f)f[t].onError(u);return c.onError(u),void 0}c.onNext(o),r=new fb,i.add(r);var v=function(){q in f&&(delete f[q],s.onCompleted()),i.remove(r)};r.setDisposable(k.take(1).subscribe(b,function(a){for(t in f)f[t].onError(a);c.onError(a)},function(){v()}))}try{m=d(h)}catch(u){for(t in f)f[t].onError(u);return c.onError(u),void 0}s.onNext(m)},function(a){for(var b in f)f[b].onError(a);c.onError(a)},function(){for(var a in f)f[a].onCompleted();c.onCompleted()})),j})},Eb.select=Eb.map=function(a,b){var c=this;return new Vb(function(d){var e=0;return c.subscribe(function(f){var g;try{g=a.call(b,f,e++,c)}catch(h){return d.onError(h),void 0}d.onNext(g)},d.onError.bind(d),d.onCompleted.bind(d))})},Eb.pluck=function(a){return this.select(function(b){return b[a]})},Eb.selectMany=Eb.flatMap=function(a,b){return b?this.selectMany(function(c){return a(c).select(function(a){return b(c,a)})}):"function"==typeof a?r.call(this,a):r.call(this,function(){return a})},Eb.selectSwitch=Eb.flatMapLatest=function(a,b){return this.select(a,b).switchLatest()},Eb.skip=function(a){if(0>a)throw new Error(C);var b=this;return new Vb(function(c){var d=a;return b.subscribe(function(a){0>=d?c.onNext(a):d--},c.onError.bind(c),c.onCompleted.bind(c))})},Eb.skipWhile=function(a,b){var c=this;return new Vb(function(d){var e=0,f=!1;return c.subscribe(function(g){if(!f)try{f=!a.call(b,g,e++,c)}catch(h){return d.onError(h),void 0}f&&d.onNext(g)},d.onError.bind(d),d.onCompleted.bind(d))})},Eb.take=function(a,b){if(0>a)throw new Error(C);if(0===a)return Lb(b);var c=this;return new Vb(function(b){var d=a;return c.subscribe(function(a){d>0&&(d--,b.onNext(a),0===d&&b.onCompleted())},b.onError.bind(b),b.onCompleted.bind(b))})},Eb.takeWhile=function(a,b){var c=this;return new Vb(function(d){var e=0,f=!0;return c.subscribe(function(g){if(f){try{f=a.call(b,g,e++,c)}catch(h){return d.onError(h),void 0}f?d.onNext(g):d.onCompleted()}},d.onError.bind(d),d.onCompleted.bind(d))})},Eb.where=Eb.filter=function(a,b){var c=this;return new Vb(function(d){var e=0;return c.subscribe(function(f){var g;try{g=a.call(b,f,e++,c)}catch(h){return d.onError(h),void 0}g&&d.onNext(f)},d.onError.bind(d),d.onCompleted.bind(d))})};var Vb=z.Internals.AnonymousObservable=function(a){function b(a){return"undefined"==typeof a?a=db:"function"==typeof a&&(a=cb(a)),a}function c(d){function e(a){var c=new Wb(a);if(nb.scheduleRequired())nb.schedule(function(){try{c.setDisposable(b(d(c)))}catch(a){if(!c.fail(a))throw a}});else try{c.setDisposable(b(d(c)))}catch(e){if(!c.fail(e))throw e}return c}return this instanceof c?(a.call(this,e),void 0):new c(d)}return T(c,a),c}(Kb),Wb=function(a){function b(b){a.call(this),this.observer=b,this.m=new fb}T(b,a);var c=b.prototype;return c.next=function(a){var b=!1;try{this.observer.onNext(a),b=!0}catch(c){throw c}finally{b||this.dispose()}},c.error=function(a){try{this.observer.onError(a)}catch(b){throw b}finally{this.dispose()}},c.completed=function(){try{this.observer.onCompleted()}catch(a){throw a}finally{this.dispose()}},c.setDisposable=function(a){this.m.setDisposable(a)},c.getDisposable=function(){return this.m.getDisposable()},c.disposable=function(a){return arguments.length?this.getDisposable():setDisposable(a)},c.dispose=function(){a.prototype.dispose.call(this),this.m.dispose()},b}(Fb),Xb=function(a){function b(a){return this.underlyingObservable.subscribe(a)}function c(c,d,e){a.call(this,b),this.key=c,this.underlyingObservable=e?new Vb(function(a){return new _(e.getDisposable(),d.subscribe(a))}):d}return T(c,a),c}(Kb),Yb=function(a,b){this.subject=a,this.observer=b};Yb.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1),this.observer=null}};var Zb=z.Subject=function(a){function b(a){return h.call(this),this.isStopped?this.exception?(a.onError(this.exception),db):(a.onCompleted(),db):(this.observers.push(a),new Yb(this,a))}function c(){a.call(this,b),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return T(c,a),U(c.prototype,Cb,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(h.call(this),!this.isStopped){var a=this.observers.slice(0);this.isStopped=!0;for(var b=0,c=a.length;c>b;b++)a[b].onCompleted();this.observers=[]}},onError:function(a){if(h.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,d=b.length;d>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){if(h.call(this),!this.isStopped)for(var b=this.observers.slice(0),c=0,d=b.length;d>c;c++)b[c].onNext(a)},dispose:function(){this.isDisposed=!0,this.observers=null}}),c.create=function(a,b){return new $b(a,b)},c}(Kb),$b=(z.AsyncSubject=function(a){function b(a){if(h.call(this),!this.isStopped)return this.observers.push(a),new Yb(this,a);var b=this.exception,c=this.hasValue,d=this.value;return b?a.onError(b):c?(a.onNext(d),a.onCompleted()):a.onCompleted(),db}function c(){a.call(this,b),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return T(c,a),U(c.prototype,Cb,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){var a,b,c;if(h.call(this),!this.isStopped){var d=this.observers.slice(0);this.isStopped=!0;var e=this.value,f=this.hasValue;if(f)for(b=0,c=d.length;c>b;b++)a=d[b],a.onNext(e),a.onCompleted();else for(b=0,c=d.length;c>b;b++)d[b].onCompleted();this.observers=[]}},onError:function(a){if(h.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,d=b.length;d>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){h.call(this),this.isStopped||(this.value=a,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),c}(Kb),function(a){function b(a){return this.observable.subscribe(a)}function c(c,d){a.call(this,b),this.observer=c,this.observable=d}return T(c,a),U(c.prototype,Cb,{onCompleted:function(){this.observer.onCompleted()},onError:function(a){this.observer.onError(a)},onNext:function(a){this.observer.onNext(a)}}),c}(Kb));"function"==typeof define&&"object"==typeof define.amd&&define.amd?(t.Rx=z,define(function(){return z})):u&&v?w?(v.exports=z).Rx=z:u.Rx=z:t.Rx=z}).call(this);
1
+ (function(a){function b(){}function c(a){return a}function d(a,b){return R(a,b)}function e(a,b){return a-b}function f(a){return a.toString()}function g(a){throw a}function h(){if(this.isDisposed)throw new Error(D)}function i(a){return"function"!=typeof a.toString&&"string"==typeof(a+"")}function j(a){return a&&"object"==typeof a?N.call(a)==E:!1}function k(a){return"function"==typeof a}function l(a,b,c,d){var e;if(a===b)return 0!==a||1/a==1/b;var f=typeof a,g=typeof b;if(!(a!==a||a&&s[f]||b&&s[g]))return!1;if(null==a||null==b)return a===b;var h=N.call(a),m=N.call(b);if(h==E&&(h=K),m==E&&(m=K),h!=m)return!1;switch(h){case G:case H:return+a==+b;case J:return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case L:case M:return a==String(b)}var n=h==F;if(!n){if(h!=K||!y&&(i(a)||i(b)))return!1;var o=!P&&j(a)?Object:a.constructor,p=!P&&j(b)?Object:b.constructor;if(o!=p&&!(k(o)&&o instanceof o&&k(p)&&p instanceof p))return!1}for(var q=c.length;q--;)if(c[q]==a)return d[q]==b;var r=0;if(e=!0,c.push(a),d.push(b),n){for(q=a.length,r=b.length,e=r==a.length;r--;){var t=b[r];if(!(e=l(a[r],t,c,d)))break}return e}for(var u in b)if(O.call(b,u))return r++,e=O.call(a,u)&&l(a[u],b[u],c,d);if(e)for(var u in a)if(O.call(a,u))return e=--r>-1;return c.pop(),d.pop(),e}function m(a,b){return 1===a.length&&Array.isArray(a[b])?a[b]:S.call(a)}function n(a,b){for(var c=new Array(a),d=0;a>d;d++)c[d]=b();return c}function o(a,b){this.scheduler=a,this.disposable=b,this.isDisposed=!1}function p(a,b){return new Sb(function(c){var d=new fb,e=new gb;return e.setDisposable(d),d.setDisposable(a.subscribe(c.onNext.bind(c),function(a){var d,f;try{f=b(a)}catch(g){return c.onError(g),void 0}d=new fb,e.setDisposable(d),d.setDisposable(f.subscribe(c))},c.onCompleted.bind(c))),e})}function q(a,b){var c=this;return new Sb(function(d){var e=0,f=a.length;return c.subscribe(function(c){if(f>e){var g,h=a[e++];try{g=b(c,h)}catch(i){return d.onError(i),void 0}d.onNext(g)}else d.onCompleted()},d.onError.bind(d),d.onCompleted.bind(d))})}function r(a){return this.select(a).mergeObservable()}var s={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},t=s[typeof window]&&window||this,u=s[typeof exports]&&exports&&!exports.nodeType&&exports,v=s[typeof module]&&module&&!module.nodeType&&module,w=v&&v.exports===u&&u,x=s[typeof global]&&global;!x||x.global!==x&&x.window!==x||(t=x);var y,z={Internals:{}},A=function(){return Date.now?Date.now:function(){return+new Date}}(),B="Sequence contains no elements.",C="Argument out of range",D="Object has been disposed",E="[object Arguments]",F="[object Array]",G="[object Boolean]",H="[object Date]",I="[object Function]",J="[object Number]",K="[object Object]",L="[object RegExp]",M="[object String]",N=Object.prototype.toString,O=Object.prototype.hasOwnProperty,P=N.call(arguments)==E;try{y=!(N.call(document)==K&&!({toString:0}+""))}catch(Q){y=!0}P||(j=function(a){return a&&"object"==typeof a?O.call(a,"callee"):!1}),k(/x/)&&(k=function(a){return"function"==typeof a&&N.call(a)==I});var R=z.Internals.isEqual=function(a,b){return l(a,b,[],[])},S=Array.prototype.slice,T=({}.hasOwnProperty,this.inherits=z.Internals.inherits=function(a,b){function c(){this.constructor=a}c.prototype=b.prototype,a.prototype=new c}),U=z.Internals.addProperties=function(a){for(var b=S.call(arguments,1),c=0,d=b.length;d>c;c++){var e=b[c];for(var f in e)a[f]=e[f]}},V=z.Internals.addRef=function(a,b){return new Sb(function(c){return new _(b.getDisposable(),a.subscribe(c))})};Function.prototype.bind||(Function.prototype.bind=function(a){var b=this,c=S.call(arguments,1),d=function(){function e(){}if(this instanceof d){e.prototype=b.prototype;var f=new e,g=b.apply(f,c.concat(S.call(arguments)));return Object(g)===g?g:f}return b.apply(a,c.concat(S.call(arguments)))};return d});var W=Object("a"),X="a"!=W[0]||!(0 in W);Array.prototype.every||(Array.prototype.every=function(a){var b=Object(this),c=X&&{}.toString.call(this)==M?this.split(""):b,d=c.length>>>0,e=arguments[1];if({}.toString.call(a)!=I)throw new TypeError(a+" is not a function");for(var f=0;d>f;f++)if(f in c&&!a.call(e,c[f],f,b))return!1;return!0}),Array.prototype.map||(Array.prototype.map=function(a){var b=Object(this),c=X&&{}.toString.call(this)==M?this.split(""):b,d=c.length>>>0,e=Array(d),f=arguments[1];if({}.toString.call(a)!=I)throw new TypeError(a+" is not a function");for(var g=0;d>g;g++)g in c&&(e[g]=a.call(f,c[g],g,b));return e}),Array.prototype.filter||(Array.prototype.filter=function(a){for(var b,c=[],d=new Object(this),e=0,f=d.length>>>0;f>e;e++)b=d[e],e in d&&a.call(arguments[1],b,e,d)&&c.push(b);return c}),Array.isArray||(Array.isArray=function(a){return Object.prototype.toString.call(a)==F}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a){var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>1&&(d=Number(arguments[1]),d!==d?d=0:0!==d&&1/0!=d&&d!==-1/0&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1});var Y=function(a,b){this.id=a,this.value=b};Y.prototype.compareTo=function(a){var b=this.value.compareTo(a.value);return 0===b&&(b=this.id-a.id),b};var Z=z.Internals.PriorityQueue=function(a){this.items=new Array(a),this.length=0},$=Z.prototype;$.isHigherPriority=function(a,b){return this.items[a].compareTo(this.items[b])<0},$.percolate=function(a){if(!(a>=this.length||0>a)){var b=a-1>>1;if(!(0>b||b===a)&&this.isHigherPriority(a,b)){var c=this.items[a];this.items[a]=this.items[b],this.items[b]=c,this.percolate(b)}}},$.heapify=function(b){if(b===a&&(b=0),!(b>=this.length||0>b)){var c=2*b+1,d=2*b+2,e=b;if(c<this.length&&this.isHigherPriority(c,e)&&(e=c),d<this.length&&this.isHigherPriority(d,e)&&(e=d),e!==b){var f=this.items[b];this.items[b]=this.items[e],this.items[e]=f,this.heapify(e)}}},$.peek=function(){return this.items[0].value},$.removeAt=function(a){this.items[a]=this.items[--this.length],delete this.items[this.length],this.heapify()},$.dequeue=function(){var a=this.peek();return this.removeAt(0),a},$.enqueue=function(a){var b=this.length++;this.items[b]=new Y(Z.count++,a),this.percolate(b)},$.remove=function(a){for(var b=0;b<this.length;b++)if(this.items[b].value===a)return this.removeAt(b),!0;return!1},Z.count=0;var _=z.CompositeDisposable=function(){this.disposables=m(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},ab=_.prototype;ab.add=function(a){this.isDisposed?a.dispose():(this.disposables.push(a),this.length++)},ab.remove=function(a){var b=!1;if(!this.isDisposed){var c=this.disposables.indexOf(a);-1!==c&&(b=!0,this.disposables.splice(c,1),this.length--,a.dispose())}return b},ab.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var a=this.disposables.slice(0);this.disposables=[],this.length=0;for(var b=0,c=a.length;c>b;b++)a[b].dispose()}},ab.clear=function(){var a=this.disposables.slice(0);this.disposables=[],this.length=0;for(var b=0,c=a.length;c>b;b++)a[b].dispose()},ab.contains=function(a){return-1!==this.disposables.indexOf(a)},ab.toArray=function(){return this.disposables.slice(0)};var bb=z.Disposable=function(a){this.isDisposed=!1,this.action=a||b};bb.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var cb=bb.create=function(a){return new bb(a)},db=bb.empty={dispose:b},eb=function(){function a(a){this.isSingle=a,this.isDisposed=!1,this.current=null}var b=a.prototype;return b.getDisposable=function(){return this.current},b.setDisposable=function(a){if(this.current&&this.isSingle)throw new Error("Disposable has already been assigned");var b,c=this.isDisposed;c||(b=this.current,this.current=a),b&&b.dispose(),c&&a&&a.dispose()},b.dispose=function(){var a;this.isDisposed||(this.isDisposed=!0,a=this.current,this.current=null),a&&a.dispose()},a}(),fb=z.SingleAssignmentDisposable=function(a){function b(){a.call(this,!0)}return T(b,a),b}(eb),gb=z.SerialDisposable=function(a){function b(){a.call(this,!1)}return T(b,a),b}(eb),hb=z.RefCountDisposable=function(){function a(a){this.disposable=a,this.disposable.count++,this.isInnerDisposed=!1}function b(a){this.underlyingDisposable=a,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return a.prototype.dispose=function(){this.disposable.isDisposed||this.isInnerDisposed||(this.isInnerDisposed=!0,this.disposable.count--,0===this.disposable.count&&this.disposable.isPrimaryDisposed&&(this.disposable.isDisposed=!0,this.disposable.underlyingDisposable.dispose()))},b.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},b.prototype.getDisposable=function(){return this.isDisposed?db:new a(this)},b}();o.prototype.dispose=function(){var a=this;this.scheduler.schedule(function(){a.isDisposed||(a.isDisposed=!0,a.disposable.dispose())})};var ib=z.Internals.ScheduledItem=function(a,b,c,d,f){this.scheduler=a,this.state=b,this.action=c,this.dueTime=d,this.comparer=f||e,this.disposable=new fb};ib.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},ib.prototype.compareTo=function(a){return this.comparer(this.dueTime,a.dueTime)},ib.prototype.isCancelled=function(){return this.disposable.isDisposed},ib.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var jb,kb=z.Scheduler=function(){function a(a,b,c,d){this.now=a,this._schedule=b,this._scheduleRelative=c,this._scheduleAbsolute=d}function b(a,b){var c=b.first,d=b.second,e=new _,f=function(b){d(b,function(b){var c=!1,d=!1,g=a.scheduleWithState(b,function(a,b){return c?e.remove(g):d=!0,f(b),db});d||(e.add(g),c=!0)})};return f(c),e}function c(a,b,c){var d=b.first,e=b.second,f=new _,g=function(b){e(b,function(b,d){var e=!1,h=!1,i=a[c].call(a,b,d,function(a,b){return e?f.remove(i):h=!0,g(b),db});h||(f.add(i),e=!0)})};return g(d),f}function d(a,b){return b(),db}var e=a.prototype;return e.catchException=e["catch"]=function(a){return new pb(this,a)},e.schedulePeriodic=function(a,b){return this.schedulePeriodicWithState(null,a,function(){b()})},e.schedulePeriodicWithState=function(a,b,c){var d=a,e=setInterval(function(){d=c(d)},b);return cb(function(){clearInterval(e)})},e.schedule=function(a){return this._schedule(a,d)},e.scheduleWithState=function(a,b){return this._schedule(a,b)},e.scheduleWithRelative=function(a,b){return this._scheduleRelative(b,a,d)},e.scheduleWithRelativeAndState=function(a,b,c){return this._scheduleRelative(a,b,c)},e.scheduleWithAbsolute=function(a,b){return this._scheduleAbsolute(b,a,d)},e.scheduleWithAbsoluteAndState=function(a,b,c){return this._scheduleAbsolute(a,b,c)},e.scheduleRecursive=function(a){return this.scheduleRecursiveWithState(a,function(a,b){a(function(){b(a)})})},e.scheduleRecursiveWithState=function(a,c){return this.scheduleWithState({first:a,second:c},function(a,c){return b(a,c)})},e.scheduleRecursiveWithRelative=function(a,b){return this.scheduleRecursiveWithRelativeAndState(b,a,function(a,b){a(function(c){b(a,c)})})},e.scheduleRecursiveWithRelativeAndState=function(a,b,d){return this._scheduleRelative({first:a,second:d},b,function(a,b){return c(a,b,"scheduleWithRelativeAndState")})},e.scheduleRecursiveWithAbsolute=function(a,b){return this.scheduleRecursiveWithAbsoluteAndState(b,a,function(a,b){a(function(c){b(a,c)})})},e.scheduleRecursiveWithAbsoluteAndState=function(a,b,d){return this._scheduleAbsolute({first:a,second:d},b,function(a,b){return c(a,b,"scheduleWithAbsoluteAndState")})},a.now=A,a.normalize=function(a){return 0>a&&(a=0),a},a}(),lb=kb.normalize,mb=(z.Internals.SchedulePeriodicRecursive=function(){function a(a,b){b(0,this._period);try{this._state=this._action(this._state)}catch(c){throw this._cancel.dispose(),c}}function b(a,b,c,d){this._scheduler=a,this._state=b,this._period=c,this._action=d}return b.prototype.start=function(){var b=new fb;return this._cancel=b,b.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,a.bind(this))),b},b}(),kb.immediate=function(){function a(a,b){return b(this,a)}function b(a,b,c){for(var d=lb(d);d-this.now()>0;);return c(this,a)}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new kb(A,a,b,c)}()),nb=kb.currentThread=function(){function a(a){for(var b;a.length>0;)if(b=a.dequeue(),!b.isCancelled()){for(;b.dueTime-kb.now()>0;);b.isCancelled()||b.invoke()}}function b(a,b){return this.scheduleWithRelativeAndState(a,0,b)}function c(b,c,d){var f=this.now()+kb.normalize(c),g=new ib(this,b,d,f);if(e)e.enqueue(g);else{e=new Z(4),e.enqueue(g);try{a(e)}catch(h){throw h}finally{e=null}}return g.disposable}function d(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}var e,f=new kb(A,b,c,d);return f.scheduleRequired=function(){return null===e},f.ensureTrampoline=function(a){return null===e?this.schedule(a):a()},f}(),ob=b;!function(){function a(){if(!t.postMessage||t.importScripts)return!1;var a=!1,b=t.onmessage;return t.onmessage=function(){a=!0},t.postMessage("","*"),t.onmessage=b,a}function b(a){for(var b=0,c=a.length;c>b;b++){var d=a[b].target.getAttribute("drainQueue");h[d](),delete h[d]}}function c(a){if("string"==typeof a.data&&a.data.substring(0,l.length)===l){var b=a.data.substring(l.length),c=m[b];c(),delete m[b]}}var d=RegExp("^"+String(N).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),e="function"==typeof(e=x&&w&&x.setImmediate)&&!d.test(e)&&e,f="function"==typeof(f=x&&w&&x.clearImmediate)&&!d.test(f)&&f,g=t.MutationObserver||t.WebKitMutationObserver;if(g){var h={},i=0,j=new g(b),k=document.createElement("div");j.observe(k,{attributes:!0}),t.addEventListener("unload",function(){j.disconnect(),j=null}),jb=function(a){var b=i++;return h[b]=a,k.setAttribute("drainQueue",b),b},ob=function(a){delete h[a]}}else if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))jb=process.nextTick;else if("function"==typeof e)jb=e,ob=f;else if(a()){var l="ms.rx.schedule"+Math.random(),m={},n=0;t.addEventListener?t.addEventListener("message",c,!1):t.attachEvent("onmessage",c,!1),jb=function(a){var b=n++;m[b]=a,t.postMessage(l+b,"*")}}else if(t.MessageChannel){var o=new t.MessageChannel,p={},q=0;o.port1.onmessage=function(a){var b=a.data,c=p[b];c(),delete p[b]},jb=function(a){var b=q++;p[b]=a,o.port2.postMessage(b)}}else"document"in t&&"onreadystatechange"in t.document.createElement("script")?jb=function(a){var b=t.document.createElement("script");b.onreadystatechange=function(){a(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},t.document.documentElement.appendChild(b)}:(jb=function(a){return setTimeout(a,0)},ob=clearTimeout)}();var pb=(kb.timeout=function(){function a(a,b){var c=this,d=new fb,e=jb(function(){d.isDisposed||d.setDisposable(b(c,a))});return new _(d,cb(function(){ob(e)}))}function b(a,b,c){var d=this,e=kb.normalize(b);if(0===e)return d.scheduleWithState(a,c);var f=new fb,g=setTimeout(function(){f.isDisposed||f.setDisposable(c(d,a))},e);return new _(f,cb(function(){clearTimeout(g)}))}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new kb(A,a,b,c)}(),function(a){function b(){return this._scheduler.now()}function c(a,b){return this._scheduler.scheduleWithState(a,this._wrap(b))}function d(a,b,c){return this._scheduler.scheduleWithRelativeAndState(a,b,this._wrap(c))}function e(a,b,c){return this._scheduler.scheduleWithAbsoluteAndState(a,b,this._wrap(c))}function f(f,g){this._scheduler=f,this._handler=g,this._recursiveOriginal=null,this._recursiveWrapper=null,a.call(this,b,c,d,e)}return T(f,a),f.prototype._clone=function(a){return new f(a,this._handler)},f.prototype._wrap=function(a){var b=this;return function(c,d){try{return a(b._getRecursiveWrapper(c),d)}catch(e){if(!b._handler(e))throw e;return db}}},f.prototype._getRecursiveWrapper=function(a){if(this._recursiveOriginal!==a){this._recursiveOriginal=a;var b=this._clone(a);b._recursiveOriginal=a,b._recursiveWrapper=b,this._recursiveWrapper=b}return this._recursiveWrapper},f.prototype.schedulePeriodicWithState=function(a,b,c){var d=this,e=!1,f=new fb;return f.setDisposable(this._scheduler.schedulePeriodicWithState(a,b,function(a){if(e)return null;try{return c(a)}catch(b){if(e=!0,!d._handler(b))throw b;return f.dispose(),null}})),f},f}(kb)),qb=z.Notification=function(){function a(a,b){this.hasValue=null==b?!1:b,this.kind=a}var b=a.prototype;return b.accept=function(a,b,c){return 1===arguments.length&&"object"==typeof a?this._acceptObservable(a):this._accept(a,b,c)},b.toObservable=function(a){var b=this;return a||(a=mb),new Sb(function(c){return a.schedule(function(){b._acceptObservable(c),"N"===b.kind&&c.onCompleted()})})},a}(),rb=qb.createOnNext=function(){function a(a){return a(this.value)}function b(a){return a.onNext(this.value)}function c(){return"OnNext("+this.value+")"}return function(d){var e=new qb("N",!0);return e.value=d,e._accept=a,e._acceptObservable=b,e.toString=c,e}}(),sb=qb.createOnError=function(){function a(a,b){return b(this.exception)}function b(a){return a.onError(this.exception)}function c(){return"OnError("+this.exception+")"}return function(d){var e=new qb("E");return e.exception=d,e._accept=a,e._acceptObservable=b,e.toString=c,e}}(),tb=qb.createOnCompleted=function(){function a(a,b,c){return c()}function b(a){return a.onCompleted()}function c(){return"OnCompleted()"}return function(){var d=new qb("C");return d._accept=a,d._acceptObservable=b,d.toString=c,d}}(),ub=z.Internals.Enumerator=function(a,b){this.moveNext=a,this.getCurrent=b},vb=ub.create=function(a,b){var c=!1;return new ub(function(){if(c)return!1;var b=a();return b||(c=!0),b},function(){return b()})},wb=z.Internals.Enumerable=function(a){this.getEnumerator=a};wb.prototype.concat=function(){var a=this;return new Sb(function(b){var c,d=a.getEnumerator(),e=new gb,f=mb.scheduleRecursive(function(a){var f,g;if(!c){try{g=d.moveNext(),g&&(f=d.getCurrent())}catch(h){return b.onError(h),void 0}if(!g)return b.onCompleted(),void 0;var i=new fb;e.setDisposable(i),i.setDisposable(f.subscribe(b.onNext.bind(b),b.onError.bind(b),function(){a()}))}});return new _(e,f,cb(function(){c=!0}))})},wb.prototype.catchException=function(){var a=this;return new Sb(function(b){var c,d,e=a.getEnumerator(),f=new gb,g=mb.scheduleRecursive(function(a){var g,h;if(!c){try{h=e.moveNext(),h&&(g=e.getCurrent())}catch(i){return b.onError(i),void 0}if(!h)return d?b.onError(d):b.onCompleted(),void 0;var j=new fb;f.setDisposable(j),j.setDisposable(g.subscribe(b.onNext.bind(b),function(b){d=b,a()},b.onCompleted.bind(b)))}});return new _(f,g,cb(function(){c=!0}))})};var xb=wb.repeat=function(a,b){return 1===arguments.length&&(b=-1),new wb(function(){var c,d=b;return vb(function(){return 0===d?!1:(d>0&&d--,c=a,!0)},function(){return c})})},yb=wb.forEach=function(a,b,d){return b||(b=c),new wb(function(){var c,e=-1;return vb(function(){return++e<a.length?(c=b.call(d,a[e],e,a),!0):!1},function(){return c})})},zb=z.Observer=function(){};zb.prototype.toNotifier=function(){var a=this;return function(b){return b.accept(a)}},zb.prototype.asObserver=function(){return new Db(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},zb.prototype.checked=function(){return new Eb(this)};var Ab=zb.create=function(a,c,d){return a||(a=b),c||(c=g),d||(d=b),new Db(a,c,d)};zb.fromNotifier=function(a){return new Db(function(b){return a(rb(b))},function(b){return a(sb(b))},function(){return a(tb())})},zb.notifyOn=function(a){return new Gb(a,this)};var Bb,Cb=z.Internals.AbstractObserver=function(a){function b(){this.isStopped=!1,a.call(this)}return T(b,a),b.prototype.onNext=function(a){this.isStopped||this.next(a)},b.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.error(a))},b.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},b.prototype.dispose=function(){this.isStopped=!0},b.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.error(a),!0)},b}(zb),Db=z.AnonymousObserver=function(a){function b(b,c,d){a.call(this),this._onNext=b,this._onError=c,this._onCompleted=d}return T(b,a),b.prototype.next=function(a){this._onNext(a)},b.prototype.error=function(a){this._onError(a)},b.prototype.completed=function(){this._onCompleted()},b}(Cb),Eb=function(a){function b(b){a.call(this),this._observer=b,this._state=0}T(b,a);var c=b.prototype;return c.onNext=function(a){this.checkAccess();try{this._observer.onNext(a)}catch(b){throw b}finally{this._state=0}},c.onError=function(a){this.checkAccess();try{this._observer.onError(a)}catch(b){throw b}finally{this._state=2}},c.onCompleted=function(){this.checkAccess();try{this._observer.onCompleted()}catch(a){throw a}finally{this._state=2}},c.checkAccess=function(){if(1===this._state)throw new Error("Re-entrancy detected");if(2===this._state)throw new Error("Observer completed");0===this._state&&(this._state=1)},b}(zb),Fb=z.Internals.ScheduledObserver=function(a){function b(b,c){a.call(this),this.scheduler=b,this.observer=c,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new gb}return T(b,a),b.prototype.next=function(a){var b=this;this.queue.push(function(){b.observer.onNext(a)})},b.prototype.error=function(a){var b=this;this.queue.push(function(){b.observer.onError(a)})},b.prototype.completed=function(){var a=this;this.queue.push(function(){a.observer.onCompleted()})},b.prototype.ensureActive=function(){var a=!1,b=this;!this.hasFaulted&&this.queue.length>0&&(a=!this.isAcquired,this.isAcquired=!0),a&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(a){var c;if(!(b.queue.length>0))return b.isAcquired=!1,void 0;c=b.queue.shift();try{c()}catch(d){throw b.queue=[],b.hasFaulted=!0,d}a()}))},b.prototype.dispose=function(){a.prototype.dispose.call(this),this.disposable.dispose()},b}(Cb),Gb=function(a){function b(){a.apply(this,arguments)}return T(b,a),b.prototype.next=function(b){a.prototype.next.call(this,b),this.ensureActive()},b.prototype.error=function(b){a.prototype.error.call(this,b),this.ensureActive()},b.prototype.completed=function(){a.prototype.completed.call(this),this.ensureActive()},b}(Fb),Hb=z.Observable=function(){function a(a){this._subscribe=a}return Bb=a.prototype,Bb.finalValue=function(){var a=this;return new Sb(function(b){var c,d=!1;return a.subscribe(function(a){d=!0,c=a},b.onError.bind(b),function(){d?(b.onNext(c),b.onCompleted()):b.onError(new Error(B))})})},Bb.subscribe=Bb.forEach=function(a,b,c){var d;return d="object"==typeof a?a:Ab(a,b,c),this._subscribe(d)},Bb.toArray=function(){function a(a,b){var c=a.slice(0);return c.push(b),c}return this.scan([],a).startWith([]).finalValue()},a}();Bb.observeOn=function(a){var b=this;return new Sb(function(c){return b.subscribe(new Gb(a,c))})},Bb.subscribeOn=function(a){var b=this;return new Sb(function(c){var d=new fb,e=new gb;return e.setDisposable(d),d.setDisposable(a.schedule(function(){e.setDisposable(new o(a,b.subscribe(c)))})),e})},Hb.create=Hb.createWithDisposable=function(a){return new Sb(a)};var Ib=(Hb.defer=function(a){return new Sb(function(b){var c;try{c=a()}catch(d){return Mb(d).subscribe(b)}return c.subscribe(b)})},Hb.empty=function(a){return a||(a=mb),new Sb(function(b){return a.schedule(function(){b.onCompleted()})})}),Jb=Hb.fromArray=function(a,b){return b||(b=nb),new Sb(function(c){var d=0;return b.scheduleRecursive(function(b){d<a.length?(c.onNext(a[d++]),b()):c.onCompleted()})})};Hb.generate=function(a,b,c,d,e){return e||(e=nb),new Sb(function(f){var g=!0,h=a;return e.scheduleRecursive(function(a){var e,i;try{g?g=!1:h=c(h),e=b(h),e&&(i=d(h))}catch(j){return f.onError(j),void 0}e?(f.onNext(i),a()):f.onCompleted()})})};var Kb=Hb.never=function(){return new Sb(function(){return db})};Hb.range=function(a,b,c){return c||(c=nb),new Sb(function(d){return c.scheduleRecursiveWithState(0,function(c,e){b>c?(d.onNext(a+c),e(c+1)):d.onCompleted()})})},Hb.repeat=function(a,b,c){return c||(c=nb),null==b&&(b=-1),Lb(a,c).repeat(b)};var Lb=Hb["return"]=Hb.returnValue=function(a,b){return b||(b=mb),new Sb(function(c){return b.schedule(function(){c.onNext(a),c.onCompleted()})})},Mb=Hb["throw"]=Hb.throwException=function(a,b){return b||(b=mb),new Sb(function(c){return b.schedule(function(){c.onError(a)})})};Hb.using=function(a,b){return new Sb(function(c){var d,e,f=db;try{d=a(),d&&(f=d),e=b(d)}catch(g){return new _(Mb(g).subscribe(c),f)}return new _(e.subscribe(c),f)})},Bb.amb=function(a){var b=this;return new Sb(function(c){function d(){f||(f=g,j.dispose())}function e(){f||(f=h,i.dispose())}var f,g="L",h="R",i=new fb,j=new fb;return i.setDisposable(b.subscribe(function(a){d(),f===g&&c.onNext(a)},function(a){d(),f===g&&c.onError(a)},function(){d(),f===g&&c.onCompleted()})),j.setDisposable(a.subscribe(function(a){e(),f===h&&c.onNext(a)},function(a){e(),f===h&&c.onError(a)},function(){e(),f===h&&c.onCompleted()})),new _(i,j)})},Hb.amb=function(){function a(a,b){return a.amb(b)}for(var b=Kb(),c=m(arguments,0),d=0,e=c.length;e>d;d++)b=a(b,c[d]);return b},Bb["catch"]=Bb.catchException=function(a){return"function"==typeof a?p(this,a):Nb([this,a])};var Nb=Hb.catchException=Hb["catch"]=function(){var a=m(arguments,0);return yb(a).catchException()};Bb.combineLatest=function(){var a=S.call(arguments);return Array.isArray(a[0])?a[0].unshift(this):a.unshift(this),Ob.apply(this,a)};var Ob=Hb.combineLatest=function(){var a=S.call(arguments),b=a.pop();return Array.isArray(a[0])&&(a=a[0]),new Sb(function(d){function e(a){var e;if(i[a]=!0,j||(j=i.every(c))){try{e=b.apply(null,l)}catch(f){return d.onError(f),void 0}d.onNext(e)}else k.filter(function(b,c){return c!==a}).every(c)&&d.onCompleted()}function f(a){k[a]=!0,k.every(c)&&d.onCompleted()}for(var g=function(){return!1},h=a.length,i=n(h,g),j=!1,k=n(h,g),l=new Array(h),m=new Array(h),o=0;h>o;o++)!function(b){m[b]=new fb,m[b].setDisposable(a[b].subscribe(function(a){l[b]=a,e(b)},d.onError.bind(d),function(){f(b)}))}(o);return new _(m)})};Bb.concat=function(){var a=S.call(arguments,0);return a.unshift(this),Pb.apply(this,a)};var Pb=Hb.concat=function(){var a=m(arguments,0);return yb(a).concat()};Bb.concatObservable=Bb.concatAll=function(){return this.merge(1)},Bb.merge=function(a){if("number"!=typeof a)return Qb(this,a);var b=this;return new Sb(function(c){var d=0,e=new _,f=!1,g=[],h=function(a){var b=new fb;e.add(b),b.setDisposable(a.subscribe(c.onNext.bind(c),c.onError.bind(c),function(){var a;e.remove(b),g.length>0?(a=g.shift(),h(a)):(d--,f&&0===d&&c.onCompleted())}))};return e.add(b.subscribe(function(b){a>d?(d++,h(b)):g.push(b)},c.onError.bind(c),function(){f=!0,0===d&&c.onCompleted()})),e})};var Qb=Hb.merge=function(){var a,b;return arguments[0]?arguments[0].now?(a=arguments[0],b=S.call(arguments,1)):(a=mb,b=S.call(arguments,0)):(a=mb,b=S.call(arguments,1)),Array.isArray(b[0])&&(b=b[0]),Jb(b,a).mergeObservable()};Bb.mergeObservable=Bb.mergeAll=function(){var a=this;return new Sb(function(b){var c=new _,d=!1,e=new fb;return c.add(e),e.setDisposable(a.subscribe(function(a){var e=new fb;c.add(e),e.setDisposable(a.subscribe(function(a){b.onNext(a)},b.onError.bind(b),function(){c.remove(e),d&&1===c.length&&b.onCompleted()}))},b.onError.bind(b),function(){d=!0,1===c.length&&b.onCompleted()})),c})},Bb.onErrorResumeNext=function(a){if(!a)throw new Error("Second observable is required");return Rb([this,a])};var Rb=Hb.onErrorResumeNext=function(){var a=m(arguments,0);return new Sb(function(b){var c=0,d=new gb,e=mb.scheduleRecursive(function(e){var f,g;c<a.length?(f=a[c++],g=new fb,d.setDisposable(g),g.setDisposable(f.subscribe(b.onNext.bind(b),function(){e()},function(){e()}))):b.onCompleted()});return new _(d,e)})};Bb.skipUntil=function(a){var b=this;return new Sb(function(c){var d=!1,e=new _(b.subscribe(function(a){d&&c.onNext(a)},c.onError.bind(c),function(){d&&c.onCompleted()})),f=new fb;return e.add(f),f.setDisposable(a.subscribe(function(){d=!0,f.dispose()},c.onError.bind(c),function(){f.dispose()})),e})},Bb["switch"]=Bb.switchLatest=function(){var a=this;return new Sb(function(b){var c=!1,d=new gb,e=!1,f=0,g=a.subscribe(function(a){var g=new fb,h=++f;c=!0,d.setDisposable(g),g.setDisposable(a.subscribe(function(a){f===h&&b.onNext(a)},function(a){f===h&&b.onError(a)},function(){f===h&&(c=!1,e&&b.onCompleted())}))},b.onError.bind(b),function(){e=!0,c||b.onCompleted()});return new _(g,d)})},Bb.takeUntil=function(a){var c=this;return new Sb(function(d){return new _(c.subscribe(d),a.subscribe(d.onCompleted.bind(d),d.onError.bind(d),b))})},Bb.zip=function(){if(Array.isArray(arguments[0]))return q.apply(this,arguments);var a=this,b=S.call(arguments),d=b.pop();return b.unshift(a),new Sb(function(e){function f(a){i[a]=!0,i.every(function(a){return a})&&e.onCompleted()}for(var g=b.length,h=n(g,function(){return[]}),i=n(g,function(){return!1}),j=function(b){var f,g;if(h.every(function(a){return a.length>0})){try{g=h.map(function(a){return a.shift()}),f=d.apply(a,g)}catch(j){return e.onError(j),void 0}e.onNext(f)}else i.filter(function(a,c){return c!==b}).every(c)&&e.onCompleted()},k=new Array(g),l=0;g>l;l++)!function(a){k[a]=new fb,k[a].setDisposable(b[a].subscribe(function(b){h[a].push(b),j(a)},e.onError.bind(e),function(){f(a)}))}(l);return new _(k)})},Hb.zip=function(){var a=S.call(arguments,0),b=a.shift();return b.zip.apply(b,a)},Hb.zipArray=function(){var a=m(arguments,0);return new Sb(function(b){function d(a){if(g.every(function(a){return a.length>0})){var d=g.map(function(a){return a.shift()});b.onNext(d)}else if(h.filter(function(b,c){return c!==a}).every(c))return b.onCompleted(),void 0}function e(a){return h[a]=!0,h.every(c)?(b.onCompleted(),void 0):void 0}for(var f=a.length,g=n(f,function(){return[]}),h=n(f,function(){return!1}),i=new Array(f),j=0;f>j;j++)!function(c){i[c]=new fb,i[c].setDisposable(a[c].subscribe(function(a){g[c].push(a),d(c)},b.onError.bind(b),function(){e(c)}))}(j);var k=new _(i);return k.add(cb(function(){for(var a=0,b=g.length;b>a;a++)g[a]=[]})),k})},Bb.asObservable=function(){var a=this;return new Sb(function(b){return a.subscribe(b)})},Bb.bufferWithCount=function(a,b){return 1===arguments.length&&(b=a),this.windowWithCount(a,b).selectMany(function(a){return a.toArray()}).where(function(a){return a.length>0})},Bb.dematerialize=function(){var a=this;return new Sb(function(b){return a.subscribe(function(a){return a.accept(b)},b.onError.bind(b),b.onCompleted.bind(b))})},Bb.distinctUntilChanged=function(a,b){var e=this;return a||(a=c),b||(b=d),new Sb(function(c){var d,f=!1;return e.subscribe(function(e){var g,h=!1;try{g=a(e)}catch(i){return c.onError(i),void 0}if(f)try{h=b(d,g)}catch(i){return c.onError(i),void 0}f&&h||(f=!0,d=g,c.onNext(e))},c.onError.bind(c),c.onCompleted.bind(c))})},Bb["do"]=Bb.doAction=function(a,b,c){var d,e=this;return"function"==typeof a?d=a:(d=a.onNext.bind(a),b=a.onError.bind(a),c=a.onCompleted.bind(a)),new Sb(function(a){return e.subscribe(function(b){try{d(b)}catch(c){a.onError(c)}a.onNext(b)},function(c){if(b){try{b(c)}catch(d){a.onError(d)}a.onError(c)}else a.onError(c)},function(){if(c){try{c()}catch(b){a.onError(b)}a.onCompleted()}else a.onCompleted()})})},Bb["finally"]=Bb.finallyAction=function(a){var b=this;return new Sb(function(c){var d=b.subscribe(c);return cb(function(){try{d.dispose()}catch(b){throw b}finally{a()}})})},Bb.ignoreElements=function(){var a=this;return new Sb(function(c){return a.subscribe(b,c.onError.bind(c),c.onCompleted.bind(c))})},Bb.materialize=function(){var a=this;return new Sb(function(b){return a.subscribe(function(a){b.onNext(rb(a))},function(a){b.onNext(sb(a)),b.onCompleted()},function(){b.onNext(tb()),b.onCompleted()})})},Bb.repeat=function(a){return xb(this,a).concat()},Bb.retry=function(a){return xb(this,a).catchException()},Bb.scan=function(){var a,b,c=!1,d=this;return 2===arguments.length?(c=!0,a=arguments[0],b=arguments[1]):b=arguments[0],new Sb(function(e){var f,g,h;return d.subscribe(function(d){try{h||(h=!0),f?g=b(g,d):(g=c?b(a,d):d,f=!0)
2
+ }catch(i){return e.onError(i),void 0}e.onNext(g)},e.onError.bind(e),function(){!h&&c&&e.onNext(a),e.onCompleted()})})},Bb.skipLast=function(a){var b=this;return new Sb(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&c.onNext(d.shift())},c.onError.bind(c),c.onCompleted.bind(c))})},Bb.startWith=function(){var a,b,c=0;return arguments.length&&"now"in Object(arguments[0])?(b=arguments[0],c=1):b=mb,a=S.call(arguments,c),yb([Jb(a,b),this]).concat()},Bb.takeLast=function(a,b){return this.takeLastBuffer(a).selectMany(function(a){return Jb(a,b)})},Bb.takeLastBuffer=function(a){var b=this;return new Sb(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&d.shift()},c.onError.bind(c),function(){c.onNext(d),c.onCompleted()})})},Bb.windowWithCount=function(a,b){var c=this;if(0>=a)throw new Error(C);if(1===arguments.length&&(b=a),0>=b)throw new Error(C);return new Sb(function(d){var e=new fb,f=new hb(e),g=0,h=[],i=function(){var a=new Wb;h.push(a),d.onNext(V(a,f))};return i(),e.setDisposable(c.subscribe(function(c){for(var d,e=0,f=h.length;f>e;e++)h[e].onNext(c);var j=g-a+1;j>=0&&j%b===0&&(d=h.shift(),d.onCompleted()),g++,g%b===0&&i()},function(a){for(;h.length>0;)h.shift().onError(a);d.onError(a)},function(){for(;h.length>0;)h.shift().onCompleted();d.onCompleted()})),f})},Bb.defaultIfEmpty=function(b){var c=this;return b===a&&(b=null),new Sb(function(a){var d=!1;return c.subscribe(function(b){d=!0,a.onNext(b)},a.onError.bind(a),function(){d||a.onNext(b),a.onCompleted()})})},Bb.distinct=function(a,b){var d=this;return a||(a=c),b||(b=f),new Sb(function(c){var e={};return d.subscribe(function(d){var f,g,h,i=!1;try{f=a(d),g=b(f)}catch(j){return c.onError(j),void 0}for(h in e)if(g===h){i=!0;break}i||(e[g]=null,c.onNext(d))},c.onError.bind(c),c.onCompleted.bind(c))})},Bb.groupBy=function(a,b,c){return this.groupByUntil(a,b,function(){return Kb()},c)},Bb.groupByUntil=function(a,d,e,g){var h=this;return d||(d=c),g||(g=f),new Sb(function(c){var f={},i=new _,j=new hb(i);return i.add(h.subscribe(function(h){var k,l,m,n,o,p,q,r,s,t;try{p=a(h),q=g(p)}catch(u){for(t in f)f[t].onError(u);return c.onError(u),void 0}n=!1;try{s=f[q],s||(s=new Wb,f[q]=s,n=!0)}catch(u){for(t in f)f[t].onError(u);return c.onError(u),void 0}if(n){o=new Ub(p,s,j),l=new Ub(p,s);try{k=e(l)}catch(u){for(t in f)f[t].onError(u);return c.onError(u),void 0}c.onNext(o),r=new fb,i.add(r);var v=function(){q in f&&(delete f[q],s.onCompleted()),i.remove(r)};r.setDisposable(k.take(1).subscribe(b,function(a){for(t in f)f[t].onError(a);c.onError(a)},function(){v()}))}try{m=d(h)}catch(u){for(t in f)f[t].onError(u);return c.onError(u),void 0}s.onNext(m)},function(a){for(var b in f)f[b].onError(a);c.onError(a)},function(){for(var a in f)f[a].onCompleted();c.onCompleted()})),j})},Bb.select=Bb.map=function(a,b){var c=this;return new Sb(function(d){var e=0;return c.subscribe(function(f){var g;try{g=a.call(b,f,e++,c)}catch(h){return d.onError(h),void 0}d.onNext(g)},d.onError.bind(d),d.onCompleted.bind(d))})},Bb.pluck=function(a){return this.select(function(b){return b[a]})},Bb.selectMany=Bb.flatMap=function(a,b){return b?this.selectMany(function(c){return a(c).select(function(a){return b(c,a)})}):"function"==typeof a?r.call(this,a):r.call(this,function(){return a})},Bb.selectSwitch=Bb.flatMapLatest=function(a,b){return this.select(a,b).switchLatest()},Bb.skip=function(a){if(0>a)throw new Error(C);var b=this;return new Sb(function(c){var d=a;return b.subscribe(function(a){0>=d?c.onNext(a):d--},c.onError.bind(c),c.onCompleted.bind(c))})},Bb.skipWhile=function(a,b){var c=this;return new Sb(function(d){var e=0,f=!1;return c.subscribe(function(g){if(!f)try{f=!a.call(b,g,e++,c)}catch(h){return d.onError(h),void 0}f&&d.onNext(g)},d.onError.bind(d),d.onCompleted.bind(d))})},Bb.take=function(a,b){if(0>a)throw new Error(C);if(0===a)return Ib(b);var c=this;return new Sb(function(b){var d=a;return c.subscribe(function(a){d>0&&(d--,b.onNext(a),0===d&&b.onCompleted())},b.onError.bind(b),b.onCompleted.bind(b))})},Bb.takeWhile=function(a,b){var c=this;return new Sb(function(d){var e=0,f=!0;return c.subscribe(function(g){if(f){try{f=a.call(b,g,e++,c)}catch(h){return d.onError(h),void 0}f?d.onNext(g):d.onCompleted()}},d.onError.bind(d),d.onCompleted.bind(d))})},Bb.where=Bb.filter=function(a,b){var c=this;return new Sb(function(d){var e=0;return c.subscribe(function(f){var g;try{g=a.call(b,f,e++,c)}catch(h){return d.onError(h),void 0}g&&d.onNext(f)},d.onError.bind(d),d.onCompleted.bind(d))})};var Sb=z.Internals.AnonymousObservable=function(a){function b(a){return"undefined"==typeof a?a=db:"function"==typeof a&&(a=cb(a)),a}function c(d){function e(a){var c=new Tb(a);if(nb.scheduleRequired())nb.schedule(function(){try{c.setDisposable(b(d(c)))}catch(a){if(!c.fail(a))throw a}});else try{c.setDisposable(b(d(c)))}catch(e){if(!c.fail(e))throw e}return c}return this instanceof c?(a.call(this,e),void 0):new c(d)}return T(c,a),c}(Hb),Tb=function(a){function b(b){a.call(this),this.observer=b,this.m=new fb}T(b,a);var c=b.prototype;return c.next=function(a){var b=!1;try{this.observer.onNext(a),b=!0}catch(c){throw c}finally{b||this.dispose()}},c.error=function(a){try{this.observer.onError(a)}catch(b){throw b}finally{this.dispose()}},c.completed=function(){try{this.observer.onCompleted()}catch(a){throw a}finally{this.dispose()}},c.setDisposable=function(a){this.m.setDisposable(a)},c.getDisposable=function(){return this.m.getDisposable()},c.disposable=function(a){return arguments.length?this.getDisposable():setDisposable(a)},c.dispose=function(){a.prototype.dispose.call(this),this.m.dispose()},b}(Cb),Ub=function(a){function b(a){return this.underlyingObservable.subscribe(a)}function c(c,d,e){a.call(this,b),this.key=c,this.underlyingObservable=e?new Sb(function(a){return new _(e.getDisposable(),d.subscribe(a))}):d}return T(c,a),c}(Hb),Vb=function(a,b){this.subject=a,this.observer=b};Vb.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1),this.observer=null}};var Wb=z.Subject=function(a){function b(a){return h.call(this),this.isStopped?this.exception?(a.onError(this.exception),db):(a.onCompleted(),db):(this.observers.push(a),new Vb(this,a))}function c(){a.call(this,b),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return T(c,a),U(c.prototype,zb,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(h.call(this),!this.isStopped){var a=this.observers.slice(0);this.isStopped=!0;for(var b=0,c=a.length;c>b;b++)a[b].onCompleted();this.observers=[]}},onError:function(a){if(h.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,d=b.length;d>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){if(h.call(this),!this.isStopped)for(var b=this.observers.slice(0),c=0,d=b.length;d>c;c++)b[c].onNext(a)},dispose:function(){this.isDisposed=!0,this.observers=null}}),c.create=function(a,b){return new Xb(a,b)},c}(Hb),Xb=(z.AsyncSubject=function(a){function b(a){if(h.call(this),!this.isStopped)return this.observers.push(a),new Vb(this,a);var b=this.exception,c=this.hasValue,d=this.value;return b?a.onError(b):c?(a.onNext(d),a.onCompleted()):a.onCompleted(),db}function c(){a.call(this,b),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return T(c,a),U(c.prototype,zb,{hasObservers:function(){return h.call(this),this.observers.length>0},onCompleted:function(){var a,b,c;if(h.call(this),!this.isStopped){this.isStopped=!0;var d=this.observers.slice(0),e=this.value,f=this.hasValue;if(f)for(b=0,c=d.length;c>b;b++)a=d[b],a.onNext(e),a.onCompleted();else for(b=0,c=d.length;c>b;b++)d[b].onCompleted();this.observers=[]}},onError:function(a){if(h.call(this),!this.isStopped){var b=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var c=0,d=b.length;d>c;c++)b[c].onError(a);this.observers=[]}},onNext:function(a){h.call(this),this.isStopped||(this.value=a,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),c}(Hb),function(a){function b(a){return this.observable.subscribe(a)}function c(c,d){a.call(this,b),this.observer=c,this.observable=d}return T(c,a),U(c.prototype,zb,{onCompleted:function(){this.observer.onCompleted()},onError:function(a){this.observer.onError(a)},onNext:function(a){this.observer.onNext(a)}}),c}(Hb));"function"==typeof define&&"object"==typeof define.amd&&define.amd?(t.Rx=z,define(function(){return z})):u&&v?w?(v.exports=z).Rx=z:u.Rx=z:t.Rx=z}).call(this);