Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

baconjs

Package Overview
Dependencies
Maintainers
2
Versions
224
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

baconjs - npm Package Compare versions

Comparing version 0.7.77 to 0.7.78

debounce.js

40

assemble.js

@@ -15,3 +15,2 @@ #!/usr/bin/env babel-node

var assert = require("assert");
var coffee = require("coffee-script");
var uglifyjs = require("uglify-js");

@@ -30,4 +29,4 @@ var esprima = require("esprima");

// Boilerplate: *header* and *footer*
var header = fs.readFileSync(path.join(__dirname, "src", "boilerplate", "object.coffee"), "utf-8");
var footer = fs.readFileSync(path.join(__dirname, "src", "boilerplate", "exports.coffee"), "utf-8");
var header = fs.readFileSync(path.join(__dirname, "src", "boilerplate", "object.js"), "utf-8");
var footer = fs.readFileSync(path.join(__dirname, "src", "boilerplate", "exports.js"), "utf-8");
// 16 spaces

@@ -53,38 +52,25 @@ var padding = " ";

var [coffeePieces, esPieces] = Deps.splitPieces(pieces);
if (options.verbose) {
console.info(esPieces.length + " of " + (esPieces.length + coffeePieces.length) + " pieces are JavaScript");
}
// Coffee pieces
var coffeeOutput = [
header,
_.pluck(coffeePieces, "contents").join("\n"),
footer,
].join("\n");
var coffeeTranspiled = coffee.compile(coffeeOutput);
// ES6 pieces
// let's be conservative with options:
// let's be conservative with Babel options:
var babelOptions = {
comments: false,
whitelist: [
"es3.memberExpressionLiterals",
"es3.propertyLiterals",
"es6.arrowFunctions",
"es6.blockScoping",
"es6.properties.shorthand",
"es6.constants",
"es6.destructuring",
"es6.parameters",
"es6.spread"
],
loose: [
"es6.destructuring"
]
};
var esOutput = _.pluck(esPieces, "contents").join("\n");
var esOutput = header + _.pluck(pieces, "contents").join("\n") + footer;
var esTranspiled = babel.transform(esOutput, babelOptions);
var output = "(function() {\n" + esTranspiled.code + "\n}).call(this);";
// Combining
var whereToInsert = "if ((typeof define !== \"undefined\" && define !== null) && (define.amd != null))";
assert(coffeeTranspiled.indexOf(whereToInsert) !== -1, "whereToInsert needle should be in coffee part");
var esInsert = esTranspiled.code + "\n\n" + whereToInsert;
var output = coffeeTranspiled.replace(whereToInsert, esInsert);
// Stripping asserts

@@ -91,0 +77,0 @@ function notAssertStatement(node) {

@@ -1,2 +0,2 @@

(function(){function t(t){if(Array.isArray(t)){for(var n=0,r=Array(t.length);n<t.length;n++)r[n]=t[n];return r}return Array.from(t)}var n,r,e,u,i,o,s,c,a,f,h,p,l,d,v,y,b,m,g,w,E,D,S,A,O,M,_,k,I,W,P,T,x,V,H,B,F,C,q,L,U,N,z,j,R,$,Q,Z,X,G,J,K,Y,tt,nt,rt,et,ut,it,ot,st,ct,at,ft,ht={}.hasOwnProperty,pt=function(t,n){function r(){this.constructor=t}for(var e in n)ht.call(n,e)&&(t[e]=n[e]);return r.prototype=n.prototype,t.prototype=new r,t.__super__=n.prototype,t},lt=[].slice,dt=function(t,n){return function(){return t.apply(n,arguments)}};n={toString:function(){return"Bacon"}},n.version="0.7.77",p=("undefined"!=typeof global&&null!==global?global:this).Error,J=function(){},z=function(t,n){return n},F=function(t,n){return t},M=function(t){return t.slice(0)},L=function(t){return t instanceof Array},N=function(t){return t instanceof y},D={indexOf:Array.prototype.indexOf?function(t,n){return t.indexOf(n)}:function(t,n){var r,e,u,i;for(r=e=0,u=t.length;u>e;r=++e)if(i=t[r],n===i)return r;return-1},indexWhere:function(t,n){var r,e,u,i;for(r=e=0,u=t.length;u>e;r=++e)if(i=t[r],n(i))return r;return-1},head:function(t){return t[0]},always:function(t){return function(){return t}},negate:function(t){return function(n){return!t(n)}},empty:function(t){return 0===t.length},tail:function(t){return t.slice(1,t.length)},filter:function(t,n){var r,e,u,i;for(r=[],e=0,u=n.length;u>e;e++)i=n[e],t(i)&&r.push(i);return r},map:function(t,n){var r,e,u,i;for(u=[],r=0,e=n.length;e>r;r++)i=n[r],u.push(t(i));return u},each:function(t,n){var r,e;for(r in t)ht.call(t,r)&&(e=t[r],n(r,e));return void 0},toArray:function(t){return L(t)?t:[t]},contains:function(t,n){return-1!==D.indexOf(t,n)},id:function(t){return t},last:function(t){return t[t.length-1]},all:function(t,n){var r,e,u;for(null==n&&(n=D.id),r=0,e=t.length;e>r;r++)if(u=t[r],!n(u))return!1;return!0},any:function(t,n){var r,e,u;for(null==n&&(n=D.id),r=0,e=t.length;e>r;r++)if(u=t[r],n(u))return!0;return!1},without:function(t,n){return D.filter(function(n){return n!==t},n)},remove:function(t,n){var r;return r=D.indexOf(n,t),r>=0?n.splice(r,1):void 0},fold:function(t,n,r){var e,u,i;for(e=0,u=t.length;u>e;e++)i=t[e],n=r(n,i);return n},flatMap:function(t,n){return D.fold(n,[],function(n,r){return n.concat(t(r))})},cached:function(t){var n;return n=v,function(){return n===v&&(n=t(),t=void 0),n}},isFunction:function(t){return"function"==typeof t},toString:function(t){var n,r,e,u;try{return Y++,null==t?"undefined":D.isFunction(t)?"function":L(t)?Y>5?"[..]":"["+D.map(D.toString,t).toString()+"]":null!=(null!=t?t.toString:void 0)&&t.toString!==Object.prototype.toString?t.toString():"object"==typeof t?Y>5?"{..}":(r=function(){var r;r=[];for(e in t)ht.call(t,e)&&(u=function(){try{return t[e]}catch(r){return n=r}}(),r.push(D.toString(e)+":"+D.toString(u)));return r}(),"{"+r+"}"):t}finally{Y--}}},Y=0,n._=D,E=n.UpdateBarrier=function(){var t,r,e,u,i,o,s,c,a,f,h,p,l,d;return f=void 0,h=[],p={},r=[],e=0,t=function(t){return f?r.push(t):t()},l=function(t,n){var r;return f?(r=p[t.id],null==r?(r=p[t.id]=[n],h.push(t)):r.push(n)):n()},i=function(){for(;h.length>0;)s(0);return void 0},s=function(t){var n,r,e,u,i,s;for(u=h[t],i=u.id,s=p[i],h.splice(t,1),delete p[i],o(u),r=0,e=s.length;e>r;r++)(n=s[r])();return void 0},o=function(t){var n,r,e,u,i;for(r=t.internalDeps(),u=0,i=r.length;i>u;u++)n=r[u],o(n),p[n.id]&&(e=D.indexOf(h,n),s(e));return void 0},a=function(t,n,u,o){var s,c;if(f)return u.apply(n,o);f=t;try{c=u.apply(n,o),i()}finally{for(f=void 0;e<r.length;)s=r[e],e++,s();e=0,r=[]}return c},u=function(){return f?f.id:void 0},d=function(r,e){var u,i,o,s;return s=!1,i=!1,u=function(){return i=!0},o=function(){return s=!0,u()},u=r.dispatcher.subscribe(function(r){return t(function(){var t;return s||(t=e(r),t!==n.noMore)?void 0:o()})}),i&&u(),o},c=function(){return h.length>0},{whenDoneWith:l,hasWaiters:c,inTransaction:a,currentEventId:u,wrappedSubscribe:d,afterTransaction:t}}(),w=function(){function t(t,n,r){this.obs=t,this.sync=n,this.lazy=null!=r?r:!1,this.queue=[]}return t.prototype.subscribe=function(t){return this.obs.dispatcher.subscribe(t)},t.prototype.toString=function(){return this.obs.toString()},t.prototype.markEnded=function(){return this.ended=!0},t.prototype.consume=function(){return this.lazy?{value:D.always(this.queue[0])}:this.queue[0]},t.prototype.push=function(t){return this.queue=[t]},t.prototype.mayHave=function(){return!0},t.prototype.hasAtLeast=function(){return this.queue.length},t.prototype.flatten=!0,t}(),i=function(t){function n(){return n.__super__.constructor.apply(this,arguments)}return pt(n,t),n.prototype.consume=function(){return this.queue.shift()},n.prototype.push=function(t){return this.queue.push(t)},n.prototype.mayHave=function(t){return!this.ended||this.queue.length>=t},n.prototype.hasAtLeast=function(t){return this.queue.length>=t},n.prototype.flatten=!1,n}(w),r=function(t){function n(t){n.__super__.constructor.call(this,t,!0)}return pt(n,t),n.prototype.consume=function(){var t;return t=this.queue,this.queue=[],{value:function(){return t}}},n.prototype.push=function(t){return this.queue.push(t.value())},n.prototype.hasAtLeast=function(){return!0},n}(w),w.isTrigger=function(t){return t instanceof w?t.sync:t instanceof h},w.fromObservable=function(t){return t instanceof w?t:t instanceof b?new w(t,!1):new i(t,!0)},o=function(){function t(t,n,r){this.context=t,this.method=n,this.args=r}return t.prototype.deps=function(){return this.cached||(this.cached=V([this.context].concat(this.args)))},t.prototype.toString=function(){return D.toString(this.context)+"."+D.toString(this.method)+"("+D.map(D.toString,this.args)+")"},t}(),W=function(){var t,n,r;return n=arguments[0],r=arguments[1],t=3<=arguments.length?lt.call(arguments,2):[],(n||r)instanceof o?n||r:new o(n,r,t)},at=function(t,n){return n.desc=t,n},V=function(t){return L(t)?D.flatMap(V,t):N(t)?[t]:t instanceof w?[t.obs]:[]},n.Desc=o,n.Desc.empty=new n.Desc("","",[]),ft=function(t){return function(){var n,r,e,u;return e=arguments[0],n=2<=arguments.length?lt.call(arguments,1):[],"object"==typeof e&&n.length&&(r=e,u=n[0],e=function(){return r[u].apply(r,arguments)},n=n.slice(1)),t.apply(null,[e].concat(lt.call(n)))}},$=function(t){return t=Array.prototype.slice.call(t),Q.apply(null,t)},K=function(t,n){return function(){var r;return r=1<=arguments.length?lt.call(arguments,0):[],t.apply(null,n.concat(r))}},st=function(t){return function(n){return function(r){var e;return null==r?void 0:(e=r[n],D.isFunction(e)?e.apply(r,t):e)}}},ut=function(t,n){var r,e;return e=t.slice(1).split("."),r=D.map(st(n),e),function(n){var e,u;for(e=0,u=r.length;u>e;e++)t=r[e],n=t(n);return n}},U=function(t){return"string"==typeof t&&t.length>1&&"."===t.charAt(0)},Q=ft(function(){var t,n;return n=arguments[0],t=2<=arguments.length?lt.call(arguments,1):[],D.isFunction(n)?t.length?K(n,t):n:U(n)?ut(n,t):D.always(n)}),R=function(t,n){return Q.apply(null,[t].concat(lt.call(n)))},I=function(t,n,r,e){var u;return n instanceof b?(u=n.sampledBy(t,function(t,n){return[t,n]}),e.call(u,function(t){var n,r;return n=t[0],r=t[1],n}).map(function(t){var n,r;return n=t[0],r=t[1]})):(n=R(n,r),e.call(t,n))},rt=function(t){var n;if(D.isFunction(t))return t;if(U(t))return n=it(t),function(t,r){return t[n](r)};throw new p("not a function or a field key: "+t)},it=function(t){return t.slice(1)},g=function(){function t(t){this.value=t}return t.prototype.getOrElse=function(){return this.value},t.prototype.get=function(){return this.value},t.prototype.filter=function(n){return n(this.value)?new t(this.value):v},t.prototype.map=function(n){return new t(n(this.value))},t.prototype.forEach=function(t){return t(this.value)},t.prototype.isDefined=!0,t.prototype.toArray=function(){return[this.value]},t.prototype.inspect=function(){return"Some("+this.value+")"},t.prototype.toString=function(){return this.inspect()},t}(),v={getOrElse:function(t){return t},filter:function(){return v},map:function(){return v},forEach:function(){},isDefined:!1,toArray:function(){return[]},inspect:function(){return"None"},toString:function(){return this.inspect()}},ot=function(t){return t instanceof g||t===v?t:new g(t)},n.noMore=["<no-more>"],n.more=["<more>"],T=0,f=function(){function t(){this.id=++T}return t.prototype.isEvent=function(){return!0},t.prototype.isEnd=function(){return!1},t.prototype.isInitial=function(){return!1},t.prototype.isNext=function(){return!1},t.prototype.isError=function(){return!1},t.prototype.hasValue=function(){return!1},t.prototype.filter=function(){return!0},t.prototype.inspect=function(){return this.toString()},t.prototype.log=function(){return this.toString()},t}(),d=function(t){function n(t,r){return this instanceof n?(n.__super__.constructor.call(this),void(!r&&D.isFunction(t)||t instanceof n?(this.valueF=t,this.valueInternal=void 0):(this.valueF=void 0,this.valueInternal=t))):new n(t,r)}return pt(n,t),n.prototype.isNext=function(){return!0},n.prototype.hasValue=function(){return!0},n.prototype.value=function(){return this.valueF instanceof n?(this.valueInternal=this.valueF.value(),this.valueF=void 0):this.valueF&&(this.valueInternal=this.valueF(),this.valueF=void 0),this.valueInternal},n.prototype.fmap=function(t){var n,r;return this.valueInternal?(r=this.valueInternal,this.apply(function(){return t(r)})):(n=this,this.apply(function(){return t(n.value())}))},n.prototype.apply=function(t){return new n(t)},n.prototype.filter=function(t){return t(this.value())},n.prototype.toString=function(){return D.toString(this.value())},n.prototype.log=function(){return this.value()},n}(f),l=function(t){function n(t,r){return this instanceof n?void n.__super__.constructor.call(this,t,r):new n(t,r)}return pt(n,t),n.prototype.isInitial=function(){return!0},n.prototype.isNext=function(){return!1},n.prototype.apply=function(t){return new n(t)},n.prototype.toNext=function(){return new d(this)},n}(d),c=function(t){function n(){return this instanceof n?void 0:new n}return pt(n,t),n.prototype.isEnd=function(){return!0},n.prototype.fmap=function(){return this},n.prototype.apply=function(){return this},n.prototype.toString=function(){return"<end>"},n}(f),a=function(t){function n(t){return this instanceof n?void(this.error=t):new n(t)}return pt(n,t),n.prototype.isError=function(){return!0},n.prototype.fmap=function(){return this},n.prototype.apply=function(){return this},n.prototype.toString=function(){return"<error> "+D.toString(this.error)},n}(f),n.Event=f,n.Initial=l,n.Next=d,n.End=c,n.Error=a,q=function(t){return new l(t,!0)},G=function(t){return new d(t,!0)},P=function(){return new c},et=function(t){return t instanceof f?t:G(t)},C=0,tt=function(){},y=function(){function t(t){this.desc=t,this.id=++C,this.initialDesc=this.desc}return t.prototype.subscribe=function(t){return E.wrappedSubscribe(this,t)},t.prototype.subscribeInternal=function(t){return this.dispatcher.subscribe(t)},t.prototype.onValue=function(){var t;return t=$(arguments),this.subscribe(function(n){return n.hasValue()?t(n.value()):void 0})},t.prototype.onValues=function(t){return this.onValue(function(n){return t.apply(null,n)})},t.prototype.onError=function(){var t;return t=$(arguments),this.subscribe(function(n){return n.isError()?t(n.error):void 0})},t.prototype.onEnd=function(){var t;return t=$(arguments),this.subscribe(function(n){return n.isEnd()?t():void 0})},t.prototype.name=function(t){return this._name=t,this},t.prototype.withDescription=function(){return this.desc=W.apply(null,arguments),this},t.prototype.toString=function(){return this._name?this._name:this.desc.toString()},t.prototype.internalDeps=function(){return this.initialDesc.deps()},t}(),y.prototype.assign=y.prototype.onValue,y.prototype.forEach=y.prototype.onValue,y.prototype.inspect=y.prototype.toString,n.Observable=y,u=function(){function t(t){var n,r,e;for(null==t&&(t=[]),this.unsubscribe=dt(this.unsubscribe,this),this.unsubscribed=!1,this.subscriptions=[],this.starting=[],n=0,r=t.length;r>n;n++)e=t[n],this.add(e)}return t.prototype.add=function(t){var n,r,e;if(!this.unsubscribed)return n=!1,r=J,this.starting.push(t),e=function(e){return function(){return e.unsubscribed?void 0:(n=!0,e.remove(r),D.remove(t,e.starting))}}(this),r=t(this.unsubscribe,e),this.unsubscribed||n?r():this.subscriptions.push(r),D.remove(t,this.starting),r},t.prototype.remove=function(t){return this.unsubscribed?void 0:void 0!==D.remove(t,this.subscriptions)?t():void 0},t.prototype.unsubscribe=function(){var t,n,r,e;if(!this.unsubscribed){for(this.unsubscribed=!0,r=this.subscriptions,t=0,n=r.length;n>t;t++)(e=r[t])();return this.subscriptions=[],this.starting=[]}},t.prototype.count=function(){return this.unsubscribed?0:this.subscriptions.length+this.starting.length},t.prototype.empty=function(){return 0===this.count()},t}(),n.CompositeUnsubscribe=u,s=function(){function t(t,n){this._subscribe=t,this._handleEvent=n,this.subscribe=dt(this.subscribe,this),this.handleEvent=dt(this.handleEvent,this),this.subscriptions=[],this.queue=[]}return t.prototype.pushing=!1,t.prototype.ended=!1,t.prototype.prevError=void 0,t.prototype.unsubSrc=void 0,t.prototype.hasSubscribers=function(){return this.subscriptions.length>0},t.prototype.removeSub=function(t){return this.subscriptions=D.without(t,this.subscriptions)},t.prototype.push=function(t){return t.isEnd()&&(this.ended=!0),E.inTransaction(t,this,this.pushIt,[t])},t.prototype.pushToSubscriptions=function(t){var r,e,u,i,o,s;try{for(s=this.subscriptions,e=0,u=s.length;u>e;e++)o=s[e],i=o.sink(t),(i===n.noMore||t.isEnd())&&this.removeSub(o);return!0}catch(c){throw r=c,this.pushing=!1,this.queue=[],r}},t.prototype.pushIt=function(t){if(this.pushing)return this.queue.push(t),n.more;if(t!==this.prevError){for(t.isError()&&(this.prevError=t),this.pushing=!0,this.pushToSubscriptions(t),this.pushing=!1;this.queue.length;)t=this.queue.shift(),this.push(t);return this.hasSubscribers()?n.more:(this.unsubscribeFromSource(),n.noMore)}},t.prototype.handleEvent=function(t){return this._handleEvent?this._handleEvent(t):this.push(t)},t.prototype.unsubscribeFromSource=function(){return this.unsubSrc&&this.unsubSrc(),this.unsubSrc=void 0},t.prototype.subscribe=function(t){var n;return this.ended?(t(P()),J):(n={sink:t},this.subscriptions.push(n),1===this.subscriptions.length&&(this.unsubSrc=this._subscribe(this.handleEvent)),function(t){return function(){return t.removeSub(n),t.hasSubscribers()?void 0:t.unsubscribeFromSource()}}(this))},t}(),n.Dispatcher=s,h=function(t){function r(t,n,e){return this instanceof r?(D.isFunction(t)&&(e=n,n=t,t=o.empty),r.__super__.constructor.call(this,t),this.dispatcher=new s(n,e),void tt(this)):new r(t,n,e)}return pt(r,t),r.prototype.toProperty=function(t){var r,e;return e=0===arguments.length?v:ot(function(){return t}),r=this.dispatcher,new b(new n.Desc(this,"toProperty",[t]),function(t){var u,i,o,s,c;return u=!1,s=!1,c=J,i=n.more,o=function(){return u?void 0:e.forEach(function(r){return u=!0,i=t(new l(r)),i===n.noMore?(c(),c=J):void 0})},c=r.subscribe(function(r){return r.hasValue()?r.isInitial()&&!s?(e=new g(function(t){return function(){return r.value()}}(this)),n.more):(r.isInitial()||o(),u=!0,e=new g(r),t(r)):(r.isEnd()&&(i=o()),i!==n.noMore?t(r):void 0)}),s=!0,o(),c})},r.prototype.toEventStream=function(){return this},r.prototype.withHandler=function(t){return new r(new n.Desc(this,"withHandler",[t]),this.dispatcher.subscribe,t)},r}(y),n.EventStream=h,n.never=function(){return new h(W(n,"never"),function(t){return t(P()),J})},n.when=function(){var t,r,e,u,i,o,s,c,a,f,p,l,d,v,y,b,m,g,S,A;if(0===arguments.length)return n.never();for(s=arguments.length,A="when: expecting arguments in the form (Observable+,function)+",g=[],d=[],r=0,v=[];s>r;){for(v[r]=arguments[r],v[r+1]=arguments[r+1],l=D.toArray(arguments[r]),t=_(arguments[r+1]),p={f:t,ixs:[]},S=!1,i=0,c=l.length;c>i;i++){for(m=l[i],e=D.indexOf(g,m),S||(S=w.isTrigger(m)),0>e&&(g.push(m),e=g.length-1),y=p.ixs,o=0,a=y.length;a>o;o++)u=y[o],u.index===e&&u.count++;p.ixs.push({index:e,count:1})}l.length>0&&d.push(p),r+=2}return g.length?(g=D.map(w.fromObservable,g),f=D.any(g,function(t){return t.flatten})&&k(D.map(function(t){return t.obs},g)),b=new h(new n.Desc(n,"when",v),function(t){var e,u,i,o,s,c,a;return a=[],i=!1,o=function(t){var n,e,u;for(u=t.ixs,n=0,e=u.length;e>n;n++)if(r=u[n],!g[r.index].hasAtLeast(r.count))return!1;return!0},u=function(t){return!t.sync||t.ended},e=function(t){var n,e,u;for(u=t.ixs,n=0,e=u.length;e>n;n++)if(r=u[n],!g[r.index].mayHave(r.count))return!0},s=function(t){return!t.source.flatten},c=function(c){return function(h){var p,l,v;return l=function(){return E.whenDoneWith(b,p)},v=function(){var e,u,i,c,f,h;if(!(a.length>0))return n.more;for(f=n.more,h=a.pop(),u=0,i=d.length;i>u;u++)if(c=d[u],o(c))return e=function(){var t,n,e,u;for(e=c.ixs,u=[],n=0,t=e.length;t>n;n++)r=e[n],u.push(g[r.index].consume());return u}(),f=t(h.e.apply(function(){var t,n;return n=function(){var n,r,u;for(u=[],r=0,n=e.length;n>r;r++)t=e[r],u.push(t.value());return u}(),c.f.apply(c,n)})),a.length&&(a=D.filter(s,a)),f===n.noMore?f:v()},p=function(){var r;return r=v(),i&&(D.all(g,u)||D.all(d,e))&&(r=n.noMore,t(P())),r===n.noMore&&h(),r},c.subscribe(function(r){var e;return r.isEnd()?(i=!0,c.markEnded(),l()):r.isError()?e=t(r):(c.push(r),c.sync&&(a.push({source:c,e:r}),f||E.hasWaiters()?l():p())),e===n.noMore&&h(),e||n.more})}},new n.CompositeUnsubscribe(function(){var t,n,r;for(r=[],t=0,n=g.length;n>t;t++)m=g[t],r.push(c(m));return r}()).unsubscribe})):n.never()},k=function(t,n){var r;return null==n&&(n=[]),r=function(t){var e;return D.contains(n,t)?!0:(e=t.internalDeps(),e.length?(n.push(t),D.any(e,r)):(n.push(t),!1))},D.any(t,r)},_=function(t){return D.isFunction(t)?t:D.always(t)},n.groupSimultaneous=function(){var t,e,u;return u=1<=arguments.length?lt.call(arguments,0):[],1===u.length&&L(u[0])&&(u=u[0]),e=function(){var n,e,i;for(i=[],n=0,e=u.length;e>n;n++)t=u[n],i.push(new r(t));return i}(),at(new n.Desc(n,"groupSimultaneous",u),n.when(e,function(){var t;return t=1<=arguments.length?lt.call(arguments,0):[]}))},m=function(t){function r(t,n,e){this.property=t,this.subscribe=dt(this.subscribe,this),r.__super__.constructor.call(this,n,e),this.current=v,this.currentValueRootId=void 0,this.propertyEnded=!1}return pt(r,t),r.prototype.push=function(t){return t.isEnd()&&(this.propertyEnded=!0),t.hasValue()&&(this.current=new g(t),this.currentValueRootId=E.currentEventId()),r.__super__.push.call(this,t)},r.prototype.maybeSubSource=function(t,r){return r===n.noMore?J:this.propertyEnded?(t(P()),J):s.prototype.subscribe.call(this,t)},r.prototype.subscribe=function(t){var r,e,u,i;return e=!1,u=n.more,this.current.isDefined&&(this.hasSubscribers()||this.propertyEnded)?(r=E.currentEventId(),i=this.currentValueRootId,!this.propertyEnded&&i&&r&&r!==i?(E.whenDoneWith(this.property,function(n){return function(){return n.currentValueRootId===i?t(q(n.current.get().value())):void 0}}(this)),this.maybeSubSource(t,u)):(E.inTransaction(void 0,this,function(){return u=t(q(this.current.get().value()))},[]),this.maybeSubSource(t,u))):this.maybeSubSource(t,u)},r}(s),b=function(t){function r(t,n,e){r.__super__.constructor.call(this,t),this.dispatcher=new m(this,n,e),tt(this)}return pt(r,t),r.prototype.changes=function(){return new h(new n.Desc(this,"changes",[]),function(t){return function(n){return t.dispatcher.subscribe(function(t){return t.isInitial()?void 0:n(t)})}}(this))},r.prototype.withHandler=function(t){return new r(new n.Desc(this,"withHandler",[t]),this.dispatcher.subscribe,t)},r.prototype.toProperty=function(){return this},r.prototype.toEventStream=function(){return new h(new n.Desc(this,"toEventStream",[]),function(t){return function(n){return t.dispatcher.subscribe(function(t){return t.isInitial()&&(t=t.toNext()),n(t)})}}(this))},r}(y),n.Property=b,n.constant=function(t){return new b(new n.Desc(n,"constant",[t]),function(n){return n(q(t)),n(P()),J})},n.fromBinder=function(t,r){return null==r&&(r=D.id),new h(new n.Desc(n,"fromBinder",[t,r]),function(e){var u,i,o,s;return s=!1,u=!1,i=function(){return s?void 0:"undefined"!=typeof o&&null!==o?(o(),s=!0):u=!0},o=t(function(){var t,u,o,s,c,a;for(t=1<=arguments.length?lt.call(arguments,0):[],a=r.apply(this,t),L(a)&&D.last(a)instanceof f||(a=[a]),c=n.more,o=0,s=a.length;s>o;o++)if(u=a[o],c=e(u=et(u)),c===n.noMore||u.isEnd())return i(),c;return c}),u&&i(),i})},n.Observable.prototype.map=function(){var t,r;return r=arguments[0],t=2<=arguments.length?lt.call(arguments,1):[],I(this,r,t,function(t){return at(new n.Desc(this,"map",[t]),this.withHandler(function(n){return this.push(n.fmap(t))}))})},A=function(t){return L(t[0])?t[0]:Array.prototype.slice.call(t)},O=function(t){return D.isFunction(t[0])?[A(Array.prototype.slice.call(t,1)),t[0]]:[A(Array.prototype.slice.call(t,0,t.length-1)),D.last(t)]},n.combineAsArray=function(){var t,r,e,u,i,o,s;for(s=A(arguments),t=r=0,e=s.length;e>r;t=++r)o=s[t],N(o)||(s[t]=n.constant(o));return s.length?(i=function(){var t,n,r;for(r=[],t=0,n=s.length;n>t;t++)u=s[t],r.push(new w(u,!0));return r}(),at(new n.Desc(n,"combineAsArray",s),n.when(i,function(){var t;return t=1<=arguments.length?lt.call(arguments,0):[]}).toProperty())):n.constant([])},n.onValues=function(){var t,r,e;return e=2<=arguments.length?lt.call(arguments,0,r=arguments.length-1):(r=0,[]),t=arguments[r++],n.combineAsArray(e).onValues(t)},n.combineWith=function(){var t,r,e;return r=O(arguments),e=r[0],t=r[1],at(new n.Desc(n,"combineWith",[t].concat(lt.call(e))),n.combineAsArray(e).map(function(n){return t.apply(null,n)}))},n.Observable.prototype.combine=function(t,r){var e;return e=rt(r),at(new n.Desc(this,"combine",[t,r]),n.combineAsArray(this,t).map(function(t){return e(t[0],t[1])}))},n.Observable.prototype.withStateMachine=function(t,r){var e;return e=t,at(new n.Desc(this,"withStateMachine",[t,r]),this.withHandler(function(t){var u,i,o,s,c,a,f;for(u=r(e,t),s=u[0],a=u[1],e=s,f=n.more,i=0,o=a.length;o>i;i++)if(c=a[i],f=this.push(c),f===n.noMore)return f;return f}))},n.Observable.prototype.skipDuplicates=function(t){return null==t&&(t=function(t,n){return t===n}),at(new n.Desc(this,"skipDuplicates",[]),this.withStateMachine(v,function(n,r){return r.hasValue()?r.isInitial()||n===v||!t(n.get(),r.value())?[new g(r.value()),[r]]:[n,[]]:[n,[r]]}))},n.Observable.prototype.awaiting=function(t){return at(new n.Desc(this,"awaiting",[t]),n.groupSimultaneous(this,t).map(function(t){var n,r;return n=t[0],r=t[1],0===r.length}).toProperty(!1).skipDuplicates())},n.Observable.prototype.not=function(){return at(new n.Desc(this,"not",[]),this.map(function(t){return!t}))},n.Property.prototype.and=function(t){return at(new n.Desc(this,"and",[t]),this.combine(t,function(t,n){return t&&n}))},n.Property.prototype.or=function(t){return at(new n.Desc(this,"or",[t]),this.combine(t,function(t,n){return t||n}))},n.scheduler={setTimeout:function(t,n){return setTimeout(t,n)},setInterval:function(t,n){return setInterval(t,n)},clearInterval:function(t){return clearInterval(t)},clearTimeout:function(t){return clearTimeout(t)},now:function(){return(new Date).getTime()}},n.EventStream.prototype.bufferWithTime=function(t){return at(new n.Desc(this,"bufferWithTime",[t]),this.bufferWithTimeOrCount(t,Number.MAX_VALUE))},n.EventStream.prototype.bufferWithCount=function(t){return at(new n.Desc(this,"bufferWithCount",[t]),this.bufferWithTimeOrCount(void 0,t))},n.EventStream.prototype.bufferWithTimeOrCount=function(t,r){var e;return e=function(n){return n.values.length===r?n.flush():void 0!==t?n.schedule():void 0},at(new n.Desc(this,"bufferWithTimeOrCount",[t,r]),this.buffer(t,e,e))},n.EventStream.prototype.buffer=function(t,r,e){var u,i,o;return null==r&&(r=J),null==e&&(e=J),u={scheduled:null,end:void 0,values:[],flush:function(){var t,r;if(this.scheduled&&(n.scheduler.clearTimeout(this.scheduled),this.scheduled=null),this.values.length>0){if(r=this.values,this.values=[],t=this.push(G(r)),null!=this.end)return this.push(this.end);if(t!==n.noMore)return e(this)}else if(null!=this.end)return this.push(this.end)},schedule:function(){return this.scheduled?void 0:this.scheduled=t(function(t){return function(){return t.flush()}}(this))}},o=n.more,D.isFunction(t)||(i=t,t=function(t){return n.scheduler.setTimeout(t,i)}),at(new n.Desc(this,"buffer",[]),this.withHandler(function(t){return u.push=function(t){return function(n){return t.push(n)}}(this),t.isError()?o=this.push(t):t.isEnd()?(u.end=t,u.scheduled||u.flush()):(u.values.push(t.value()),r(u)),o}))},n.Observable.prototype.filter=function(){var t,r;return r=arguments[0],t=2<=arguments.length?lt.call(arguments,1):[],I(this,r,t,function(t){return at(new n.Desc(this,"filter",[t]),this.withHandler(function(r){return r.filter(t)?this.push(r):n.more}))})},n.once=function(t){return new h(new o(n,"once",[t]),function(n){return n(et(t)),n(P()),J})},n.EventStream.prototype.concat=function(t){var r;return r=this,new h(new n.Desc(r,"concat",[t]),function(n){var e,u;return u=J,e=r.dispatcher.subscribe(function(r){return r.isEnd()?u=t.dispatcher.subscribe(n):n(r)}),function(){return e(),u()}})},n.Observable.prototype.flatMap=function(){return B(this,X(arguments))},n.Observable.prototype.flatMapFirst=function(){return B(this,X(arguments),!0)},B=function(t,r,e,i){var o,s,c;return c=[t],o=[],s=new h(new n.Desc(t,"flatMap"+(e?"First":""),[r]),function(s){var c,a,f,h,p;return f=new u,h=[],p=function(t){var e;return e=Z(r(t.value())),o.push(e),f.add(function(t,r){return e.dispatcher.subscribe(function(u){var i;return u.isEnd()?(D.remove(e,o),a(),c(r),n.noMore):(u instanceof l&&(u=u.toNext()),i=s(u),i===n.noMore&&t(),i)})})},a=function(){var t;return t=h.shift(),t?p(t):void 0},c=function(t){return t(),f.empty()?s(P()):void 0},f.add(function(r,u){return t.dispatcher.subscribe(function(t){return t.isEnd()?c(u):t.isError()?s(t):e&&f.count()>1?n.more:f.unsubscribed?n.noMore:i&&f.count()>i?h.push(t):p(t)})}),f.unsubscribe}),s.internalDeps=function(){return o.length?c.concat(o):c},s},X=function(t){return 1===t.length&&N(t[0])?D.always(t[0]):$(t)},Z=function(t){return N(t)?t:n.once(t)},n.Observable.prototype.flatMapWithConcurrencyLimit=function(){var t,r;return r=arguments[0],t=2<=arguments.length?lt.call(arguments,1):[],at(new n.Desc(this,"flatMapWithConcurrencyLimit",[r].concat(lt.call(t))),B(this,X(t),!1,r))},n.Observable.prototype.flatMapConcat=function(){return at(new n.Desc(this,"flatMapConcat",Array.prototype.slice.call(arguments,0)),this.flatMapWithConcurrencyLimit.apply(this,[1].concat(lt.call(arguments))))},n.later=function(t,r){return at(new n.Desc(n,"later",[t,r]),n.fromBinder(function(e){var u,i;return i=function(){return e([r,P()])},u=n.scheduler.setTimeout(i,t),function(){return n.scheduler.clearTimeout(u)}}))},n.Observable.prototype.bufferingThrottle=function(t){return at(new n.Desc(this,"bufferingThrottle",[t]),this.flatMapConcat(function(r){return n.once(r).concat(n.later(t).filter(!1))}))},n.Property.prototype.bufferingThrottle=function(){return n.Observable.prototype.bufferingThrottle.apply(this,arguments).toProperty()},e=function(t){function r(){return this.guardedSink=dt(this.guardedSink,this),this.subscribeAll=dt(this.subscribeAll,this),this.unsubAll=dt(this.unsubAll,this),this instanceof r?(this.sink=void 0,this.subscriptions=[],this.ended=!1,void r.__super__.constructor.call(this,new n.Desc(n,"Bus",[]),this.subscribeAll)):new r}return pt(r,t),r.prototype.unsubAll=function(){var t,n,r,e;for(r=this.subscriptions,t=0,n=r.length;n>t;t++)e=r[t],"function"==typeof e.unsub&&e.unsub();return void 0},r.prototype.subscribeAll=function(t){var n,r,e,u;if(this.ended)t(P());else for(this.sink=t,e=M(this.subscriptions),n=0,r=e.length;r>n;n++)u=e[n],this.subscribeInput(u);return this.unsubAll},r.prototype.guardedSink=function(t){return function(r){return function(e){return e.isEnd()?(r.unsubscribeInput(t),n.noMore):r.sink(e)}}(this)},r.prototype.subscribeInput=function(t){return t.unsub=t.input.dispatcher.subscribe(this.guardedSink(t.input))},r.prototype.unsubscribeInput=function(t){var n,r,e,u,i;for(u=this.subscriptions,n=r=0,e=u.length;e>r;n=++r)if(i=u[n],i.input===t)return"function"==typeof i.unsub&&i.unsub(),void this.subscriptions.splice(n,1)},r.prototype.plug=function(t){var n;if(!this.ended)return n={input:t},this.subscriptions.push(n),null!=this.sink&&this.subscribeInput(n),function(n){return function(){return n.unsubscribeInput(t)}}(this)},r.prototype.end=function(){return this.ended=!0,this.unsubAll(),"function"==typeof this.sink?this.sink(P()):void 0},r.prototype.push=function(t){return this.ended?void 0:"function"==typeof this.sink?this.sink(G(t)):void 0},r.prototype.error=function(t){return"function"==typeof this.sink?this.sink(new a(t)):void 0},r}(h),n.Bus=e,j=function(t,r){return ft(function(){var e,u,i;return u=arguments[0],e=2<=arguments.length?lt.call(arguments,1):[],i=K(r,[function(t,n){return u.apply(null,lt.call(t).concat([n]))}]),at(new n.Desc(n,t,[u].concat(lt.call(e))),n.combineAsArray(e).flatMap(i))})},n.fromCallback=j("fromCallback",function(){var t,r;return r=arguments[0],t=2<=arguments.length?lt.call(arguments,1):[],n.fromBinder(function(n){return R(r,t)(n),J},function(t){return[t,P()]})}),n.fromNodeCallback=j("fromNodeCallback",function(){var t,r;return r=arguments[0],t=2<=arguments.length?lt.call(arguments,1):[],n.fromBinder(function(n){return R(r,t)(n),J},function(t,n){return t?[new a(t),P()]:[n,P()]})}),n.combineTemplate=function(t){var r,e,u,i,o,s,c,a,f,h,p;return c=[],p=[],s=function(t){return t[t.length-1]},h=function(t,n,r){return s(t)[n]=r},r=function(t,n){return function(r,e){return h(r,t,e[n])}},o=function(t,n){return function(r){return h(r,t,n)}},a=function(t){return L(t)?[]:{}},f=function(t,n){return function(r){var e;return e=a(n),h(r,t,e),r.push(e)}},u=function(t,n){var e;return N(n)?(p.push(n),c.push(r(t,p.length-1))):n!==Object(n)||"function"==typeof n||n instanceof RegExp||n instanceof Date?c.push(o(t,n)):(e=function(t){return t.pop()},c.push(f(t,n)),i(n),c.push(e))},i=function(t){return D.each(t,u)},i(t),e=function(n){var r,e,u,i,o;for(o=a(t),r=[o],u=0,i=c.length;i>u;u++)(e=c[u])(r,n);return o},at(new n.Desc(n,"combineTemplate",[t]),n.combineAsArray(p).map(e))},S=function(t,r){var e;return e=new h(W(t,"justInitValue"),function(r){var u,i;return i=void 0,u=t.dispatcher.subscribe(function(t){return t.isEnd()||(i=t),n.noMore}),E.whenDoneWith(e,function(){return null!=i&&r(i),r(P())}),u}),e.concat(r).toProperty()},n.Observable.prototype.mapEnd=function(){var t;return t=$(arguments),at(new n.Desc(this,"mapEnd",[t]),this.withHandler(function(r){return r.isEnd()?(this.push(G(t(r))),this.push(P()),n.noMore):this.push(r)}))},n.Observable.prototype.skipErrors=function(){return at(new n.Desc(this,"skipErrors",[]),this.withHandler(function(t){return t.isError()?n.more:this.push(t)}))},n.EventStream.prototype.takeUntil=function(t){var r;return r={},at(new n.Desc(this,"takeUntil",[t]),n.groupSimultaneous(this.mapEnd(r),t.skipErrors()).withHandler(function(e){var u,i,o,s,c,a;if(e.hasValue()){if(s=e.value(),u=s[0],t=s[1],t.length)return this.push(P());for(c=n.more,i=0,o=u.length;o>i;i++)a=u[i],c=this.push(a===r?P():G(a));return c}return this.push(e)}))},n.Property.prototype.takeUntil=function(t){var r;return r=this.changes().takeUntil(t),at(new n.Desc(this,"takeUntil",[t]),S(this,r))},n.Observable.prototype.flatMapLatest=function(){var t,r;return t=X(arguments),r=this.toEventStream(),at(new n.Desc(this,"flatMapLatest",[t]),r.flatMap(function(n){return Z(t(n)).takeUntil(r)}))},n.Property.prototype.delayChanges=function(t,n){return at(t,S(this,n(this.changes())))},n.EventStream.prototype.delay=function(t){return at(new n.Desc(this,"delay",[t]),this.flatMap(function(r){return n.later(t,r)}))},n.Property.prototype.delay=function(t){return this.delayChanges(new n.Desc(this,"delay",[t]),function(n){return n.delay(t)})},n.EventStream.prototype.debounce=function(t){return at(new n.Desc(this,"debounce",[t]),this.flatMapLatest(function(r){
return n.later(t,r)}))},n.Property.prototype.debounce=function(t){return this.delayChanges(new n.Desc(this,"debounce",[t]),function(n){return n.debounce(t)})},n.EventStream.prototype.debounceImmediate=function(t){return at(new n.Desc(this,"debounceImmediate",[t]),this.flatMapFirst(function(r){return n.once(r).concat(n.later(t).filter(!1))}))},n.Observable.prototype.decode=function(t){return at(new n.Desc(this,"decode",[t]),this.combine(n.combineTemplate(t),function(t,n){return n[t]}))},n.Observable.prototype.scan=function(t,r){var e,u,i,o;return r=rt(r),e=ot(t),u=!1,o=function(t){return function(o){var s,c,a,f;return s=!1,f=J,c=n.more,a=function(){return s?void 0:e.forEach(function(t){return s=u=!0,c=o(new l(function(){return t})),c===n.noMore?(f(),f=J):void 0})},f=t.dispatcher.subscribe(function(t){var i,f;return t.hasValue()?u&&t.isInitial()?n.more:(t.isInitial()||a(),s=u=!0,f=e.getOrElse(void 0),i=r(f,t.value()),e=new g(i),o(t.apply(function(){return i}))):(t.isEnd()&&(c=a()),c!==n.noMore?o(t):void 0)}),E.whenDoneWith(i,a),f}}(this),i=new b(new n.Desc(this,"scan",[t,r]),o)},n.Observable.prototype.diff=function(t,r){return r=rt(r),at(new n.Desc(this,"diff",[t,r]),this.scan([t],function(t,n){return[n,r(t[0],n)]}).filter(function(t){return 2===t.length}).map(function(t){return t[1]}))},n.Observable.prototype.doAction=function(){var t;return t=$(arguments),at(new n.Desc(this,"doAction",[t]),this.withHandler(function(n){return n.hasValue()&&t(n.value()),this.push(n)}))},n.Observable.prototype.doEnd=function(){var t;return t=$(arguments),at(new n.Desc(this,"doEnd",[t]),this.withHandler(function(n){return n.isEnd()&&t(),this.push(n)}))},n.Observable.prototype.doError=function(){var t;return t=$(arguments),at(new n.Desc(this,"doError",[t]),this.withHandler(function(n){return n.isError()&&t(n.error),this.push(n)}))},n.Observable.prototype.doLog=function(){var t;return t=1<=arguments.length?lt.call(arguments,0):[],at(new n.Desc(this,"doLog",t),this.withHandler(function(n){return"undefined"!=typeof console&&null!==console&&"function"==typeof console.log&&console.log.apply(console,lt.call(t).concat([n.log()])),this.push(n)}))},n.Observable.prototype.endOnError=function(){var t,r;return r=arguments[0],t=2<=arguments.length?lt.call(arguments,1):[],null==r&&(r=!0),I(this,r,t,function(t){return at(new n.Desc(this,"endOnError",[]),this.withHandler(function(n){return n.isError()&&t(n.error)?(this.push(n),this.push(P())):this.push(n)}))})},y.prototype.errors=function(){return at(new n.Desc(this,"errors",[]),this.filter(function(){return!1}))},n.Observable.prototype.mapError=function(){var t;return t=$(arguments),at(new n.Desc(this,"mapError",[t]),this.withHandler(function(n){return this.push(n.isError()?G(t(n.error)):n)}))},n.Observable.prototype.flatMapError=function(t){return at(new n.Desc(this,"flatMapError",[t]),this.mapError(function(t){return new a(t)}).flatMap(function(r){return r instanceof a?t(r.error):n.once(r)}))},n.EventStream.prototype.sampledBy=function(t,r){return at(new n.Desc(this,"sampledBy",[t,r]),this.toProperty().sampledBy(t,r))},n.Property.prototype.sampledBy=function(t,r){var e,u,i,o,s;return null!=r?r=rt(r):(e=!0,r=function(t){return t.value()}),s=new w(this,!1,e),i=new w(t,!0,e),o=n.when([s,i],r),u=t instanceof b?o.toProperty():o,at(new n.Desc(this,"sampledBy",[t,r]),u)},n.Property.prototype.sample=function(t){return at(new n.Desc(this,"sample",[t]),this.sampledBy(n.interval(t,{})))},n.Observable.prototype.map=function(){var t,r;return r=arguments[0],t=2<=arguments.length?lt.call(arguments,1):[],r instanceof b?r.sampledBy(this,F):I(this,r,t,function(t){return at(new n.Desc(this,"map",[t]),this.withHandler(function(n){return this.push(n.fmap(t))}))})},n.Observable.prototype.fold=function(t,r){return at(new n.Desc(this,"fold",[t,r]),this.scan(t,r).sampledBy(this.filter(!1).mapEnd().toProperty()))},y.prototype.reduce=y.prototype.fold,x=[["addEventListener","removeEventListener"],["addListener","removeListener"],["on","off"],["bind","unbind"]],H=function(t){var n,r,e,u,i,o,s;for(r=0,u=x.length;u>r;r++)if(s=x[r],o=[t[s[0]],t[s[1]]],o[0]&&o[1])return o;for(e=0,i=x.length;i>e;e++)if(s=x[e],n=t[s[0]])return[n,function(){}];throw new a("No suitable event methods in "+t)},n.fromEventTarget=function(t,r,e){var u,i,o;return u=H(t),i=u[0],o=u[1],at(new n.Desc(n,"fromEvent",[t,r]),n.fromBinder(function(n){return i.call(t,r,n),function(){return o.call(t,r,n)}},e))},n.fromEvent=n.fromEventTarget,n.fromPoll=function(t,r){return at(new n.Desc(n,"fromPoll",[t,r]),n.fromBinder(function(r){var e;return e=n.scheduler.setInterval(r,t),function(){return n.scheduler.clearInterval(e)}},r))},ct=function(t){return[t,P()]},n.fromPromise=function(t,r,e){return null==e&&(e=ct),at(new n.Desc(n,"fromPromise",[t]),n.fromBinder(function(n){var e;return null!=(e=t.then(n,function(t){return n(new a(t))}))&&"function"==typeof e.done&&e.done(),function(){return r&&"function"==typeof t.abort?t.abort():void 0}},e))},n.spy=function(t){return nt.push(t)},nt=[],tt=function(t){var n,r,e;if(nt.length&&!tt.running)try{for(tt.running=!0,n=0,r=nt.length;r>n;n++)(e=nt[n])(t)}finally{delete tt.running}return void 0},n.Observable.prototype.take=function(t){return 0>=t?n.never():at(new n.Desc(this,"take",[t]),this.withHandler(function(r){return r.hasValue()?(t--,t>0?this.push(r):(0===t&&this.push(r),this.push(P()),n.noMore)):this.push(r)}))},n.Observable.prototype.first=function(){return at(new n.Desc(this,"first",[]),this.take(1))},n.Observable.prototype.groupBy=function(t,r){null==r&&(r=n._.id);var e={},u=this;return u.filter(function(n){return!e[t(n)]}).map(function(i){var o=t(i),s=u.filter(function(n){return t(n)===o}),c=n.once(i).concat(s),a=r(c,i).withHandler(function(t){return this.push(t),t.isEnd()?delete e[o]:void 0});return e[o]=a,a})},n.fromArray=function(t){if(t.length){var r=0;return new h(new n.Desc(n,"fromArray",[t]),function(e){var u=!1,i=n.more,o=!1,s=!1,c=function(){if(s=!0,!o){for(o=!0;s;)if(s=!1,i!==n.noMore&&!u){var a=t[r++];i=e(et(a)),i!==n.noMore&&(r===t.length?e(P()):E.afterTransaction(c))}return o=!1}};return c(),function(){return u=!0}})}return at(new n.Desc(n,"fromArray",t),n.never())},n.EventStream.prototype.holdWhen=function(t){var r=!1,e=[],i=this;return new h(new n.Desc(this,"holdWhen",[t]),function(n){var o=new u,s=!1,c=function(t){return"function"==typeof t&&t(),o.empty()&&s?n(P()):void 0};return o.add(function(u,i){return t.subscribeInternal(function(t){if(!t.hasValue())return t.isEnd()?c(i):n(t);if(r=t.value(),!r){var u=e;return e=[],function(){for(var t,r=[],e=0;e<u.length;e++)t=u[e],r.push(n(G(t)));return r}()}})}),o.add(function(t,u){return i.subscribeInternal(function(t){return r&&t.hasValue()?e.push(t.value()):t.isEnd()&&e.length?c(u):n(t)})}),s=!0,c(),o.unsubscribe})},n.interval=function(t,r){return("undefined"==typeof r||null===r)&&(r={}),at(new n.Desc(n,"interval",[t,r]),n.fromPoll(t,function(){return G(r)}))},n.$={},n.$.asEventStream=function(t,r,e){var u=this;return D.isFunction(r)&&(e=r,r=void 0),at(new n.Desc(this.selector||this,"asEventStream",[t]),n.fromBinder(function(n){return u.on(t,r,n),function(){return u.off(t,r,n)}}),e)},"undefined"!=typeof jQuery&&jQuery&&(jQuery.fn.asEventStream=n.$.asEventStream),"undefined"!=typeof Zepto&&Zepto&&(Zepto.fn.asEventStream=n.$.asEventStream),n.Observable.prototype.last=function(){var t;return at(new n.Desc(this,"last",[]),this.withHandler(function(r){return r.isEnd()?(t&&this.push(t),this.push(P()),n.noMore):void(t=r)}))},n.Observable.prototype.log=function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return this.subscribe(function(t){"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,n.concat([t.log()]))}),this},n.EventStream.prototype.merge=function(t){var r=this;return at(new n.Desc(r,"merge",[t]),n.mergeAll(this,t))},n.mergeAll=function(){var t=A(arguments);return t.length?new h(new n.Desc(n,"mergeAll",t),function(r){var e=0,u=function(u){return function(i){return u.dispatcher.subscribe(function(u){if(u.isEnd())return e++,e===t.length?r(P()):n.more;var o=r(u);return o===n.noMore&&i(),o})}},i=D.map(u,t);return new n.CompositeUnsubscribe(i).unsubscribe}):n.never()},n.repeatedly=function(t,r){var e=0;return at(new n.Desc(n,"repeatedly",[t,r]),n.fromPoll(t,function(){return r[e++%r.length]}))},n.repeat=function(t){var r=0;return n.fromBinder(function(e){function u(t){return t.isEnd()?o?i():o=!0:s=e(t)}function i(){var i;for(o=!0;o&&s!==n.noMore;)i=t(r++),o=!1,i?c=i.subscribeInternal(u):e(P());return o=!0}var o=!1,s=n.more,c=function(){};return i(),function(){return c()}})},n.retry=function(t){if(!D.isFunction(t.source))throw new p("'source' option has to be a function");var r=t.source,e=t.retries||0,u=t.maxRetries||e,i=t.delay||function(){return 0},o=t.isRetryable||function(){return!0},s=!1,c=null;return at(new n.Desc(n,"retry",[t]),n.repeat(function(){function t(){return r().endOnError().withHandler(function(t){return t.isError()?(c=t,o(c.error)&&e>0?void 0:(s=!0,this.push(t))):(t.hasValue()&&(c=null,s=!0),this.push(t))})}if(s)return null;if(c){var a={error:c.error,retriesDone:u-e},f=n.later(i(a)).filter(!1);return e-=1,f.concat(n.once().flatMap(t))}return t()}))},n.sequentially=function(t,r){var e=0;return at(new n.Desc(n,"sequentially",[t,r]),n.fromPoll(t,function(){var t=r[e++];return e<r.length?t:e===r.length?[t,P()]:P()}))},n.Observable.prototype.skip=function(t){return at(new n.Desc(this,"skip",[t]),this.withHandler(function(r){return r.hasValue()&&t>0?(t--,n.more):this.push(r)}))},n.EventStream.prototype.skipUntil=function(t){var r=t.take(1).map(!0).toProperty(!1);return at(new n.Desc(this,"skipUntil",[t]),this.filter(r))},n.EventStream.prototype.skipWhile=function(t){for(var r=!1,e=arguments.length,u=Array(e>1?e-1:0),i=1;e>i;i++)u[i-1]=arguments[i];return I(this,t,u,function(t){return at(new n.Desc(this,"skipWhile",[t]),this.withHandler(function(e){return!r&&e.hasValue()&&t(e.value())?n.more:(e.hasValue()&&(r=!0),this.push(e))}))})},n.Observable.prototype.slidingWindow=function(t,r){return null==r&&(r=0),at(new n.Desc(this,"slidingWindow",[t,r]),this.scan([],function(n,r){return n.concat([r]).slice(-t)}).filter(function(t){return t.length>=r}))},n.Property.prototype.startWith=function(t){return at(new n.Desc(this,"startWith",[t]),this.scan(t,function(t,n){return n}))},n.EventStream.prototype.startWith=function(t){return at(new n.Desc(this,"startWith",[t]),n.once(t).concat(this))},n.Observable.prototype.takeWhile=function(t){for(var r=arguments.length,e=Array(r>1?r-1:0),u=1;r>u;u++)e[u-1]=arguments[u];return I(this,t,e,function(t){return at(new n.Desc(this,"takeWhile",[t]),this.withHandler(function(r){return r.filter(t)?this.push(r):(this.push(P()),n.noMore)}))})},n.EventStream.prototype.throttle=function(t){return at(new n.Desc(this,"throttle",[t]),this.bufferWithTime(t).map(function(t){return t[t.length-1]}))},n.Property.prototype.throttle=function(t){return this.delayChanges(new n.Desc(this,"throttle",[t]),function(n){return n.throttle(t)})},y.prototype.firstToPromise=function(t){var r=this;if("function"!=typeof t){if("function"!=typeof Promise)throw new p("There isn't default Promise, use shim or parameter");t=Promise}return new t(function(t,e){return r.subscribe(function(r){return r.hasValue()&&t(r.value()),r.isError()&&e(r.error),n.noMore})})},y.prototype.toPromise=function(t){return this.last().firstToPromise(t)},n["try"]=function(t){return function(r){try{return n.once(t(r))}catch(e){return new n.Error(e)}}},n.update=function(r){function e(n){return function(){for(var r=arguments.length,e=Array(r),u=0;r>u;u++)e[u]=arguments[u];return function(r){return n.apply(void 0,t([r].concat(e)))}}}for(var u,i=arguments.length,o=Array(i>1?i-1:0),s=1;i>s;s++)o[s-1]=arguments[s];for(var c=o.length-1;c>0;)o[c]instanceof Function||(o[c]=D.always(o[c])),o[c]=e(o[c]),c-=2;return at(new n.Desc(n,"update",[r].concat(o)),(u=n).when.apply(u,o).scan(r,function(t,n){return n(t)}))},n.zipAsArray=function(){for(var t=arguments.length,r=Array(t),e=0;t>e;e++)r[e]=arguments[e];var u=A(r);return at(new n.Desc(n,"zipAsArray",u),n.zipWith(u,function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return n}))},n.zipWith=function(){for(var t=arguments.length,r=Array(t),e=0;t>e;e++)r[e]=arguments[e];var u=O(r),i=u[0],o=u[1];return i=D.map(function(t){return t.toEventStream()},i),at(new n.Desc(n,"zipWith",[o].concat(i)),n.when(i,o))},n.Observable.prototype.zip=function(t,r){return at(new n.Desc(this,"zip",[t]),n.zipWith([this,t],r||Array))},"undefined"!=typeof define&&null!==define&&null!=define.amd?(define([],function(){return n}),"undefined"!=typeof this&&null!==this&&(this.Bacon=n)):"undefined"!=typeof module&&null!==module&&null!=module.exports?(module.exports=n,n.Bacon=n):this.Bacon=n}).call(this);
(function(){function t(t){if(Array.isArray(t)){for(var n=0,r=Array(t.length);n<t.length;n++)r[n]=t[n];return r}return Array.from(t)}function n(t,n){var r=arguments.length<=2||void 0===arguments[2]?!1:arguments[2];this.obs=t,this.sync=n,this.lazy=r,this.queue=[]}function r(){n.apply(this,arguments)}function e(t){n.call(this,t,!0)}function i(t,n,r){this.context=t,this.method=n,this.args=r}function u(t){this.value=t}function o(){this.id=++Z}function s(t,n){return this instanceof s?(o.call(this),void(!n&&P.isFunction(t)||(null!=t?t._isNext:void 0)?(this.valueF=t,this.valueInternal=void 0):(this.valueF=void 0,this.valueInternal=t))):new s(t,n)}function a(t,n){return this instanceof a?void s.call(this,t,n):new a(t,n)}function c(){return this instanceof c?void o.call(this):new c}function f(t){return this instanceof f?(this.error=t,void o.call(this)):new f(t)}function h(t){this.desc=t,this.id=++Y,this.initialDesc=this.desc}function l(){var t=arguments.length<=0||void 0===arguments[0]?[]:arguments[0];this.unsubscribe=this.unsubscribe.bind(this),this.unsubscribed=!1,this.subscriptions=[],this.starting=[];for(var n,r=0;r<t.length;r++)n=t[r],this.add(n)}function p(t,n){this._subscribe=t,this._handleEvent=n,this.subscribe=P.bind(this.subscribe,this),this.handleEvent=P.bind(this.handleEvent,this),this.pushing=!1,this.ended=!1,this.prevError=void 0,this.unsubSrc=void 0,this.subscriptions=[],this.queue=[]}function v(t,n,r){return this instanceof v?(P.isFunction(t)&&(r=n,n=t,t=i.empty),h.call(this,t),this.dispatcher=new p(n,r),void tt(this)):new v(t,n,r)}function d(t,n,r){p.call(this,n,r),this.property=t,this.subscribe=P.bind(this.subscribe,this),this.current=$,this.currentValueRootId=void 0,this.propertyEnded=!1}function y(t,n,r){h.call(this,t),this.dispatcher=new d(this,n,r),tt(this)}function m(){return this instanceof m?(this.unsubAll=P.bind(this.unsubAll,this),this.subscribeAll=P.bind(this.subscribeAll,this),this.guardedSink=P.bind(this.guardedSink,this),this.sink=void 0,this.subscriptions=[],this.ended=!1,void v.call(this,new w.Desc(w,"Bus",[]),this.subscribeAll)):new m}function b(t){return[t,J()]}var g=Array.prototype.slice,w={toString:function(){return"Bacon"}};w.version="0.7.78";var E=("undefined"!=typeof global&&null!==global?global:this).Error,D=function(){},S=function(t,n){return t},A=function(t){return t.slice(0)},O=function(t){return t instanceof Array},M=function(t){return t&&t._isObservable},k=function(t){for(var n=arguments.length,r=1;n>1?n>r:r>n;n>1?r++:r--)for(var e in arguments[r])t[e]=arguments[r][e];return t},I=function(t,n){var r={}.hasOwnProperty,e=function(){};e.prototype=n.prototype,t.prototype=new e;for(var i in n)r.call(n,i)&&(t[i]=n[i]);return t},P={indexOf:function(){return Array.prototype.indexOf?function(t,n){return t.indexOf(n)}:function(t,n){for(var r,e=0;e<t.length;e++)if(r=t[e],n===r)return e;return-1}}(),indexWhere:function(t,n){for(var r,e=0;e<t.length;e++)if(r=t[e],n(r))return e;return-1},head:function(t){return t[0]},always:function(t){return function(){return t}},negate:function(t){return function(n){return!t(n)}},empty:function(t){return 0===t.length},tail:function(t){return t.slice(1,t.length)},filter:function(t,n){for(var r,e=[],i=0;i<n.length;i++)r=n[i],t(r)&&e.push(r);return e},map:function(t,n){return function(){for(var r,e=[],i=0;i<n.length;i++)r=n[i],e.push(t(r));return e}()},each:function(t,n){for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){var e=t[r];n(r,e)}return void 0},toArray:function(t){return O(t)?t:[t]},contains:function(t,n){return-1!==P.indexOf(t,n)},id:function(t){return t},last:function(t){return t[t.length-1]},all:function(t){for(var n,r=arguments.length<=1||void 0===arguments[1]?P.id:arguments[1],e=0;e<t.length;e++)if(n=t[e],!r(n))return!1;return!0},any:function(t){for(var n,r=arguments.length<=1||void 0===arguments[1]?P.id:arguments[1],e=0;e<t.length;e++)if(n=t[e],r(n))return!0;return!1},without:function(t,n){return P.filter(function(n){return n!==t},n)},remove:function(t,n){var r=P.indexOf(n,t);return r>=0?n.splice(r,1):void 0},fold:function(t,n,r){for(var e,i=0;i<t.length;i++)e=t[i],n=r(n,e);return n},flatMap:function(t,n){return P.fold(n,[],function(n,r){return n.concat(t(r))})},cached:function(t){var n=$;return function(){return("undefined"!=typeof n&&null!==n?n._isNone:void 0)&&(n=t(),t=void 0),n}},bind:function(t,n){return function(){return t.apply(n,arguments)}},isFunction:function(t){return"function"==typeof t},toString:function(t){var n,r,e,i={}.hasOwnProperty;try{return x++,null==t?"undefined":P.isFunction(t)?"function":O(t)?x>5?"[..]":"["+P.map(P.toString,t).toString()+"]":null!=(null!=t?t.toString:void 0)&&t.toString!==Object.prototype.toString?t.toString():"object"==typeof t?x>5?"{..}":(n=function(){var n=[];for(r in t)i.call(t,r)&&(e=function(){var n;try{return t[r]}catch(n){return n}}(),n.push(P.toString(r)+":"+P.toString(e)));return n}(),"{"+n+"}"):t}finally{x--}}},x=0;w._=P;var _=w.UpdateBarrier=function(){var t,n=[],r={},e=[],i=0,u=function(n){return t?e.push(n):n()},o=function(e,i){if(t){var u=r[e.id];return"undefined"==typeof u||null===u?(u=r[e.id]=[i],n.push(e)):u.push(i)}return i()},s=function(){for(;n.length>0;)a(0);return void 0},a=function(t){var e=n[t],i=e.id,u=r[i];n.splice(t,1),delete r[i],c(e);for(var o,s=0;s<u.length;s++)(o=u[s])();return void 0},c=function(t){for(var e,i=t.internalDeps(),u=0;u<i.length;u++)if(e=i[u],c(e),r[e.id]){var o=P.indexOf(n,e);a(o)}return void 0},f=function(n,r,u,o){if(t)return u.apply(r,o);t=n;try{var a=u.apply(r,o);s()}finally{for(t=void 0;i<e.length;){var c=e[i];i++,c()}i=0,e=[]}return a},h=function(){return t?t.id:void 0},l=function(t,n){var r=!1,e=!1,i=function(){return e=!0},o=function(){return r=!0,i()};return i=t.dispatcher.subscribe(function(t){return u(function(){if(!r){var e=n(t);if(e===w.noMore)return o()}})}),e&&i(),o},p=function(){return n.length>0};return{whenDoneWith:o,hasWaiters:p,inTransaction:f,currentEventId:h,wrappedSubscribe:l,afterTransaction:u}}();k(n.prototype,{_isSource:!0,subscribe:function(t){return this.obs.dispatcher.subscribe(t)},toString:function(){return this.obs.toString()},markEnded:function(){return this.ended=!0,!0},consume:function(){return this.lazy?{value:P.always(this.queue[0])}:this.queue[0]},push:function(t){return this.queue=[t],[t]},mayHave:function(){return!0},hasAtLeast:function(){return this.queue.length},flatten:!0}),I(r,n),k(r.prototype,{consume:function(){return this.queue.shift()},push:function(t){return this.queue.push(t)},mayHave:function(t){return!this.ended||this.queue.length>=t},hasAtLeast:function(t){return this.queue.length>=t},flatten:!1}),I(e,n),k(e.prototype,{consume:function(){var t=this.queue;return this.queue=[],{value:function(){return t}}},push:function(t){return this.queue.push(t.value())},hasAtLeast:function(){return!0}}),n.isTrigger=function(t){return(null!=t?t._isSource:void 0)?t.sync:null!=t?t._isEventStream:void 0},n.fromObservable=function(t){return(null!=t?t._isSource:void 0)?t:(null!=t?t._isProperty:void 0)?new n(t,!1):new r(t,!0)},k(i.prototype,{_isDesc:!0,deps:function(){return this.cached||(this.cached=V([this.context].concat(this.args))),this.cached},toString:function(){return P.toString(this.context)+"."+P.toString(this.method)+"("+P.map(P.toString,this.args)+")"}});var W=function(t,n){var r=t||n;if(r&&r._isDesc)return t||n;for(var e=arguments.length,u=Array(e>2?e-2:0),o=2;e>o;o++)u[o-2]=arguments[o];return new i(t,n,u)},T=function(t,n){return n.desc=t,n},V=function(t){return O(t)?P.flatMap(V,t):M(t)?[t]:("undefined"!=typeof t&&null!==t?t._isSource:void 0)?[t.obs]:[]};w.Desc=i,w.Desc.empty=new w.Desc("","",[]);var H=function(n){return function(r){for(var e=arguments.length,i=Array(e>1?e-1:0),u=1;e>u;u++)i[u-1]=arguments[u];if("object"==typeof r&&i.length){var o=r,s=i[0];r=function(){return o[s].apply(o,arguments)},i=i.slice(1)}return n.apply(void 0,[r].concat(t(i)))}},B=function(n){return n=Array.prototype.slice.call(n),L.apply(void 0,t(n))},F=function(n,r){return function(){for(var e=arguments.length,i=Array(e),u=0;e>u;u++)i[u]=arguments[u];return n.apply(void 0,t(r.concat(i)))}},C=function(t){return function(n){return function(r){if("undefined"==typeof r||null===r)return void 0;var e=r[n];return P.isFunction(e)?e.apply(r,t):e}}},q=function(t,n){var r=t.slice(1).split("."),e=P.map(C(n),r);return function(t){for(var n,r=0;r<e.length;r++)n=e[r],t=n(t);return t}},N=function(t){return"string"==typeof t&&t.length>1&&"."===t.charAt(0)},L=H(function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;n>e;e++)r[e-1]=arguments[e];return P.isFunction(t)?r.length?F(t,r):t:N(t)?q(t,r):P.always(t)}),U=function(n,r){return L.apply(void 0,[n].concat(t(r)))},z=function(t,n,r,e){if("undefined"!=typeof n&&null!==n?n._isProperty:void 0){var i=n.sampledBy(t,function(t,n){return[t,n]});return e.call(i,function(t){{var n=t[0];t[1]}return n}).map(function(t){var n=(t[0],t[1]);return n})}return n=U(n,r),e.call(t,n)},j=function(t){if(P.isFunction(t))return t;if(N(t)){var n=R(t);return function(t,r){return t[n](r)}}throw new E("not a function or a field key: "+t)},R=function(t){return t.slice(1)};k(u.prototype,{_isSome:!0,getOrElse:function(){return this.value},get:function(){return this.value},filter:function(t){return t(this.value)?new u(this.value):$},map:function(t){return new u(t(this.value))},forEach:function(t){return t(this.value)},isDefined:!0,toArray:function(){return[this.value]},inspect:function(){return"Some("+this.value+")"},toString:function(){return this.inspect()}});var $={_isNone:!0,getOrElse:function(t){return t},filter:function(){return $},map:function(){return $},forEach:function(){},isDefined:!1,toArray:function(){return[]},inspect:function(){return"None"},toString:function(){return this.inspect()}},Q=function(t){return("undefined"!=typeof t&&null!==t?t._isSome:void 0)||("undefined"!=typeof t&&null!==t?t._isNone:void 0)?t:new u(t)};w.noMore="<no-more>",w.more="<more>";var Z=0;o.prototype._isEvent=!0,o.prototype.isEvent=function(){return!0},o.prototype.isEnd=function(){return!1},o.prototype.isInitial=function(){return!1},o.prototype.isNext=function(){return!1},o.prototype.isError=function(){return!1},o.prototype.hasValue=function(){return!1},o.prototype.filter=function(){return!0},o.prototype.inspect=function(){return this.toString()},o.prototype.log=function(){return this.toString()},I(s,o),s.prototype.isNext=function(){return!0},s.prototype.hasValue=function(){return!0},s.prototype.value=function(){var t;return(null!=(t=this.valueF)?t._isNext:void 0)?(this.valueInternal=this.valueF.value(),this.valueF=void 0):this.valueF&&(this.valueInternal=this.valueF(),this.valueF=void 0),this.valueInternal},s.prototype.fmap=function(t){var n,r;return this.valueInternal?(r=this.valueInternal,this.apply(function(){return t(r)})):(n=this,this.apply(function(){return t(n.value())}))},s.prototype.apply=function(t){return new s(t)},s.prototype.filter=function(t){return t(this.value())},s.prototype.toString=function(){return P.toString(this.value())},s.prototype.log=function(){return this.value()},s.prototype._isNext=!0,I(a,s),a.prototype._isInitial=!0,a.prototype.isInitial=function(){return!0},a.prototype.isNext=function(){return!1},a.prototype.apply=function(t){return new a(t)},a.prototype.toNext=function(){return new s(this)},I(c,o),c.prototype.isEnd=function(){return!0},c.prototype.fmap=function(){return this},c.prototype.apply=function(){return this},c.prototype.toString=function(){return"<end>"},I(f,o),f.prototype.isError=function(){return!0},f.prototype.fmap=function(){return this},f.prototype.apply=function(){return this},f.prototype.toString=function(){return"<error> "+P.toString(this.error)},w.Event=o,w.Initial=a,w.Next=s,w.End=c,w.Error=f;var X=function(t){return new a(t,!0)},G=function(t){return new s(t,!0)},J=function(){return new c},K=function(t){return t&&t._isEvent?t:G(t)},Y=0,tt=function(){};k(h.prototype,{_isObservable:!0,subscribe:function(t){return _.wrappedSubscribe(this,t)},subscribeInternal:function(t){return this.dispatcher.subscribe(t)},onValue:function(){var t=B(arguments);return this.subscribe(function(n){return n.hasValue()?t(n.value()):void 0})},onValues:function(n){return this.onValue(function(r){return n.apply(void 0,t(r))})},onError:function(){var t=B(arguments);return this.subscribe(function(n){return n.isError()?t(n.error):void 0})},onEnd:function(){var t=B(arguments);return this.subscribe(function(n){return n.isEnd()?t():void 0})},name:function(t){return this._name=t,this},withDescription:function(){return this.desc=W.apply(void 0,arguments),this},toString:function(){return this._name?this._name:this.desc.toString()},internalDeps:function(){return this.initialDesc.deps()}}),h.prototype.assign=h.prototype.onValue,h.prototype.forEach=h.prototype.onValue,h.prototype.inspect=h.prototype.toString,w.Observable=h,k(l.prototype,{add:function(t){var n=this;if(!this.unsubscribed){var r=!1,e=D;this.starting.push(t);var i=function(){return n.unsubscribed?void 0:(r=!0,n.remove(e),P.remove(t,n.starting))};return e=t(this.unsubscribe,i),this.unsubscribed||r?e():this.subscriptions.push(e),P.remove(t,this.starting),e}},remove:function(t){return this.unsubscribed?void 0:void 0!==P.remove(t,this.subscriptions)?t():void 0},unsubscribe:function(){if(!this.unsubscribed){this.unsubscribed=!0;for(var t=this.subscriptions,n=0;n<t.length;n++)t[n]();return this.subscriptions=[],this.starting=[],[]}},count:function(){return this.unsubscribed?0:this.subscriptions.length+this.starting.length},empty:function(){return 0===this.count()}}),w.CompositeUnsubscribe=l,p.prototype.hasSubscribers=function(){return this.subscriptions.length>0},p.prototype.removeSub=function(t){return this.subscriptions=P.without(t,this.subscriptions),this.subscriptions},p.prototype.push=function(t){return t.isEnd()&&(this.ended=!0),_.inTransaction(t,this,this.pushIt,[t])},p.prototype.pushToSubscriptions=function(t){try{for(var n=this.subscriptions,r=n.length,e=0;r>e;e++){var i=n[e],u=i.sink(t);(u===w.noMore||t.isEnd())&&this.removeSub(i)}return!0}catch(o){throw this.pushing=!1,this.queue=[],o}},p.prototype.pushIt=function(t){if(this.pushing)return this.queue.push(t),w.more;if(t!==this.prevError){for(t.isError()&&(this.prevError=t),this.pushing=!0,this.pushToSubscriptions(t),this.pushing=!1;this.queue.length;)t=this.queue.shift(),this.push(t);return this.hasSubscribers()?w.more:(this.unsubscribeFromSource(),w.noMore)}},p.prototype.handleEvent=function(t){return this._handleEvent?this._handleEvent(t):this.push(t)},p.prototype.unsubscribeFromSource=function(){this.unsubSrc&&this.unsubSrc(),this.unsubSrc=void 0},p.prototype.subscribe=function(t){var n;return this.ended?(t(J()),D):(n={sink:t},this.subscriptions.push(n),1===this.subscriptions.length&&(this.unsubSrc=this._subscribe(this.handleEvent)),function(t){return function(){return t.removeSub(n),t.hasSubscribers()?void 0:t.unsubscribeFromSource()}}(this))},w.Dispatcher=p,I(v,h),k(v.prototype,{_isEventStream:!0,toProperty:function(t){var n=0===arguments.length?$:Q(function(){return t}),r=this.dispatcher,e=new w.Desc(this,"toProperty",[t]);return new y(e,function(t){var e=!1,i=!1,o=D,s=w.more,c=function(){return e?void 0:n.forEach(function(n){return e=!0,s=t(new a(n)),s===w.noMore?(o(),o=D,D):void 0})};return o=r.subscribe(function(r){return r.hasValue()?r.isInitial()&&!i?(n=new u(function(){return r.value()}),w.more):(r.isInitial()||c(),e=!0,n=new u(r),t(r)):(r.isEnd()&&(s=c()),s!==w.noMore?t(r):void 0)}),i=!0,c(),o})},toEventStream:function(){return this},withHandler:function(t){return new v(new w.Desc(this,"withHandler",[t]),this.dispatcher.subscribe,t)}}),w.EventStream=v,w.never=function(){return new v(W(w,"never"),function(t){return t(J()),D})},w.when=function(){if(0===arguments.length)return w.never();for(var r=arguments.length,e=[],i=[],u=0,o=[];r>u;){o[u]=arguments[u],o[u+1]=arguments[u+1];for(var s,a=P.toArray(arguments[u]),c=rt(arguments[u+1]),f={f:c,ixs:[]},h=!1,l=0;l<a.length;l++){s=a[l];var p=P.indexOf(e,s);h||(h=n.isTrigger(s)),0>p&&(e.push(s),p=e.length-1);for(var d,y=0;y<f.ixs.length;y++)d=f.ixs[y],d.index===p&&d.count++;f.ixs.push({index:p,count:1})}a.length>0&&i.push(f),u+=2}if(!e.length)return w.never();e=P.map(n.fromObservable,e);var m=P.any(e,function(t){return t.flatten})&&nt(P.map(function(t){return t.obs},e)),b=new w.Desc(w,"when",o),g=new v(b,function(n){var r=[],u=!1,o=function(t){for(var n,r=0;r<t.ixs.length;r++)if(n=t.ixs[r],!e[n.index].hasAtLeast(n.count))return!1;return!0},s=function(t){return!t.sync||t.ended},a=function(t){for(var n,r=0;r<t.ixs.length;r++)if(n=t.ixs[r],!e[n.index].mayHave(n.count))return!0},c=function(t){return!t.source.flatten},f=function(f){return function(h){var l=function(){return _.whenDoneWith(g,v)},p=function(){if(!(r.length>0))return w.more;for(var u,s=w.more,a=r.pop(),f=0;f<i.length;f++)if(u=i[f],o(u)){var h=function(){for(var t,n=[],r=0;r<u.ixs.length;r++)t=u.ixs[r],n.push(e[t.index].consume());return n}();return s=n(a.e.apply(function(){var n,r=function(){for(var t,n=[],r=0;r<h.length;r++)t=h[r],n.push(t.value());return n}();return(n=u).f.apply(n,t(r))})),r.length&&(r=P.filter(c,r)),s===w.noMore?s:p()}},v=function(){var t=p();return u&&(P.all(e,s)||P.all(i,a))&&(t=w.noMore,n(J())),t===w.noMore&&h(),t};return f.subscribe(function(t){if(t.isEnd())u=!0,f.markEnded(),l();else if(t.isError())var e=n(t);else f.push(t),f.sync&&(r.push({source:f,e:t}),m||_.hasWaiters()?l():v());return e===w.noMore&&h(),e||w.more})}};return new w.CompositeUnsubscribe(function(){for(var t,n=[],r=0;r<e.length;r++)t=e[r],n.push(f(t));return n}()).unsubscribe});return g};var nt=function(t){var n=arguments.length<=1||void 0===arguments[1]?[]:arguments[1],r=function(t){if(P.contains(n,t))return!0;var e=t.internalDeps();return e.length?(n.push(t),P.any(e,r)):(n.push(t),!1)};return P.any(t,r)},rt=function(t){return P.isFunction(t)?t:P.always(t)};w.groupSimultaneous=function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];1===n.length&&O(n[0])&&(n=n[0]);var i=function(){for(var t,r=[],i=0;i<n.length;i++)t=n[i],r.push(new e(t));return r}();return T(new w.Desc(w,"groupSimultaneous",n),w.when(i,function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return n}))},I(d,p),k(d.prototype,{push:function(t){return t.isEnd()&&(this.propertyEnded=!0),t.hasValue()&&(this.current=new u(t),this.currentValueRootId=_.currentEventId()),p.prototype.push.call(this,t)},maybeSubSource:function(t,n){return n===w.noMore?D:this.propertyEnded?(t(J()),D):p.prototype.subscribe.call(this,t)},subscribe:function(t){var n=this,r=w.more;if(this.current.isDefined&&(this.hasSubscribers()||this.propertyEnded)){var e=_.currentEventId(),i=this.currentValueRootId;return!this.propertyEnded&&i&&e&&e!==i?(_.whenDoneWith(this.property,function(){return n.currentValueRootId===i?t(X(n.current.get().value())):void 0}),this.maybeSubSource(t,r)):(_.inTransaction(void 0,this,function(){return r=t(X(this.current.get().value()))},[]),this.maybeSubSource(t,r))}return this.maybeSubSource(t,r)}}),I(y,h),k(y.prototype,{_isProperty:!0,changes:function(){var t=this;return new v(new w.Desc(this,"changes",[]),function(n){return t.dispatcher.subscribe(function(t){return t.isInitial()?void 0:n(t)})})},withHandler:function(t){return new y(new w.Desc(this,"withHandler",[t]),this.dispatcher.subscribe,t)},toProperty:function(){return this},toEventStream:function(){var t=this;return new v(new w.Desc(this,"toEventStream",[]),function(n){return t.dispatcher.subscribe(function(t){return t.isInitial()&&(t=t.toNext()),n(t)})})}}),w.Property=y,w.constant=function(t){return new y(new w.Desc(w,"constant",[t]),function(n){return n(X(t)),n(J()),D})},w.fromBinder=function(t){var n=arguments.length<=1||void 0===arguments[1]?P.id:arguments[1],r=new w.Desc(w,"fromBinder",[t,n]);return new v(r,function(r){var e=!1,i=!1,u=function(){return e?void 0:"undefined"!=typeof o&&null!==o?(o(),e=!0):i=!0},o=t(function(){for(var t,e=arguments.length,i=Array(e),o=0;e>o;o++)i[o]=arguments[o];var s=n.apply(this,i);O(s)&&(null!=(t=P.last(s))?t._isEvent:void 0)||(s=[s]);for(var a,c=w.more,f=0;f<s.length;f++)if(a=s[f],c=r(a=K(a)),c===w.noMore||a.isEnd())return u(),c;return c});return i&&u(),u})},w.Observable.prototype.map=function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;n>e;e++)r[e-1]=arguments[e];return z(this,t,r,function(t){return T(new w.Desc(this,"map",[t]),this.withHandler(function(n){return this.push(n.fmap(t))}))})};var et=function(t){return O(t[0])?t[0]:Array.prototype.slice.call(t)},it=function(t){return P.isFunction(t[0])?[et(Array.prototype.slice.call(t,1)),t[0]]:[et(Array.prototype.slice.call(t,0,t.length-1)),P.last(t)]};w.combineAsArray=function(){for(var t,r=et(arguments),e=0;e<r.length;e++)t=r[e],M(t)||(r[e]=w.constant(t));if(r.length){var i=function(){for(var t,e=[],i=0;i<r.length;i++)t=r[i],e.push(new n(t,!0));return e}();return T(new w.Desc(w,"combineAsArray",r),w.when(i,function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return n}).toProperty())}return w.constant([])},w.onValues=function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return w.combineAsArray(n.slice(0,n.length-1)).onValues(n[n.length-1])},w.combineWith=function(){var n=it(arguments),r=n[0],e=n[1],i=new w.Desc(w,"combineWith",[e].concat(t(r)));return T(i,w.combineAsArray(r).map(function(n){return e.apply(void 0,t(n))}))},w.Observable.prototype.combine=function(t,n){var r=j(n),e=new w.Desc(this,"combine",[t,n]);return T(e,w.combineAsArray(this,t).map(function(t){return r(t[0],t[1])}))},w.Observable.prototype.withStateMachine=function(t,n){var r=t,e=new w.Desc(this,"withStateMachine",[t,n]);return T(e,this.withHandler(function(t){var e=n(r,t),i=e[0],u=e[1];r=i;for(var o,s=w.more,a=0;a<u.length;a++)if(o=u[a],s=this.push(o),s===w.noMore)return s;return s}))};var ut=function(t,n){return t===n},ot=function(t){return"undefined"!=typeof t&&null!==t?t._isNone:!1};w.Observable.prototype.skipDuplicates=function(){var t=arguments.length<=0||void 0===arguments[0]?ut:arguments[0],n=new w.Desc(this,"skipDuplicates",[]);return T(n,this.withStateMachine($,function(n,r){return r.hasValue()?r.isInitial()||ot(n)||!t(n.get(),r.value())?[new u(r.value()),[r]]:[n,[]]:[n,[r]]}))},w.Observable.prototype.awaiting=function(t){var n=new w.Desc(this,"awaiting",[t]);return T(n,w.groupSimultaneous(this,t).map(function(t){return 0===t[1].length}).toProperty(!1).skipDuplicates())},w.Observable.prototype.not=function(){return T(new w.Desc(this,"not",[]),this.map(function(t){return!t}))},w.Property.prototype.and=function(t){return T(new w.Desc(this,"and",[t]),this.combine(t,function(t,n){return t&&n}))},w.Property.prototype.or=function(t){return T(new w.Desc(this,"or",[t]),this.combine(t,function(t,n){return t||n}))},w.scheduler={setTimeout:function(t,n){return setTimeout(t,n)},setInterval:function(t,n){return setInterval(t,n)},clearInterval:function(t){return clearInterval(t)},clearTimeout:function(t){return clearTimeout(t)},now:function(){return(new Date).getTime()}},w.EventStream.prototype.bufferWithTime=function(t){return T(new w.Desc(this,"bufferWithTime",[t]),this.bufferWithTimeOrCount(t,Number.MAX_VALUE))},w.EventStream.prototype.bufferWithCount=function(t){return T(new w.Desc(this,"bufferWithCount",[t]),this.bufferWithTimeOrCount(void 0,t))},w.EventStream.prototype.bufferWithTimeOrCount=function(t,n){var r=function(r){return r.values.length===n?r.flush():void 0!==t?r.schedule():void 0},e=new w.Desc(this,"bufferWithTimeOrCount",[t,n]);return T(e,this.buffer(t,r,r))},w.EventStream.prototype.buffer=function(t){var n=arguments.length<=1||void 0===arguments[1]?D:arguments[1],r=arguments.length<=2||void 0===arguments[2]?D:arguments[2],e={scheduled:null,end:void 0,values:[],flush:function(){if(this.scheduled&&(w.scheduler.clearTimeout(this.scheduled),this.scheduled=null),this.values.length>0){var t=this.values;this.values=[];var n=this.push(G(t));if(null!=this.end)return this.push(this.end);if(n!==w.noMore)return r(this)}else if(null!=this.end)return this.push(this.end)},schedule:function(){var n=this;return this.scheduled?void 0:this.scheduled=t(function(){return n.flush()})}},i=w.more;if(!P.isFunction(t)){var u=t;t=function(t){return w.scheduler.setTimeout(t,u)}}return T(new w.Desc(this,"buffer",[]),this.withHandler(function(t){var r=this;return e.push=function(t){return r.push(t)},t.isError()?i=this.push(t):t.isEnd()?(e.end=t,e.scheduled||e.flush()):(e.values.push(t.value()),n(e)),i}))},w.Observable.prototype.filter=function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;n>e;e++)r[e-1]=arguments[e];return z(this,t,r,function(t){return T(new w.Desc(this,"filter",[t]),this.withHandler(function(n){return n.filter(t)?this.push(n):w.more}))})},w.once=function(t){return new v(new i(w,"once",[t]),function(n){return n(K(t)),n(J()),D})},w.EventStream.prototype.concat=function(t){var n=this;return new v(new w.Desc(n,"concat",[t]),function(r){var e=D,i=n.dispatcher.subscribe(function(n){return n.isEnd()?e=t.dispatcher.subscribe(r):r(n)});return function(){return i(),e()}})},w.Observable.prototype.flatMap=function(){return ct(this,st(arguments))},w.Observable.prototype.flatMapFirst=function(){return ct(this,st(arguments),!0)};var st=function(t){return 1===t.length&&M(t[0])?P.always(t[0]):B(t)},at=function(t){return M(t)?t:w.once(t)},ct=function(t,n,r,e){var i=[t],u=[],o=new w.Desc(t,"flatMap"+(r?"First":""),[n]),s=new v(o,function(i){var o=new l,s=[],a=function(t){var r=at(n(t.value()));return u.push(r),o.add(function(t,n){return r.dispatcher.subscribe(function(e){if(e.isEnd())return P.remove(r,u),c(),f(n),w.noMore;("undefined"!=typeof e&&null!==e?e._isInitial:void 0)&&(e=e.toNext());var o=i(e);return o===w.noMore&&t(),o})})},c=function(){var t=s.shift();return t?a(t):void 0},f=function(t){return t(),o.empty()?i(J()):void 0};return o.add(function(n,u){return t.dispatcher.subscribe(function(t){return t.isEnd()?f(u):t.isError()?i(t):r&&o.count()>1?w.more:o.unsubscribed?w.noMore:e&&o.count()>e?s.push(t):a(t)})}),o.unsubscribe});return s.internalDeps=function(){return u.length?i.concat(u):i},s};w.Observable.prototype.flatMapWithConcurrencyLimit=function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;n>e;e++)r[e-1]=arguments[e];var i=new w.Desc(this,"flatMapWithConcurrencyLimit",[t].concat(r));return T(i,ct(this,st(r),!1,t))},w.Observable.prototype.flatMapConcat=function(){var t=new w.Desc(this,"flatMapConcat",Array.prototype.slice.call(arguments,0));return T(t,this.flatMapWithConcurrencyLimit.apply(this,[1].concat(g.call(arguments))))},w.later=function(t,n){return T(new w.Desc(w,"later",[t,n]),w.fromBinder(function(r){var e=function(){return r([n,J()])},i=w.scheduler.setTimeout(e,t);return function(){return w.scheduler.clearTimeout(i)}}))},w.Observable.prototype.bufferingThrottle=function(t){var n=new w.Desc(this,"bufferingThrottle",[t]);return T(n,this.flatMapConcat(function(n){return w.once(n).concat(w.later(t).filter(!1))}))},w.Property.prototype.bufferingThrottle=function(){return w.Observable.prototype.bufferingThrottle.apply(this,arguments).toProperty()},I(m,v),k(m.prototype,{unsubAll:function(){for(var t,n=this.subscriptions,r=0;r<n.length;r++)t=n[r],"function"==typeof t.unsub&&t.unsub();return void 0},subscribeAll:function(t){if(this.ended)t(J());else{this.sink=t;for(var n,r=A(this.subscriptions),e=0;e<r.length;e++)n=r[e],this.subscribeInput(n)}return this.unsubAll},guardedSink:function(t){var n=this;return function(r){return r.isEnd()?(n.unsubscribeInput(t),w.noMore):n.sink(r)}},subscribeInput:function(t){return t.unsub=t.input.dispatcher.subscribe(this.guardedSink(t.input)),t.unsub},unsubscribeInput:function(t){for(var n,r=this.subscriptions,e=0;e<r.length;e++)if(n=r[e],n.input===t)return"function"==typeof n.unsub&&n.unsub(),void this.subscriptions.splice(e,1)},plug:function(t){var n=this;if(!this.ended){var r={input:t};return this.subscriptions.push(r),"undefined"!=typeof this.sink&&this.subscribeInput(r),function(){return n.unsubscribeInput(t)}}},end:function(){return this.ended=!0,this.unsubAll(),"function"==typeof this.sink?this.sink(J()):void 0},push:function(t){return this.ended||"function"!=typeof this.sink?void 0:this.sink(G(t))},error:function(t){return"function"==typeof this.sink?this.sink(new f(t)):void 0}}),w.Bus=m;var ft=function(n,r){return H(function(e){for(var i=F(r,[function(n,r){return e.apply(void 0,t(n).concat([r]))}]),u=arguments.length,o=Array(u>1?u-1:0),s=1;u>s;s++)o[s-1]=arguments[s];return T(new w.Desc(w,n,[e].concat(o)),w.combineAsArray(o).flatMap(i))})};w.fromCallback=ft("fromCallback",function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;n>e;e++)r[e-1]=arguments[e];return w.fromBinder(function(n){return U(t,r)(n),D},function(t){return[t,J()]})}),w.fromNodeCallback=ft("fromNodeCallback",function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;n>e;e++)r[e-1]=arguments[e];return w.fromBinder(function(n){return U(t,r)(n),D},function(t,n){return t?[new f(t),J()]:[n,J()]})}),w.combineTemplate=function(t){function n(t){return t[t.length-1]}function r(t,r,e){return n(t)[r]=e,e}function e(t,n){return function(e,i){return r(e,t,i[n])}}function i(t,n){return function(e){return r(e,t,n)}}function u(t){return O(t)?[]:{}}function o(t,n){return function(e){var i=u(n);return r(e,t,i),e.push(i)}}function s(t,n){if(M(n))return h.push(n),f.push(e(t,h.length-1));if(n!==Object(n)||"function"==typeof n||n instanceof RegExp||n instanceof Date)return f.push(i(t,n));var r=function(t){return t.pop()};return f.push(o(t,n)),c(n),f.push(r)}function a(n){for(var r,e=u(t),i=[e],o=0;o<f.length;o++)(r=f[o])(i,n);return e}function c(t){return P.each(t,s)}var f=[],h=[];return c(t),T(new w.Desc(w,"combineTemplate",[t]),w.combineAsArray(h).map(a))};var ht=function(t,n){var r=new v(W(t,"justInitValue"),function(n){var e=void 0,i=t.dispatcher.subscribe(function(t){return t.isEnd()||(e=t),w.noMore});return _.whenDoneWith(r,function(){return"undefined"!=typeof e&&null!==e&&n(e),n(J())}),i});return r.concat(n).toProperty()};w.Observable.prototype.mapEnd=function(){var t=B(arguments);return T(new w.Desc(this,"mapEnd",[t]),this.withHandler(function(n){return n.isEnd()?(this.push(G(t(n))),this.push(J()),w.noMore):this.push(n)}))},w.Observable.prototype.skipErrors=function(){return T(new w.Desc(this,"skipErrors",[]),this.withHandler(function(t){return t.isError()?w.more:this.push(t)}))},w.EventStream.prototype.takeUntil=function(t){var n={};return T(new w.Desc(this,"takeUntil",[t]),w.groupSimultaneous(this.mapEnd(n),t.skipErrors()).withHandler(function(t){if(t.hasValue()){var r=t.value(),e=r[0],i=r[1];if(i.length)return this.push(J());for(var u,o=w.more,s=0;s<e.length;s++)u=e[s],o=this.push(u===n?J():G(u));return o}return this.push(t)}))},w.Property.prototype.takeUntil=function(t){var n=this.changes().takeUntil(t);return T(new w.Desc(this,"takeUntil",[t]),ht(this,n))},w.Observable.prototype.flatMapLatest=function(){var t=st(arguments),n=this.toEventStream();return T(new w.Desc(this,"flatMapLatest",[t]),n.flatMap(function(r){return at(t(r)).takeUntil(n)}))},w.Property.prototype.delayChanges=function(t,n){return T(t,ht(this,n(this.changes())))},w.EventStream.prototype.delay=function(t){return T(new w.Desc(this,"delay",[t]),this.flatMap(function(n){return w.later(t,n)}))},w.Property.prototype.delay=function(t){return this.delayChanges(new w.Desc(this,"delay",[t]),function(n){return n.delay(t)})},w.EventStream.prototype.debounce=function(t){return T(new w.Desc(this,"debounce",[t]),this.flatMapLatest(function(n){return w.later(t,n)}))},w.Property.prototype.debounce=function(t){return this.delayChanges(new w.Desc(this,"debounce",[t]),function(n){return n.debounce(t)})},w.EventStream.prototype.debounceImmediate=function(t){return T(new w.Desc(this,"debounceImmediate",[t]),this.flatMapFirst(function(n){return w.once(n).concat(w.later(t).filter(!1))}))},w.Observable.prototype.decode=function(t){return T(new w.Desc(this,"decode",[t]),this.combine(w.combineTemplate(t),function(t,n){
return n[t]}))},w.Observable.prototype.scan=function(t,n){var r,e=this;n=j(n);var i=Q(t),o=!1,s=function(t){var s=!1,c=D,f=w.more,h=function(){return s?void 0:i.forEach(function(n){return s=o=!0,f=t(new a(function(){return n})),f===w.noMore?(c(),c=D):void 0})};return c=e.dispatcher.subscribe(function(r){if(r.hasValue()){if(o&&r.isInitial())return w.more;r.isInitial()||h(),s=o=!0;var e=i.getOrElse(void 0),a=n(e,r.value());return i=new u(a),t(r.apply(function(){return a}))}return r.isEnd()&&(f=h()),f!==w.noMore?t(r):void 0}),_.whenDoneWith(r,h),c};return r=new y(new w.Desc(this,"scan",[t,n]),s)},w.Observable.prototype.diff=function(t,n){return n=j(n),T(new w.Desc(this,"diff",[t,n]),this.scan([t],function(t,r){return[r,n(t[0],r)]}).filter(function(t){return 2===t.length}).map(function(t){return t[1]}))},w.Observable.prototype.doAction=function(){var t=B(arguments);return T(new w.Desc(this,"doAction",[t]),this.withHandler(function(n){return n.hasValue()&&t(n.value()),this.push(n)}))},w.Observable.prototype.doEnd=function(){var t=B(arguments);return T(new w.Desc(this,"doEnd",[t]),this.withHandler(function(n){return n.isEnd()&&t(),this.push(n)}))},w.Observable.prototype.doError=function(){var t=B(arguments);return T(new w.Desc(this,"doError",[t]),this.withHandler(function(n){return n.isError()&&t(n.error),this.push(n)}))},w.Observable.prototype.doLog=function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return T(new w.Desc(this,"doLog",n),this.withHandler(function(t){return"undefined"!=typeof console&&null!==console&&"function"==typeof console.log&&console.log.apply(console,n.concat([t.log()])),this.push(t)}))},w.Observable.prototype.endOnError=function(t){("undefined"==typeof t||null===t)&&(t=!0);for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;n>e;e++)r[e-1]=arguments[e];return z(this,t,r,function(t){return T(new w.Desc(this,"endOnError",[]),this.withHandler(function(n){return n.isError()&&t(n.error)?(this.push(n),this.push(J())):this.push(n)}))})},h.prototype.errors=function(){return T(new w.Desc(this,"errors",[]),this.filter(function(){return!1}))},w.Observable.prototype.take=function(t){return 0>=t?w.never():T(new w.Desc(this,"take",[t]),this.withHandler(function(n){return n.hasValue()?(t--,t>0?this.push(n):(0===t&&this.push(n),this.push(J()),w.noMore)):this.push(n)}))},w.Observable.prototype.first=function(){return T(new w.Desc(this,"first",[]),this.take(1))},w.Observable.prototype.mapError=function(){var t=B(arguments);return T(new w.Desc(this,"mapError",[t]),this.withHandler(function(n){return this.push(n.isError()?G(t(n.error)):n)}))},w.Observable.prototype.flatMapError=function(t){var n=new w.Desc(this,"flatMapError",[t]);return T(n,this.mapError(function(t){return new f(t)}).flatMap(function(n){return n instanceof f?t(n.error):w.once(n)}))},w.EventStream.prototype.sampledBy=function(t,n){return T(new w.Desc(this,"sampledBy",[t,n]),this.toProperty().sampledBy(t,n))},w.Property.prototype.sampledBy=function(t,r){var e=!1;"undefined"!=typeof r&&null!==r?r=j(r):(e=!0,r=function(t){return t.value()});var i=new n(this,!1,e),u=new n(t,!0,e),o=w.when([i,u],r),s=t._isProperty?o.toProperty():o;return T(new w.Desc(this,"sampledBy",[t,r]),s)},w.Property.prototype.sample=function(t){return T(new w.Desc(this,"sample",[t]),this.sampledBy(w.interval(t,{})))},w.Observable.prototype.map=function(t){if(t&&t._isProperty)return t.sampledBy(this,S);for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;n>e;e++)r[e-1]=arguments[e];return z(this,t,r,function(t){return T(new w.Desc(this,"map",[t]),this.withHandler(function(n){return this.push(n.fmap(t))}))})},w.Observable.prototype.fold=function(t,n){return T(new w.Desc(this,"fold",[t,n]),this.scan(t,n).sampledBy(this.filter(!1).mapEnd().toProperty()))},h.prototype.reduce=h.prototype.fold;var lt=[["addEventListener","removeEventListener"],["addListener","removeListener"],["on","off"],["bind","unbind"]],pt=function(t){for(var n,r=0;r<lt.length;r++){n=lt[r];var e=[t[n[0]],t[n[1]]];if(e[0]&&e[1])return e}for(var i=0;i<lt.length;i++){n=lt[i];var u=t[n[0]];if(u)return[u,function(){}]}throw new f("No suitable event methods in "+t)};w.fromEventTarget=function(t,n,r){var e=pt(t),i=e[0],u=e[1],o=new w.Desc(w,"fromEvent",[t,n]);return T(o,w.fromBinder(function(r){return i.call(t,n,r),function(){return u.call(t,n,r)}},r))},w.fromEvent=w.fromEventTarget,w.fromPoll=function(t,n){var r=new w.Desc(w,"fromPoll",[t,n]);return T(r,w.fromBinder(function(n){var r=w.scheduler.setInterval(n,t);return function(){return w.scheduler.clearInterval(r)}},n))},w.fromPromise=function(t,n){var r=arguments.length<=2||void 0===arguments[2]?b:arguments[2];return T(new w.Desc(w,"fromPromise",[t]),w.fromBinder(function(r){var e=t.then(r,function(t){return r(new f(t))});return e&&"function"==typeof e.done&&e.done(),n?function(){return"function"==typeof t.abort?t.abort():void 0}:function(){}},r))},w.Observable.prototype.groupBy=function(t){var n=arguments.length<=1||void 0===arguments[1]?w._.id:arguments[1],r={},e=this;return e.filter(function(n){return!r[t(n)]}).map(function(i){var u=t(i),o=e.filter(function(n){return t(n)===u}),s=w.once(i).concat(o),a=n(s,i).withHandler(function(t){return this.push(t),t.isEnd()?delete r[u]:void 0});return r[u]=a,a})},w.fromArray=function(t){if(t.length){var n=0;return new v(new w.Desc(w,"fromArray",[t]),function(r){var e=!1,i=w.more,u=!1,o=!1,s=function(){if(o=!0,!u){for(u=!0;o;)if(o=!1,i!==w.noMore&&!e){var a=t[n++];i=r(K(a)),i!==w.noMore&&(n===t.length?r(J()):_.afterTransaction(s))}return u=!1}};return s(),function(){return e=!0}})}return T(new w.Desc(w,"fromArray",t),w.never())},w.EventStream.prototype.holdWhen=function(t){var n=!1,r=[],e=this;return new v(new w.Desc(this,"holdWhen",[t]),function(i){var u=new l,o=!1,s=function(t){return"function"==typeof t&&t(),u.empty()&&o?i(J()):void 0};return u.add(function(e,u){return t.subscribeInternal(function(t){if(!t.hasValue())return t.isEnd()?s(u):i(t);if(n=t.value(),!n){var e=r;return r=[],function(){for(var t,n=[],r=0;r<e.length;r++)t=e[r],n.push(i(G(t)));return n}()}})}),u.add(function(t,u){return e.subscribeInternal(function(t){return n&&t.hasValue()?r.push(t.value()):t.isEnd()&&r.length?s(u):i(t)})}),o=!0,s(),u.unsubscribe})},w.interval=function(t){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return T(new w.Desc(w,"interval",[t,n]),w.fromPoll(t,function(){return G(n)}))},w.$={},w.$.asEventStream=function(t,n,r){var e=this;return P.isFunction(n)&&(r=n,n=void 0),T(new w.Desc(this.selector||this,"asEventStream",[t]),w.fromBinder(function(r){return e.on(t,n,r),function(){return e.off(t,n,r)}},r))},"undefined"!=typeof jQuery&&jQuery&&(jQuery.fn.asEventStream=w.$.asEventStream),"undefined"!=typeof Zepto&&Zepto&&(Zepto.fn.asEventStream=w.$.asEventStream),w.Observable.prototype.last=function(){var t;return T(new w.Desc(this,"last",[]),this.withHandler(function(n){return n.isEnd()?(t&&this.push(t),this.push(J()),w.noMore):void(t=n)}))},w.Observable.prototype.log=function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return this.subscribe(function(t){"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,n.concat([t.log()]))}),this},w.EventStream.prototype.merge=function(t){var n=this;return T(new w.Desc(n,"merge",[t]),w.mergeAll(this,t))},w.mergeAll=function(){var t=et(arguments);return t.length?new v(new w.Desc(w,"mergeAll",t),function(n){var r=0,e=function(e){return function(i){return e.dispatcher.subscribe(function(e){if(e.isEnd())return r++,r===t.length?n(J()):w.more;var u=n(e);return u===w.noMore&&i(),u})}},i=P.map(e,t);return new w.CompositeUnsubscribe(i).unsubscribe}):w.never()},w.repeatedly=function(t,n){var r=0;return T(new w.Desc(w,"repeatedly",[t,n]),w.fromPoll(t,function(){return n[r++%n.length]}))},w.repeat=function(t){var n=0;return w.fromBinder(function(r){function e(t){return t.isEnd()?u?i():u=!0:o=r(t)}function i(){var i;for(u=!0;u&&o!==w.noMore;)i=t(n++),u=!1,i?s=i.subscribeInternal(e):r(J());return u=!0}var u=!1,o=w.more,s=function(){};return i(),function(){return s()}})},w.retry=function(t){if(!P.isFunction(t.source))throw new E("'source' option has to be a function");var n=t.source,r=t.retries||0,e=t.maxRetries||r,i=t.delay||function(){return 0},u=t.isRetryable||function(){return!0},o=!1,s=null;return T(new w.Desc(w,"retry",[t]),w.repeat(function(){function t(){return n().endOnError().withHandler(function(t){return t.isError()?(s=t,u(s.error)&&r>0?void 0:(o=!0,this.push(t))):(t.hasValue()&&(s=null,o=!0),this.push(t))})}if(o)return null;if(s){var a={error:s.error,retriesDone:e-r},c=w.later(i(a)).filter(!1);return r-=1,c.concat(w.once().flatMap(t))}return t()}))},w.sequentially=function(t,n){var r=0;return T(new w.Desc(w,"sequentially",[t,n]),w.fromPoll(t,function(){var t=n[r++];return r<n.length?t:r===n.length?[t,J()]:J()}))},w.Observable.prototype.skip=function(t){return T(new w.Desc(this,"skip",[t]),this.withHandler(function(n){return n.hasValue()&&t>0?(t--,w.more):this.push(n)}))},w.EventStream.prototype.skipUntil=function(t){var n=t.take(1).map(!0).toProperty(!1);return T(new w.Desc(this,"skipUntil",[t]),this.filter(n))},w.EventStream.prototype.skipWhile=function(t){for(var n=!1,r=arguments.length,e=Array(r>1?r-1:0),i=1;r>i;i++)e[i-1]=arguments[i];return z(this,t,e,function(t){return T(new w.Desc(this,"skipWhile",[t]),this.withHandler(function(r){return!n&&r.hasValue()&&t(r.value())?w.more:(r.hasValue()&&(n=!0),this.push(r))}))})},w.Observable.prototype.slidingWindow=function(t){var n=arguments.length<=1||void 0===arguments[1]?0:arguments[1];return T(new w.Desc(this,"slidingWindow",[t,n]),this.scan([],function(n,r){return n.concat([r]).slice(-t)}).filter(function(t){return t.length>=n}))};var vt=[],tt=function(t){if(vt.length&&!tt.running)try{tt.running=!0,vt.forEach(function(n){n(t)})}finally{delete tt.running}};w.spy=function(t){return vt.push(t)},w.Property.prototype.startWith=function(t){return T(new w.Desc(this,"startWith",[t]),this.scan(t,function(t,n){return n}))},w.EventStream.prototype.startWith=function(t){return T(new w.Desc(this,"startWith",[t]),w.once(t).concat(this))},w.Observable.prototype.takeWhile=function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;n>e;e++)r[e-1]=arguments[e];return z(this,t,r,function(t){return T(new w.Desc(this,"takeWhile",[t]),this.withHandler(function(n){return n.filter(t)?this.push(n):(this.push(J()),w.noMore)}))})},w.EventStream.prototype.throttle=function(t){return T(new w.Desc(this,"throttle",[t]),this.bufferWithTime(t).map(function(t){return t[t.length-1]}))},w.Property.prototype.throttle=function(t){return this.delayChanges(new w.Desc(this,"throttle",[t]),function(n){return n.throttle(t)})},h.prototype.firstToPromise=function(t){var n=this;if("function"!=typeof t){if("function"!=typeof Promise)throw new E("There isn't default Promise, use shim or parameter");t=Promise}return new t(function(t,r){return n.subscribe(function(n){return n.hasValue()&&t(n.value()),n.isError()&&r(n.error),w.noMore})})},h.prototype.toPromise=function(t){return this.last().firstToPromise(t)},w["try"]=function(t){return function(n){try{return w.once(t(n))}catch(r){return new w.Error(r)}}},w.update=function(n){function r(n){return function(){for(var r=arguments.length,e=Array(r),i=0;r>i;i++)e[i]=arguments[i];return function(r){return n.apply(void 0,t([r].concat(e)))}}}for(var e=arguments.length,i=Array(e>1?e-1:0),u=1;e>u;u++)i[u-1]=arguments[u];for(var o=i.length-1;o>0;)i[o]instanceof Function||(i[o]=P.always(i[o])),i[o]=r(i[o]),o-=2;return T(new w.Desc(w,"update",[n].concat(i)),w.when.apply(w,i).scan(n,function(t,n){return n(t)}))},w.zipAsArray=function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];var e=et(n);return T(new w.Desc(w,"zipAsArray",e),w.zipWith(e,function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return n}))},w.zipWith=function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];var e=it(n),i=e[0],u=e[1];return i=P.map(function(t){return t.toEventStream()},i),T(new w.Desc(w,"zipWith",[u].concat(i)),w.when(i,u))},w.Observable.prototype.zip=function(t,n){return T(new w.Desc(this,"zip",[t]),w.zipWith([this,t],n||Array))},"undefined"!=typeof define&&null!==define&&null!=define.amd?(define([],function(){return w}),"undefined"!=typeof this&&null!==this&&(this.Bacon=w)):"undefined"!=typeof module&&null!==module&&null!=module.exports?(module.exports=w,w.Bacon=w):this.Bacon=w}).call(this);
{
"name": "baconjs",
"description": "A small functional reactive programming lib for JavaScript.",
"version": "0.7.77",
"version": "0.7.78",
"keywords": [

@@ -6,0 +6,0 @@ "bacon.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc