/* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/(function(a){varb={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeofwindow]&&window||this,d=b[typeofexports]&&exports&&!exports.nodeType&&exports,e=b[typeofmodule]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeofglobal]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeofdefine&&define.amd?define(["rx.binding","exports"],function(b,d){returnc.Rx=a(c,d,b),c.Rx}):"object"==typeofmodule&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c){functiond(a,b){returnArray.isArray(a)?e.call(b,a):i(a)?A(a.call(b)):j(a)?A(a):h(a)?f(a):isPromise(a)?g(a):typeofa===x?a:z(a)||Array.isArray(a)?e.call(b,a):a}functione(a){varb=this;returnfunction(c){functione(a,e){if(!f)try{if(a=d(a,b),typeofa!==x)returni[e]=a,--h||c(null,i);a.call(b,function(a,b){if(!f){if(a)returnf=!0,c(a);i[e]=b,--h||c(null,i)}})}catch(g){f=!0,c(g)}}varf,g=Object.keys(a),h=g.length,i=newa.constructor;if(!h)returnvoidu.schedule(function(){c(null,i)});for(varj=0,k=g.length;k>j;j++)e(a[g[j]],g[j])}}functionf(a){returnfunction(b){varc,d=!1;a.subscribe(function(a){c=a,d=!0},b,function(){d&&b(null,c)})}}functiong(a){returnfunction(b){a.then(function(a){b(null,a)},b)}}functionh(a){returna&&typeofa.subscribe===x}functioni(a){returna&&a.constructor&&"GeneratorFunction"===a.constructor.name}functionj(a){returna&&typeofa.next===x&&typeofa[y]===x}functionk(a){a&&u.schedule(function(){throwa})}functionl(a,b,c){if(a.addEventListener)returna.addEventListener(b,c,!1),s(function(){a.removeEventListener(b,c,!1)});thrownewError("No listener found")}functionm(a,b,c){vard=newt;if("[object NodeList]"===Object.prototype.toString.call(a))for(vare=0,f=a.length;f>e;e++)d.add(m(a.item(e),b,c));elsea&&d.add(l(a,b,c));returnd}varn=c.Observable,o=(n.prototype,n.fromPromise),p=n.throwException,q=c.AnonymousObservable,r=c.AsyncSubject,s=c.Disposable.create,t=c.CompositeDisposable,u=(c.Scheduler.immediate,c.Scheduler.timeout),v=c.helpers.isScheduler,w=Array.prototype.slice,x="function",y="throw",z=c.internals.isObject,A=c.spawn=function(a){varb=i(a);returnfunction(c){functione(a,b){u.schedule(c.bind(g,a,b))}functionf(a,b){varc;if(arguments.length>2&&(b=w.call(arguments,1)),a)try{c=h[y](a)}catch(i){returne(i)}if(!a)try{c=h.next(b)}catch(i){returne(i)}if(c.done)returne(null,c.value);if(c.value=d(c.value,g),typeofc.value!==x)f(newTypeError("Rx.spawn only supports a function, Promise, Observable, Object or Array."));else{varj=!1;try{c.value.call(g,function(){j||(j=!0,f.apply(g,arguments))})}catch(i){u.schedule(function(){j||(j=!0,f.call(g,i))})}}}varg=this,h=a;if(b){vari=w.call(arguments),j=i.length,l=j&&typeofi[j-1]===x;c=l?i.pop():k,h=a.apply(this,i)}elsec=c||k;f()}};n.start=function(a,b,c){returnB(a,b,c)()};varB=n.toAsync=function(a,b,c){returnv(c)||(c=u),function(){vard=arguments,e=newr;returnc.schedule(function(){varc;try{c=a.apply(b,d)}catch(f){returnvoide.onError(f)}e.onNext(c),e.onCompleted()}),e.asObservable()}};n.fromCallback=function(a,b,c){returnfunction(){vard=w.call(arguments,0);returnnewq(function(e){functionf(){vara=arguments;if(c){try{a=c(a)}catch(b){returnvoide.onError(b)}e.onNext(a)}elsea.length<=1?e.onNext.apply(e,a):e.onNext(a);e.onCompleted()}d.push(f),a.apply(b,d)}).publishLast().refCount()}},n.fromNodeCallback=function(a,b,c){returnfunction(){vard=w.call(arguments,0);returnnewq(function(e){functionf(a){if(a)returnvoide.onError(a);varb=w.call(arguments,1);if(c){try{b=c(b)}catch(d){returnvoide.onError(d)}e.onNext(b)}elseb.length<=1?e.onNext.apply(e,b):e.onNext(b);e.onCompleted()}d.push(f),a.apply(b,d)}).publishLast().refCount()}},c.config.useNativeEvents=!1,n.fromEvent=function(b,d,e){if(b.addListener)returnC(function(a){b.addListener(d,a)},function(a){b.removeListener(d,a)},e);if(!c.config.useNativeEvents){if("function"==typeofb.on&&"function"==typeofb.off)returnC(function(a){b.on(d,a)},function(a){b.off(d,a)},e);if(a.Ember&&"function"==typeofa.Ember.addListener)returnC(function(a){Ember.addListener(b,d,a)},function(a){Ember.removeListener(b,d,a)},e)}returnnewq(function(a){returnm(b,d,function(b){varc=b;if(e)try{c=e(arguments)}catch(d){returnvoida.onError(d)}a.onNext(c)})}).publish().refCount()};varC=n.fromEventPattern=function(a,b,c){returnnewq(function(d){functione(a){varb=a;if(c)try{b=c(arguments)}catch(e){returnvoidd.onError(e)}d.onNext(b)}varf=a(e);returns(function(){b&&b(e,f)})}).publish().refCount()};returnn.startAsync=function(a){varb;try{b=a()}catch(c){returnp(c)}returno(b)},c});//# sourceMappingURL=rx.async.map