// Copyright (c) Microsoft Corporation. All rights reserved.
// This code is licensed by Microsoft Corporation under the terms
// of the MICROSOFT REACTIVE EXTENSIONS FOR JAVASCRIPT AND .NET LIBRARIES License.
// See http://go.microsoft.com/fwlink/?LinkId=186234.
(function(){vara;varb;varc=this;vard="Index out of range";if(typeofProvideCustomRxRootObject=="undefined")b=c.Rx={};elseb=ProvideCustomRxRootObject();vare=function(){};varf=function(){returnnewDate().getTime();};varg=function(r0,s0){returnr0===s0;};varh=function(r0){returnr0;};vari=function(r0){return{Dispose:r0};};varj={Dispose:e};b.Disposable={Create:i,Empty:j};vark=b.BooleanDisposable=function(){varr0=false;this.GetIsDisposed=function(){returnr0;};this.Dispose=function(){r0=true;};};varl=function(r0){vars0=false;r0.a++;this.Dispose=function(){vart0=false;if(!r0.b){if(!this.c){this.c=true;r0.a--;if(r0.a==0&&r0.d){r0.b=true;t0=true;}}}if(t0)r0.e.Dispose();};};varm=b.RefCountDisposable=function(r0){this.d=false;this.b=false;this.e=r0;this.a=0;this.Dispose=function(){vars0=false;if(!this.b){if(!this.d){this.d=true;if(this.a==0){this.b=true;s0=true;}}}if(s0)this.e.Dispose();};this.GetDisposable=function(){if(this.b)returnj;elsereturnnewl(this);};};varn=b.CompositeDisposable=function(){varr0=newq();for(vars0=0;s0<arguments.length;s0++)r0.Add(arguments[s0]);vart0=false;this.GetCount=function(){returnr0.GetCount();};this.Add=function(u0){if(!t0)r0.Add(u0);elseu0.Dispose();};this.Remove=function(u0,v0){if(!t0){varw0=r0.Remove(u0);if(!v0&w0)u0.Dispose();}};this.Dispose=function(){if(!t0){t0=true;this.Clear();}};this.Clear=function(){for(varu0=0;u0<r0.GetCount();u0++)r0.GetItem(u0).Dispose();r0.Clear();};};varo=b.MutableDisposable=function(){varr0=false;vars0;this.Get=function(){returns0;},this.Replace=function(t0){if(r0&&t0!==a)t0.Dispose();else{if(s0!==a)s0.Dispose();s0=t0;}};this.Dispose=function(){if(!r0){r0=true;if(s0!==a)s0.Dispose();}};};varp=function(r0){vars0=[];for(vart0=0;t0<r0.length;t0++)s0.push(r0[t0]);returns0;};varq=b.List=function(r0){vars0=[];vart0=0;varu0=r0!==a?r0:g;this.Add=function(v0){s0[t0]=v0;t0++;};this.RemoveAt=function(v0){if(v0<0||v0>=t0)throwd;if(v0==0){s0.shift();t0--;}else{s0.splice(v0,1);t0--;}};this.IndexOf=function(v0){for(varw0=0;w0<t0;w0++){if(u0(v0,s0[w0]))returnw0;}return-1;};this.Remove=function(v0){varw0=this.IndexOf(v0);if(w0==-1)returnfalse;this.RemoveAt(w0);returntrue;};this.Clear=function(){s0=[];t0=0;};this.GetCount=function(){returnt0;};this.GetItem=function(v0){if(v0<0||v0>=t0)throwd;returns0[v0];};this.SetItem=function(v0,w0){if(v0<0||v0>=t0)throwd;s0[v0]=w0;};this.ToArray=function(){varv0=[];for(varw0=0;w0<this.GetCount();w0++)v0.push(this.GetItem(w0));returnv0;};};varr=function(r0){if(r0===null)r0=g;this.f=r0;vars0=4;this.g=newArray(s0);this.h=0;};r.prototype.i=function(r0,s0){returnthis.f(this.g[r0],this.g[s0])<0;};r.prototype.j=function(r0){if(r0>=this.h||r0<0)return;vars0=r0-1>>1;if(s0<0||s0==r0)return;if(this.i(r0,s0)){vart0=this.g[r0];this.g[r0]=this.g[s0];this.g[s0]=t0;this.j(s0);}};r.prototype.k=function(r0){if(r0===a)r0=0;vars0=2*r0+1;vart0=2*r0+2;varu0=r0;if(s0<this.h&&this.i(s0,u0))u0=s0;if(t0<this.h&&this.i(t0,u0))u0=t0;if(u0!=r0){varv0=this.g[r0];this.g[r0]=this.g[u0];this.g[u0]=v0;this.k(u0);}};r.prototype.GetCount=function(){returnthis.h;};r.prototype.Peek=function(){if(this.h==0)throw"Heap is empty.";returnthis.g[0];};r.prototype.Dequeue=function(){varr0=this.Peek();this.g[0]=this.g[--this.h];deletethis.g[this.h];this.k();returnr0;};r.prototype.Enqueue=function(r0){vars0=this.h++;this.g[s0]=r0;this.j(s0);};vars=b.Scheduler=function(r0,s0,t0){this.Schedule=r0;this.ScheduleWithTime=s0;this.Now=t0;this.ScheduleRecursive=function(u0){varv0=this;varw0=newn();varx0;x0=function(){u0(function(){vary0=false;varz0=false;varA0;A0=v0.Schedule(function(){x0();if(y0)w0.Remove(A0);elsez0=true;});if(!z0){w0.Add(A0);y0=true;}});};w0.Add(v0.Schedule(x0));returnw0;};this.ScheduleRecursiveWithTime=function(u0,v0){varw0=this;varx0=newn();vary0;y0=function(){u0(function(z0){varA0=false;varB0=false;varC0;C0=w0.ScheduleWithTime(function(){y0();if(A0)x0.Remove(C0);elseB0=true;},z0);if(!B0){x0.Add(C0);A0=true;}});};x0.Add(w0.ScheduleWithTime(y0,v0));returnx0;};};vart=b.VirtualScheduler=function(r0,s0,t0,u0){varv0=news(function(w0){returnthis.ScheduleWithTime(w0,0);},function(w0,x0){returnthis.ScheduleVirtual(w0,u0(x0));},function(){returnt0(this.l);});v0.ScheduleVirtual=function(w0,x0){vary0=newk();varz0=s0(this.l,x0);varA0=function(){if(!y0.IsDisposed)w0();};varB0=newy(A0,z0);this.m.Enqueue(B0);returny0;};v0.Run=function(){while(this.m.GetCount()>0){varw0=this.m.Dequeue();this.l=w0.n;w0.o();}};v0.RunTo=function(w0){while(this.m.GetCount()>0&&this.f(this.m.Peek().n,w0)<=0){varx0=this.m.Dequeue();this.l=x0.n;x0.o();}};v0.GetTicks=function(){returnthis.l;};v0.l=0;v0.m=newr(function(w0,x0){returnr0(w0.n,x0.n);});v0.f=r0;returnv0;};varu=b.TestScheduler=function(){varr0=newt(function(s0,t0){returns0-t0;},function(s0,t0){returns0+t0;},function(s0){returnnewDate(s0);},function(s0){if(s0<=0)return1;returns0;});returnr0;};varv=news(function(r0){returnthis.ScheduleWithTime(r0,0);},function(r0,s0){vart0=this.Now()+s0;varu0=newy(r0,t0);if(this.m===a){varv0=neww();try{this.m.Enqueue(u0);v0.p();}finally{v0.q();}}elsethis.m.Enqueue(u0);returnu0.r();},f);v.s=function(r0){if(this.m===a){vars0=neww();try{r0();s0.p();}finally{s0.q();}}elser0();};s.CurrentThread=v;varw=function(){v.m=newr(function(r0,s0){try{returnr0.n-s0.n;}catch(t0){debugger;}});this.q=function(){v.m=a;};this.p=function(){while(v.m.GetCount()>0){varr0=v.m.Dequeue();if(!r0.t()){while(r0.n-v.Now()>0);if(!r0.t())r0.o();}}};};varx=0;vary=function(r0,s0){this.u=x++;this.o=r0;this.n=s0;this.v=newk();this.t=function(){returnthis.v.GetIsDisposed();};this.r=function(){returnthis.v;};};varz=news(function(r0){r0();returnj;},function(r0,s0){while(this.Now<s0);r0();},f);s.Immediate=z;varA=news(function(r0){vars0=c.setTimeout(r0,0);returni(function(){c.clearTimeout(s0);});},function(r0,s0){vart0=c.setTimeout(r0,s0);returni(function(){c.clearTimeout(t0);});},f);s.Timeout=A;varB=b.Observer=function(r0,s0,t0){this.OnNext=r0===a?e:r0;this.OnError=s0===a?function(u0){throwu0;}:s0;this.OnCompleted=t0===a?e:t0;this.AsObserver=function(){varu0=this;returnnewB(function(v0){u0.OnNext(v0);},function(v0){u0.OnError(v0);},function(){u0.OnCompleted();});};};varC=B.Create=function(r0,s0,t0){returnnewB(r0,s0,t0);};varD=b.Observable=function(r0){this.w=r0;};varE=D.CreateWithDisposable=function(r0){returnnewD(r0);};varF=D.Create=function(r0){returnE(function(s0){returni(r0(s0));});};varG=function(){returnthis.Select(function(r0){returnr0.Value;});};D.prototype={Subscribe:function(r0,s0,t0){varu0;if(arguments.length==0||arguments.length>1||typeofr0=="function")u0=newB(r0,s0,t0);elseu0=r0;returnthis.x(u0);},x:function(r0){vars0=false;vart0=newo();varu0=this;v.s(function(){varv0=newB(function(w0){if(!s0)r0.OnNext(w0);},function(w0){if(!s0){s0=true;t0.Dispose();r0.OnError(w0);}},function(){if(!s0){s0=true;t0.Dispose();r0.OnCompleted();}});t0.Replace(u0.w(v0));});returnnewn(t0,i(function(){s0=true;}));},Select:function(r0){vars0=this;returnE(function(t0){varu0=0;returns0.Subscribe(newB(function(v0){varw0;try{w0=r0(v0,u0++);}catch(x0){t0.OnError(x0);return;}t0.OnNext(w0);},function(v0){t0.OnError(v0);},function(){t0.OnCompleted();}));});},Let:function(r0,s0){if(s0===a)returnr0(this);vart0=this;returnE(function(u0){varv0=s0();varw0;try{w0=r0(v0);}catch(A0){returnL(A0).Subscribe(u0);}varx0=newo();vary0=newo();varz0=newn(y0,x0);x0.Replace(w0.Subscribe(function(A0){u0.OnNext(A0);},function(A0){u0.OnError(A0);z0.Dispose();},function(){u0.OnCompleted();z0.Dispose();}));y0.Replace(t0.Subscribe(v0));returnz0;});},MergeObservable:function(){varr0=this;returnE(function(s0){vart0=false;varu0=newn();varv0=newo();u0.Add(v0);v0.Replace(r0.Subscribe(function(w0){varx0=newo();u0.Add(x0);x0.Replace(w0.Subscribe(function(y0){s0.OnNext(y0);},function(y0){s0.OnError(y0);},function(){u0.Remove(x0);if(u0.GetCount()==1&&t0)s0.OnCompleted();}));},function(w0){s0.OnError(w0);},function(){t0=true;if(u0.GetCount()==1)s0.OnCompleted();}));returnu0;});},y:function(r0,s0){vart0=p(s0);t0.unshift(this);returnr0(t0);},Concat:function(){returnthis.y(I,arguments);},Merge:function(){returnthis.y(H,arguments);},Catch:function(){returnthis.y(P,arguments);},OnErrorResumeNext:function(){returnthis.y(V,arguments);},Zip:function(r0,s0){vart0=this;returnE(function(u0){varv0=false;varw0=[];varx0=[];vary0=false;varz0=false;varA0=newn();varB0=function(C0){A0.Dispose();w0=a;x0=a;u0.OnError(C0);};A0.Add(t0.Subscribe(function(C0){if(z0){u0.OnCompleted();return;}if(x0.length>0){varD0=x0.shift();varE0;try{E0=s0(C0,D0);}catch(F0){A0.Dispose();u0.OnError(F0);return;}u0.OnNext(E0);}elsew0.push(C0);},B0,function(){if(z0){u0.OnCompleted();return;}y0=true;}));A0.Add(r0.Subscribe(function(C0){if(y0){u0.OnCompleted();return;}if(w0.length>0){varD0=w0.shift();varE0;try{E0=s0(D0,C0);}catch(F0){A0.Dispose();u0.OnError(F0);return;}u0.OnNext(E0);}elsex0.push(C0);},B0,function(){if(y0){u0.OnCompleted();return;}z0=true;}));returnA0;});},CombineLatest:function(r0,s0){vart0=this;returnE(function(u0){varv0=false;varw0=false;varx0=false;vary0;varz0;varA0=false;varB0=false;varC0=newn();varD0=function(E0){C0.Dispose();u0.OnError(E0);};C0.Add(t0.Subscribe(function(E0){if(B0){u0.OnCompleted();return;}if(x0){varF0;try{F0=s0(E0,z0);}catch(G0){C0.Dispose();u0.OnError(G0);return;}u0.OnNext(F0);}y0=E0;w0=true;},D0,function(){if(B0){u0.OnCompleted();return;}A0=true;}));C0.Add(r0.Subscribe(function(E0){if(A0){u0.OnCompleted();return;}if(w0){varF0;try{F0=s0(y0,E0);}catch(G0){C0.Dispose();u0.OnError(G0);return;}u0.OnNext(F0);}z0=E0;x0=true;},D0,function(){if(A0){u0.OnCompleted();return;}B0=true;}));});},Switch:function(){varr0=this;returnE(function(s0){vart0=false;varu0=newo();varv0=newo();v0.Replace(r0.Subscribe(function(w0){if(!t0){varx0=newo();x0.Replace(w0.Subscribe(function(y0){s0.OnNext(y0);},function(y0){v0.Dispose();u0.Dispose();s0.OnError(y0);},function(){u0.Replace(a);if(t0)s0.OnCompleted();}));u0.Replace(x0);}},function(w0){u0.Dispose();s0.OnError(w0);},function(){t0=true;if(u0.Get()===a)s0.OnCompleted();}));returnnewn(v0,u0);});},TakeUntil:function(r0){vars0=this;returnE(function(t0){varu0=newn();u0.Add(r0.Subscribe(function(){t0.OnCompleted();u0.Dispose();},function(v0){t0.OnError(v0);},function(){}));u0.Add(s0.Subscribe(t0));returnu0;});},SkipUntil:function(r0){vars0=this;returnE(function(t0){varu0=true;varv0=newn();v0.Add(r0.Subscribe(function(){u0=false;},function(w0){t0.OnError(w0);},e));v0.Add(s0.Subscribe(newB(function(w0){if(!u0)t0.OnNext(w0);},function(w0){t0.OnError(w0);},function(){if(!u0)t0.OnCompleted();})));returnv0;});},Scan1:function(r0){vars0=this;returnO(function(){vart0;varu0=false;returns0.Select(function(v0){if(u0)t0=r0(t0,v0);else{t0=v0;u0=true;}returnt0;});});},Scan:function(r0,s0){vart0=this;returnO(function(){varu0;varv0=false;returnt0.Select(function(w0){if(v0)u0=s0(u0,w0);else{u0=s0(r0,w0);v0=true;}returnu0;});});},Scan0:function(r0,s0){vart0=this;returnE(function(u0){varv0=r0;varw0=true;returnt0.Subscribe(function(x0){if(w0){w0=false;u0.OnNext(v0);}try{v0=s0(v0,x0);}catch(y0){u0.OnError(y0);return;}u0.OnNext(v0);},function(x0){if(w0)u0.OnNext(v0);u0.OnError(x0);},function(){if(w0)u0.OnNext(v0);u0.OnCompleted();});});},Finally:function(r0){vars0=this;returnF(function(t0){varu0=s0.Subscribe(t0);returnfunction(){try{u0.Dispose();r0();}catch(v0){r0();throwv0;}};});},Do:function(r0,s0,t0){varu0;if(arguments.length==0||arguments.length>1||typeofr0=="function")u0=newB(r0,s0!==a?s0:e,t0);elseu0=r0;varv0=this;returnE(function(w0){returnv0.Subscribe(newB(function(x0){try{u0.OnNext(x0);}catch(y0){w0.OnError(y0);return;}w0.OnNext(x0);},function(x0){if(s0!==a)try{u0.OnError(x0);}catch(y0){w0.OnError(y0);return;}w0.OnError(x0);},function(){if(t0!==a)try{u0.OnCompleted();}catch(x0){w0.OnError(x0);return;}w0.OnCompleted();}));});},Where:function(r0){vars0=this;returnE(function(t0){varu0=0;returns0.Subscribe(newB(function(v0){varw0=false;try{w0=r0(v0,u0++);}catch(x0){t0.OnError(x0);return;}if(w0)t0.OnNext(v0);},function(v0){t0.OnError(v0);},function(){t0.OnCompleted();}));});},Take:function(r0,s0){if(s0===a)s0=z;vart0=this;returnE(function(u0){if(r0<=0){t0.Subscribe().Dispose();returnN(s0).Subscribe(u0);}varv0=r0;returnt0.Subscribe(newB(function(w0){if(v0-->0){u0.OnNext(w0);if(v0==0)u0.OnCompleted();}},function(w0){u0.OnError(w0);},function(){u0.OnCompleted();}));});},GroupBy:function(r0,s0,t0){if(r0===a)r0=h;if(s0===a)s0=h;if(t0===a)t0=function(v0){returnv0.toString();};varu0=this;returnE(function(v0){varw0={};varx0=newo();vary0=newm(x0);x0.Replace(u0.Subscribe(function(z0){varA0;try{A0=r0(z0);}catch(G0){for(varH0inw0)w0[H0].OnError(G0);v0.OnError(G0);return;}varB0=false;varC0;try{varD0=t0(A0);if(w0[D0]===a){C0=newi0();w0[D0]=C0;B0=true;}elseC0=w0[D0];}catch(G0){for(varH0inw0)w0[H0].OnError(G0);v0.OnError(G0);return;}if(B0){varE0=E(function(G0){returnnewn(y0.GetDisposable(),C0.Subscribe(G0));});E0.Key=A0;v0.OnNext(E0);}varF0;try{F0=s0(z0);}catch(G0){for(varH0inw0)w0[H0].OnError(G0);v0.OnError(G0);return;}C0.OnNext(F0);},function(z0){for(varA0inw0)w0[A0].OnError(z0);v0.OnError(z0);},function(){for(varz0inw0)w0[z0].OnCompleted();v0.OnCompleted();}));returny0;});},TakeWhile:function(r0){vars0=this;returnE(function(t0){varu0=true;returns0.Subscribe(newB(function(v0){if(u0){try{u0=r0(v0);}catch(w0){t0.OnError(w0);return;}if(u0)t0.OnNext(v0);elset0.OnCompleted();}},function(v0){t0.OnError(v0);},function(){t0.OnCompleted();}));});},SkipWhile:function(r0){vars0=this;returnE(function(t0){varu0=false;returns0.Subscribe(newB(function(v0){if(!u0)try{u0=!r0(v0);}catch(w0){t0.OnError(w0);return;}if(u0)t0.OnNext(v0);},function(v0){t0.OnError(v0);},function(){t0.OnCompleted();}));});},Skip:function(r0){vars0=this;returnE(function(t0){varu0=r0;returns0.Subscribe(newB(function(v0){if(u0--<=0)t0.OnNext(v0);},function(v0){t0.OnError(v0);},function(){t0.OnCompleted();}));});},SelectMany:function(r0){returnthis.Select(r0).MergeObservable();},TimeInterval:function(r0){if(r0===a)r0=z;vars0=this;returnO(function(){vart0=r0.Now();returns0.Select(function(u0){varv0=r0.Now();varw0=v0-t0;t0=v0;return{Interval:w0,Value:u0};});});},RemoveInterval:G,Timestamp:function(r0){if(r0===a)r0=z;returnthis.Select(function(s0){return{Timestamp:r0.Now(),Value:s0};});},RemoveTimestamp:G,Materialize:function(){varr0=this;returnE(function(s0){returnr0.Subscribe(newB(function(t0){s0.OnNext(newh0("N",t0));},function(t0){s0.OnNext(newh0("E",t0));s0.OnCompleted();},function(){s0.OnNext(newh0("C"));s0.OnCompleted();}));});},Dematerialize:function(){returnthis.SelectMany(function(r0){returnr0;});},AsObservable:function(){varr0=this;returnE(function(s0){returnr0.Subscribe(s0);});},Delay:function(r0,s0){if(s0===a)s0=A;vart0=this;returnE(function(u0){varv0=[];varw0=false;varx0=newo();vary0=t0.Materialize().Timestamp().Subscribe(function(z0){if(z0.Value.Kind=="E"){u0.OnError(z0.Value.Value);v0=[];if(w0)x0.Dispose();return;}v0.push({Timestamp:s0.Now()+r0,Value:z0.Value});if(!w0){x0.Replace(s0.ScheduleRecursiveWithTime(function(A0){varB0;do{B0=a;if(v0.length>0&&v0[0].Timestamp<=s0.Now())B0=v0.shift().Value;if(B0!==a)B0.Accept(u0);}while(B0!==a);if(v0.length>0){A0(Math.max(0,v0[0].Timestamp-s0.Now()));w0=true;}elsew0=false;},r0));w0=true;}});returnnewn(y0,x0);});},Throttle:function(r0,s0){if(s0===a)s0=A;vart0=this;returnE(function(u0){varv0;varw0=false;varx0=newo();vary0=0;varz0=t0.Subscribe(function(A0){w0=true;v0=A0;y0++;varB0=y0;x0.Replace(s0.ScheduleWithTime(function(){if(w0&&y0==B0)u0.OnNext(v0);w0=false;},r0));},function(A0){x0.Dispose();u0.OnError(A0);w0=false;y0++;},function(){x0.Dispose();if(w0)u0.OnNext(v0);u0.OnCompleted();w0=false;y0++;});returnnewn(z0,x0);});},Timeout:function(r0,s0,t0){if(t0===a)t0=A;if(s0===a)s0=L("Timeout",t0);varu0=this;returnE(function(v0){varw0=newo();varx0=newo();vary0=0;varz0=y0;varA0=false;x0.Replace(t0.ScheduleWithTime(function(){A0=y0==z0;if(A0)w0.Replace(s0.Subscribe(v0));},r0));w0.Replace(u0.Subscribe(function(B0){varC0=0;if(!A0){y0++;C0=y0;v0.OnNext(B0);x0.Replace(t0.ScheduleWithTime(function(){A0=y0==C0;if(A0)w0.Replace(s0.Subscribe(v0));},r0));}},function(B0){if(!A0){y0++;v0.OnError(B0);}},function(){if(!A0){y0++;v0.OnCompleted();}}));returnnewn(w0,x0);});},Sample:function(r0,s0){if(s0===a)s0=A;vart0=this;returnE(function(u0){varv0=false;varw0;varx0=false;vary0=newn();y0.Add(Y(r0,s0).Subscribe(function(z0){if(v0){u0.OnNext(w0);v0=false;}if(x0)u0.OnCompleted();},function(z0){u0.OnError(z0);},function(){u0.OnCompleted();}));y0.Add(t0.Subscribe(function(z0){v0=true;w0=z0;},function(z0){u0.OnError(z0);y0.Dispose();},function(){x0=true;}));returny0;});},Repeat:function(r0,s0){vart0=this;if(s0===a)s0=z;if(r0===a)r0=-1;returnE(function(u0){varv0=r0;varw0=newo();varx0=newn(w0);vary0=function(z0){w0.Replace(t0.Subscribe(function(A0){u0.OnNext(A0);},function(A0){u0.OnError(A0);},function(){if(v0>0){v0--;if(v0==0){u0.OnCompleted();return;}}z0();}));};x0.Add(s0.ScheduleRecursive(y0));returnx0;});},Retry:function(r0,s0){vart0=this;if(s0===a)s0=z;if(r0===a)r0=-1;returnE(function(u0){varv0=r0;varw0=newo();varx0=newn(w0);vary0=function(z0){w0.Replace(t0.Subscribe(function(A0){u0.OnNext(A0);},function(A0){if(v0>0){v0--;if(v0==0){u0.OnError(A0);return;}}z0();},function(){u0.OnCompleted();}));};x0.Add(s0.ScheduleRecursive(y0));returnx0;});},BufferWithTime:function(r0,s0,t0){if(t0===a)t0=A;if(s0===a)s0=r0;varu0=this;returnE(function(v0){varw0=newq();varx0=t0.Now();vary0=function(){varC0=[];for(varD0=0;D0<w0.GetCount();D0++){varE0=w0.GetItem(D0);if(E0.Timestamp-x0>=0)C0.push(E0.Value);}returnC0;};varz0=newn();varA0=function(C0){v0.OnError(C0);};varB0=function(){v0.OnNext(y0());v0.OnCompleted();};z0.Add(u0.Subscribe(function(C0){w0.Add({Value:C0,Timestamp:t0.Now()});},A0,B0));z0.Add(a0(r0,s0,t0).Subscribe(function(C0){varD0=y0();varE0=t0.Now()+s0-r0;while(w0.GetCount()>0&&w0.GetItem(0).Timestamp-E0<=0)w0.RemoveAt(0);v0.OnNext(D0);x0=E0;},A0,B0));returnz0;});},BufferWithTimeOrCount:function(r0,s0,t0){if(t0===a)t0=A;varu0=this;returnE(function(v0){varw0=0;varx0=newq();vary0=function(){v0.OnNext(x0.ToArray());x0.Clear();w0++;};varz0=newo();varA0;A0=function(C0){varD0=t0.ScheduleWithTime(function(){varE0=false;varF0=0;if(C0==w0){y0();F0=w0;E0=true;}if(E0)A0(F0);},r0);z0.Replace(D0);};A0(w0);varB0=u0.Subscribe(function(C0){varD0=false;varE0=0;x0.Add(C0);if(x0.GetCount()==s0){y0();E0=w0;D0=true;}if(D0)A0(E0);},function(C0){v0.OnError(C0);x0.Clear();},function(){v0.OnNext(x0.ToArray());w0++;v0.OnCompleted();x0.Clear();});returnnewn(B0,z0);});},BufferWithCount:function(r0,s0){if(s0===a)s0=r0;vart0=this;returnE(function(u0){varv0=[];varw0=0;returnt0.Subscribe(function(x0){if(w0==0)v0.push(x0);elsew0--;vary0=v0.length;if(y0==r0){varz0=v0;v0=[];varA0=Math.min(s0,y0);for(varB0=A0;B0<y0;B0++)v0.push(z0[B0]);w0=Math.max(0,s0-r0);u0.OnNext(z0);}},function(x0){u0.OnError(x0);},function(){if(v0.length>0)u0.OnNext(v0);u0.OnCompleted();});});},StartWith:function(r0,s0){if(!(r0instanceofArray))r0=[r0];if(s0===a)s0=z;vart0=this;returnE(function(u0){varv0=newn();varw0=0;v0.Add(s0.ScheduleRecursive(function(x0){if(w0<r0.length){u0.OnNext(r0[w0]);w0++;x0();}elsev0.Add(t0.Subscribe(u0));}));returnv0;});},DistinctUntilChanged:function(r0,s0){if(r0===a)r0=h;if(s0===a)s0=g;vart0=this;returnE(function(u0){varv0;varw0=false;returnt0.Subscribe(function(x0){vary0;try{y0=r0(x0);}catch(A0){u0.OnError(A0);return;}varz0=false;if(w0)try{z0=s0(v0,y0);}catch(A0){u0.OnError(A0);return;}if(!w0||!z0){w0=true;v0=y0;u0.OnNext(x0);}},function(x0){u0.OnError(x0);},function(){u0.OnCompleted();});});},Publish:function(r0){if(r0===a)returnnewq0(this,newi0());vars0=this;returnE(function(t0){varu0=newq0(s0,newi0());returnnewn(r0(u0).Subscribe(B),u0.Connect());});},Prune:function(r0,s0){if(s0===a)s0=z;if(r0===a)returnnewq0(this,newk0(s0));vart0=this;returnE(function(u0){varv0=newq0(t0,newk0(s0));returnnewn(r0(v0).Subscribe(B),v0.Connect());});},Replay:function(r0,s0,t0,u0){if(u0===a)u0=v;if(r0===a)returnnewq0(this,newm0(s0,t0,u0));varv0=this;returnE(function(w0){varx0=newq0(v0,newm0(s0,t0,u0));returnnewn(r0(x0).Subscribe(B),x0.Connect());});},SkipLast:function(r0){vars0=this;returnE(function(t0){varu0=[];returns0.Subscribe(function(v0){u0.push(v0);if(u0.length>r0)t0.OnNext(u0.shift());},function(v0){t0.OnError(v0);},function(){t0.OnCompleted();});});},TakeLast:function(r0){vars0=this;returnE(function(t0){varu0=[];returns0.Subscribe(function(v0){u0.push(v0);if(u0.length>r0)u0.shift();},function(v0){t0.OnError(v0);},function(){while(u0.length>0)t0.OnNext(u0.shift());t0.OnCompleted();});});}};varH=D.Merge=function(r0,s0){if(s0===a)s0=z;returnJ(r0,s0).MergeObservable();};varI=D.Concat=function(r0,s0){if(s0===a)s0=z;returnE(function(t0){varu0=newo();varv0=0;varw0=s0.ScheduleRecursive(function(x0){if(v0<r0.length){vary0=r0[v0];v0++;varz0=newo();u0.Replace(z0);z0.Replace(y0.Subscribe(function(A0){t0.OnNext(A0);},function(A0){t0.OnError(A0);},x0));}elset0.OnCompleted();});returnnewn(u0,w0);});};varJ=D.FromArray=function(r0,s0){if(s0===a)s0=z;returnE(function(t0){varu0=0;returns0.ScheduleRecursive(function(v0){if(u0<r0.length){t0.OnNext(r0[u0++]);v0();}elset0.OnCompleted();});});};varK=D.Return=function(r0,s0){if(s0===a)s0=z;returnE(function(t0){returns0.Schedule(function(){t0.OnNext(r0);t0.OnCompleted();});});};varL=D.Throw=function(r0,s0){if(s0===a)s0=z;returnE(function(t0){returns0.Schedule(function(){t0.OnError(r0);});});};varM=D.Never=function(){returnE(function(r0){returnj;});};varN=D.Empty=function(r0){if(r0===a)r0=z;returnE(function(s0){returnr0.Schedule(function(){s0.OnCompleted();});});};varO=D.Defer=function(r0){returnE(function(s0){vart0;try{t0=r0();}catch(u0){s0.OnError(u0);returnj;}returnt0.Subscribe(s0);});};varP=D.Catch=function(r0,s0){if(s0===a)s0=z;returnE(function(t0){varu0=newo();varv0=0;varw0=s0.ScheduleRecursive(function(x0){vary0=r0[v0];v0++;varz0=newo();u0.Replace(z0);z0.Replace(y0.Subscribe(function(A0){t0.OnNext(A0);},function(A0){if(v0<r0.length)x0();elset0.OnError(A0);},function(){t0.OnCompleted();}));});returnnewn(u0,w0);});};varQ=D.Using=function(r0,s0){returnE(function(t0){varu0;varv0=j;try{varw0=r0();if(w0!==a)v0=w0;u0=s0(w0);}catch(x0){returnnewn(Throw(x0).Subscribe(t0),v0);}returnnewn(u0.Subscribe(t0),v0);});};varR=D.Range=function(r0,s0,t0){if(t0===a)t0=z;varu0=r0+s0-1;returnT(r0,function(v0){returnv0<=u0;},function(v0){returnv0+1;},h,t0);};varS=D.Repeat=function(r0,s0,t0){if(t0===a)t0=z;if(s0===a)s0=-1;varu0=s0;returnE(function(v0){returnt0.ScheduleRecursive(function(w0){v0.OnNext(r0);if(u0>0){u0--;if(u0==0){v0.OnCompleted();return;}}w0();});});};varT=D.Generate=function(r0,s0,t0,u0,v0){if(v0===a)v0=z;returnE(function(w0){varx0=r0;vary0=true;returnv0.ScheduleRecursive(function(z0){varA0=false;varB0;try{if(y0)y0=false;elsex0=t0(x0);A0=s0(x0);if(A0)B0=u0(x0);}catch(C0){w0.OnError(C0);return;}if(A0){w0.OnNext(B0);z0();}elsew0.OnCompleted();});});};varU=D.GenerateWithTime=function(r0,s0,t0,u0,v0,w0){if(w0===a)w0=A;returnnewE(function(x0){vary0=r0;varz0=true;varA0=false;varB0;varC0;returnw0.ScheduleRecursiveWithTime(function(D0){if(A0)x0.OnNext(B0);try{if(z0)z0=false;elsey0=t0(y0);A0=s0(y0);if(A0){B0=u0(y0);C0=v0(y0);}}catch(E0){x0.OnError(E0);return;}if(A0)D0(C0);elsex0.OnCompleted();},0);});};varV=D.OnErrorResumeNext=function(r0,s0){if(s0===a)s0=z;returnE(function(t0){varu0=newo();varv0=0;varw0=s0.ScheduleRecursive(function(x0){if(v0<r0.length){vary0=r0[v0];v0++;varz0=newo();u0.Replace(z0);z0.Replace(y0.Subscribe(function(A0){t0.OnNext(A0);},x0,x0));}elset0.OnCompleted();});returnnewn(u0,w0);});};varW=D.Amb=function(){varr0=arguments;returnE(function(s0){vart0=newn();varu0=newo();u0.Replace(t0);varv0=false;for(varw0=0;w0<r0.length;w0++){varx0=r0[w0];vary0=newo();varz0=newB(function(A0){if(!v0){t0.Remove(this.z,true);t0.Dispose();u0.Replace(this.z);v0=true;}s0.OnNext(A0);},function(A0){s0.OnError(A0);u0.Dispose();},function(){s0.OnCompleted();u0.Dispose();});z0.z=y0;y0.Replace(x0.Subscribe(z0));t0.Add(y0);}returnu0;});};varX=D.ForkJoin=function(){varr0=arguments;returnE(function(s0){vart0=[];varu0=[];varv0=[];varw0=newn();for(varx0=0;x0<r0.length;x0++)(function(y0){w0.Add(r0[y0].Subscribe(function(z0){t0[y0]=true;v0[y0]=z0;},function(z0){s0.OnError(z0);},function(z0){if(!t0[y0]){s0.OnCompleted();v0=a;t0=a;return;}u0[y0]=true;varA0=true;for(varB0=0;B0<r0.length;B0++){if(!u0[B0])A0=false;}if(A0){s0.OnNext(v0);s0.OnCompleted();v0=a;u0=a;t0=a;}}));})(x0);returnw0;});};varY=D.Interval=function(r0,s0){returna0(r0,r0,s0);};varZ=function(r0){returnMath.max(0,r0);};vara0=D.Timer=function(r0,s0,t0){if(t0===a)t0=A;if(r0===a)returnM();if(r0instanceofDate)returnO(function(){returnD.Timer(r0-newDate(),s0,t0);});varu0=Z(r0);if(s0===a)returnE(function(w0){returnt0.ScheduleWithTime(function(){w0.OnNext(0);w0.OnCompleted();},u0);});varv0=Z(s0);returnE(function(w0){varx0=0;returnt0.ScheduleRecursiveWithTime(function(y0){w0.OnNext(x0++);y0(v0);},u0);});};varb0=D.While=function(r0,s0){returnE(function(t0){varu0=newo();varv0=newn(u0);v0.Add(z.ScheduleRecursive(function(w0){varx0;try{x0=r0();}catch(y0){t0.OnError(y0);return;}if(x0)u0.Replace(s0.Subscribe(function(y0){t0.OnNext(y0);},function(y0){t0.OnError(y0);},function(){w0();}));elset0.OnCompleted();}));returnv0;});};varc0=D.If=function(r0,s0,t0){if(t0===a)t0=N();returnO(function(){returnr0()?s0:t0;});};vard0=D.DoWhile=function(r0,s0){returnI([r0,b0(s0,r0)]);};vare0=D.Case=function(r0,s0,t0,u0){if(u0===a)u0=z;if(t0===a)t0=N(u0);returnO(function(){varv0=s0[r0()];if(v0===a)v0=t0;returnv0;});};varf0=D.For=function(r0,s0){returnE(function(t0){varu0=newn();varv0=0;u0.Add(z.ScheduleRecursive(function(w0){if(v0<r0.length){varx0;try{x0=s0(r0[v0]);}catch(y0){t0.OnError(y0);return;}u0.Add(x0.Subscribe(function(y0){t0.OnNext(y0);},function(y0){t0.OnError(y0);},function(){v0++;w0();}));}elset0.OnCompleted();}));returnu0;});};varg0=D.Let=function(r0,s0){returnO(function(){returns0(r0);});};varh0=b.Notification=function(r0,s0){this.Kind=r0;this.Value=s0;this.toString=function(){returnthis.Kind+": "+this.Value;};this.Accept=function(t0){switch(this.Kind){case"N":t0.OnNext(this.Value);break;case"E":t0.OnError(this.Value);break;case"C":t0.OnCompleted();break;}returnj;};this.w=function(t0){varu0=this.Accept(t0);if(r0=="N")t0.OnCompleted();returnu0;};};h0.prototype=newD;vari0=b.Subject=function(){varr0=newq();vars0=false;this.OnNext=function(t0){if(!s0){varu0=r0.ToArray();for(varv0=0;v0<u0.length;v0++){varw0=u0[v0];w0.OnNext(t0);}}};this.OnError=function(t0){if(!s0){varu0=r0.ToArray();for(varv0=0;v0<u0.length;v0++){varw0=u0[v0];w0.OnError(t0);}s0=true;r0.Clear();}};this.OnCompleted=function(){if(!s0){vart0=r0.ToArray();for(varu0=0;u0<t0.length;u0++){varv0=t0[u0];v0.OnCompleted();}s0=true;r0.Clear();}};this.w=function(t0){if(!s0){r0.Add(t0);returni(function(){r0.Remove(t0);});}elsereturnj;};};i0.prototype=newD;for(varj0inB.prototype)i0.prototype[j0]=B.prototype[j0];vark0=b.AsyncSubject=function(r0){vars0=newq();vart0;varu0=false;if(r0===a)r0=z;this.OnNext=function(v0){if(!u0)t0=newh0("N",v0);};this.OnError=function(v0){if(!u0){t0=newh0("E",v0);varw0=s0.ToArray();for(varx0=0;x0<w0.length;x0++){vary0=w0[x0];if(y0!==a)y0.OnError(v0);}u0=true;s0.Clear();}};this.OnCompleted=function(){if(!u0){if(t0===a)t0=newh0("C");varv0=s0.ToArray();for(varw0=0;w0<v0.length;w0++){varx0=v0[w0];if(x0!==a)t0.w(x0);}u0=true;s0.Clear();}};this.w=function(v0){if(!u0){s0.Add(v0);returni(function(){s0.Remove(v0);});}elsereturnr0.Schedule(function(){t0.w(v0);});};};k0.prototype=newi0;varl0=b.BehaviorSubject=function(r0,s0){vart0=newm0(1,-1,s0);t0.OnNext(r0);returnt0;};varm0=b.ReplaySubject=function(r0,s0,t0){varu0=newq();varv0=newq();varw0=false;if(t0===a)t0=v;varx0=s0>0;vary0=function(z0,A0){v0.Add({Value:newh0(z0,A0),Timestamp:t0.Now()});};this.A=function(){if(r0!==a)while(v0.GetCount()>r0)v0.RemoveAt(0);if(x0)while(v0.GetCount()>0&&t0.Now()-v0.GetItem(0).Timestamp>s0)v0.RemoveAt(0);};this.OnNext=function(z0){if(!w0){varA0=u0.ToArray();for(varB0=0;B0<A0.length;B0++){varC0=A0[B0];C0.OnNext(z0);}y0("N",z0);}};this.OnError=function(z0){if(!w0){varA0=u0.ToArray();for(varB0=0;B0<A0.length;B0++){varC0=A0[B0];C0.OnError(z0);}w0=true;u0.Clear();y0("E",z0);}};this.OnCompleted=function(){if(!w0){varz0=u0.ToArray();for(varA0=0;A0<z0.length;A0++){varB0=z0[A0];B0.OnCompleted();}w0=true;u0.Clear();y0("C");}};this.w=function(z0){varA0=newn0(this,z0);varB0=newn(A0);varC0=this;B0.Add(t0.Schedule(function(){if(!A0.B){C0.A();for(varD0=0;D0<v0.GetCount();D0++)v0.GetItem(D0).Value.Accept(z0);u0.Add(z0);A0.C=true;}}));returnB0;};this.D=function(z0){u0.Remove(z0);};};m0.prototype=newi0;varn0=function(r0,s0){this.E=r0;this.F=s0;this.C=false;this.B=false;this.Dispose=function(){if(this.C)this.E.D(this.F);this.B=true;};};varo0=D.ToAsync=function(r0,s0){if(s0===a)s0=A;returnfunction(){vart0=newk0(s0);varu0=function(){varx0;try{x0=r0.apply(this,arguments);}catch(y0){t0.OnError(y0);return;}t0.OnNext(x0);t0.OnCompleted();};varv0=this;varw0=p(arguments);s0.Schedule(function(){u0.apply(v0,w0);});returnt0;};};varp0=D.Start=function(r0,s0,t0,u0){if(t0===a)t0=[];returno0(r0,u0).apply(s0,t0);};varq0=b.ConnectableObservable=function(r0,s0){if(s0===a)s0=newi0();this.E=s0;this.G=r0;this.H=false;this.Connect=function(){vart0;varu0=false;if(!this.H){this.H=true;varv0=this;t0=newn(i(function(){v0.H=false;}));this.I=t0;t0.Add(r0.Subscribe(this.E));}returnthis.I;};this.w=function(t0){returnthis.E.Subscribe(t0);};this.RefCount=function(){vart0=0;varu0=this;varv0;returnF(function(w0){varx0=false;t0++;x0=t0==1;vary0=u0.Subscribe(w0);if(x0)v0=u0.Connect();returnfunction(){y0.Dispose();t0--;if(t0==0)v0.Dispose();};});};};q0.prototype=newD;})();