Socket
Socket
Sign inDemoInstall

baconjs

Package Overview
Dependencies
0
Maintainers
2
Versions
222
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.86 to 0.7.87

5

dist/Bacon.min.js

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

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

2

package.json
{
"name": "baconjs",
"description": "A small functional reactive programming lib for JavaScript.",
"version": "0.7.86",
"version": "0.7.87",
"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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc