Comparing version 3.0.11 to 3.0.12
@@ -1,1 +0,1 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).Bacon={})}(this,function(n){"use strict";var e=function(n,t){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)t.hasOwnProperty(r)&&(n[r]=t[r])})(n,t)};function o(n,t){function r(){this.constructor=n}e(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function a(){}var h=Array.isArray||function(n){return n instanceof Array};function f(n){return n&&n._isObservable}function y(n,t){for(var r=0;r<n.length;r++)if(!t(n[r]))return!1;return!0}function i(n,t){for(var r=0;r<n.length;r++)if(t(n[r]))return!0;return!1}function u(n,t){return-1!==w(n,t)}function b(n,t){for(var r,e=[],i=0;i<t.length;i++)n(r=t[i])&&e.push(r);return e}function s(r){return function(n,t){return r(t,n)}}function c(n,t,r){for(var e=0;e<n.length;e++)t=r(t,n[e]);return t}function p(n){return n[0]}var w=Array.prototype.indexOf?function(n,t){return n.indexOf(t)}:function(n,t){for(var r=0;r<n.length;r++)if(t===n[r])return r;return-1};function l(n){return"function"==typeof n}function g(n,t){for(var r,e=[],i=0;i<t.length;i++)r=t[i],e.push(n(r));return e}function v(n){return n.slice(1,n.length)}function d(n){return h(n)?n:[n]}function m(t){return"function"==typeof t?t:function(n){return t}}var E={indexOf:w,indexWhere:function(n,t){for(var r=0;r<n.length;r++)if(t(n[r]))return r;return-1},head:p,always:function(n){return function(){return n}},negate:function(t){return function(n){return!t(n)}},empty:function(n){return 0===n.length},tail:v,filter:b,map:g,each:function(n,t){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t(r,n[r])},toArray:d,contains:u,id:function(n){return n},last:function(n){return n[n.length-1]},all:y,any:i,without:function(t,n){return b(function(n){return n!==t},n)},remove:function(n,t){var r=w(t,n);if(0<=r)return t.splice(r,1)},fold:c,flatMap:function(r,n){return c(n,[],function(n,t){return n.concat(r(t))})},bind:function(n,t){return function(){return n.apply(t,arguments)}},isFunction:l,toFunction:m,toString:function n(t){var r={}.hasOwnProperty;try{if(S++,null==t)return"undefined";if(l(t))return"function";if(h(t))return 5<S?"[..]":"["+g(n,t).toString()+"]";if(null!=(null!=t?t.toString:void 0)&&t.toString!==Object.prototype.toString)return t.toString();if("object"!=typeof t)return t;if(5<S)return"{..}";var e=[];for(var i in t)if(r.call(t,i)){var u=function(){try{return t[i]}catch(n){return n}}();e.push(n(i)+":"+n(u))}return"{"+e+"}"}finally{S--}}},S=0,D=void 0,I="<no-more>",A={scheduler:{setTimeout:function(n,t){return setTimeout(n,t)},setInterval:function(n,t){return setInterval(n,t)},clearInterval:function(n){return clearInterval(n)},clearTimeout:function(n){return clearTimeout(n)},now:function(){return(new Date).getTime()}}};var k=void 0,_=[],B={},x=[],M=0,W={},O=!1;function P(n){n<=M||(x[n-1]||(x[n-1]=[[],0]),M=n)}function T(n,t){if(!k&&!O)return t();P(1);for(var r=0;r<M-1&&!N(n,x[r][0]);)r++;x[r][0].push([n,t]),k||C()}function N(n,t){for(var r=0;r<t.length;r++)if(t[r][0].id==n.id)return!0;return!1}function C(){var n=M;if(n){var t=!O;O=!0;try{for(;n<=M;){var r=x[M-1];if(!r)throw new Error("Unexpected stack top: "+r);var e=r[0],i=r[1];if(!(i<e.length)){r[0]=[],r[1]=0;break}var u=e[i][1];r[1]++,P(M+1);var o=!1;try{for(u(),o=!0;n<M&&0==x[M-1][0].length;)M--}finally{o||(x=[],M=0)}}}finally{t&&(O=!1)}}}function r(n,t){if(k){var r=B[n.id];return void 0===r?(r=B[n.id]=[t],_.push(n)):r.push(t)}return t()}function F(n,t){var r=_[n],e=r.id,i=B[e];_.splice(n,1),delete B[e],t&&0<_.length&&function n(t){if(W[t.id])return;var r=t.internalDeps();for(var e,i=0;i<r.length;i++)if(e=r[i],n(e),B[e.id]){var u=E.indexOf(_,e);F(u,!1)}W[t.id]=!0}(r);for(var u=0;u<i.length;u++)(0,i[u])()}var V={toString:function(){return E.toString({rootEvent:k,processingAfters:O,waiterObs:_,waiters:B,aftersStack:x,aftersStackHeight:M,flushed:W})},whenDoneWith:r,hasWaiters:function(){return 0<_.length},inTransaction:function(n,t,r,e){if(k)return r.apply(t,e);k=n;try{var i=r.apply(t,e);!function(){for(;0<_.length;)F(0,!0);W={}}()}finally{k=void 0,C()}return i},currentEventId:function(){return k?k.id:void 0},wrappedSubscribe:function(t,n,r){var e=!1,i=!1,u=function(){i=!0},o=function(){e=!0,u()};return u=n(function(n){return T(t,function(){e||r(n)===I&&o()}),D}),i&&u(),o},afterTransaction:T,soonButNotYet:function(n,t){k?r(n,t):A.scheduler.setTimeout(t,0)},isInTransaction:function(){return void 0!==k}},L=function(){function n(n,t,r){void 0===r&&(r=[]),this._isDesc=!0,this.context=n,this.method=t,this.args=r}return n.prototype.deps=function(){return this.cachedDeps||(this.cachedDeps=t([this.context].concat(this.args))),this.cachedDeps},n.prototype.toString=function(){var n=E.map(E.toString,this.args);return E.toString(this.context)+"."+E.toString(this.method)+"("+n+")"},n}();function q(n,t){for(var r=[],e=2;e<arguments.length;e++)r[e-2]=arguments[e];var i=n||t;return i&&i._isDesc?n||t:new L(n,t,r)}function t(n){return h(n)?E.flatMap(t,n):f(n)?[n]:(null!=n?n._isSource:void 0)?[n.obs]:[]}var j=function(){return D},U=function(){return D};function Q(n,t,r){return r.transform(function(n,c){var f=n;return function(n,t){var r=c(f,n),e=r[0],i=r[1];f=e;for(var u=D,o=0;o<i.length;o++){var s=i[o];if((u=t(s))===I)return u}return u}}(n,t),new L(r,"withStateMachine",[n,t]))}var z=function(){function t(n){this._isSome=!0,this.isDefined=!0,this.value=n}return t.prototype.getOrElse=function(n){return this.value},t.prototype.get=function(){return this.value},t.prototype.filter=function(n){return n(this.value)?new t(this.value):H},t.prototype.map=function(n){return new t(n(this.value))},t.prototype.forEach=function(n){n(this.value)},t.prototype.toArray=function(){return[this.value]},t.prototype.inspect=function(){return"Some("+this.value+")"},t.prototype.toString=function(){return this.inspect()},t}(),H={_isNone:!0,getOrElse:function(n){return n},get:function(){throw new Error("None.get()")},filter:function(){return H},map:function(){return H},forEach:function(){},isDefined:!1,toArray:function(){return[]},inspect:function(){return"None"},toString:function(){return this.inspect()}};function R(){return H}var Y=0,X=function(){function n(){this.id=++Y,this.isEvent=!0,this._isEvent=!0,this.isEnd=!1,this.isInitial=!1,this.isNext=!1,this.isError=!1,this.hasValue=!1}return n.prototype.filter=function(n){return!0},n.prototype.inspect=function(){return this.toString()},n.prototype.log=function(){return this.toString()},n.prototype.toNext=function(){return this},n}(),$=function(r){function n(n){var t=r.call(this)||this;if(t.hasValue=!0,n instanceof X)throw new nn("Wrapping an event inside other event");return t.value=n,t}return o(n,r),n.prototype.fmap=function(n){return this.apply(n(this.value))},n.prototype.filter=function(n){return n(this.value)},n.prototype.toString=function(){return E.toString(this.value)},n.prototype.log=function(){return this.value},n}(X),G=function(r){function t(n){var t=r.call(this,n)||this;return t.isNext=!0,t._isNext=!0,t}return o(t,r),t.prototype.apply=function(n){return new t(n)},t}($),J=function(r){function t(n){var t=r.call(this,n)||this;return t.isInitial=!0,t._isInitial=!0,t}return o(t,r),t.prototype.apply=function(n){return new t(n)},t.prototype.toNext=function(){return new G(this.value)},t}($),K=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.hasValue=!1,n}return o(n,t),n.prototype.fmap=function(n){return this},n}(X),Z=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.isEnd=!0,n}return o(n,t),n.prototype.toString=function(){return"<end>"},n}(K),nn=function(r){function n(n){var t=r.call(this)||this;return t.isError=!0,t.error=n,t}return o(n,r),n.prototype.toString=function(){return"<error> "+E.toString(this.error)},n}(K);function tn(n){return new J(n)}function rn(n){return new G(n)}function en(){return new Z}function un(n){return n&&n._isEvent?n:rn(n)}function on(n){return n&&n._isEvent}function sn(n){return n.isError}function cn(n){return n.hasValue}function fn(n){return n.isEnd}function an(n,t){return n===t}function hn(n,t,r){return t.transform(pn(n),r||new L(t,"take",[n]))}function pn(r){return function(n,t){return n.hasValue?0<--r?t(n):(0===r&&t(n),t(en()),I):t(n)}}function ln(t,n,o){var s,c=n,f=!1;return s=new Mt(new L(t,"scan",[n,o]),function(r){var e=!1,n=a,i=D,u=function(){return e||(e=f=!0,(i=r(new J(c)))===I&&(n(),n=a)),i};return n=t.subscribeInternal(function(n){if(cn(n)){if(f&&n.isInitial)return D;n.isInitial||u(),e=f=!0;var t=o(c,n.value);return c=t,r(n.apply(t))}return n.isEnd&&(i=u()),i!==I?r(n):i}),V.whenDoneWith(s,u),n})}var vn=function(){function n(n){void 0===n&&(n=[]),this.unsubscribed=!1,this.unsubscribe=E.bind(this.unsubscribe,this),this.unsubscribed=!1,this.subscriptions=[],this.starting=[];for(var t,r=0;r<n.length;r++)t=n[r],this.add(t)}return n.prototype.add=function(n){var t=this;if(!this.unsubscribed){var r=!1,e=a;this.starting.push(n);e=n(this.unsubscribe,function(){t.unsubscribed||(r=!0,t.remove(e),E.remove(n,t.starting))}),this.unsubscribed||r?e():this.subscriptions.push(e),E.remove(n,this.starting)}},n.prototype.remove=function(n){if(!this.unsubscribed)return void 0!==E.remove(n,this.subscriptions)?n():void 0},n.prototype.unsubscribe=function(){if(!this.unsubscribed){this.unsubscribed=!0;for(var n=this.subscriptions,t=0;t<n.length;t++)n[t]();this.subscriptions=[],this.starting=[]}},n.prototype.count=function(){return this.unsubscribed?0:this.subscriptions.length+this.starting.length},n.prototype.empty=function(){return 0===this.count()},n}();function dn(s,n){return function(t){var r=!1,e=!1,i=a,u=D,o=function(){if(!r)return s.forEach(function(n){if(r=!0,(u=t(new J(n)))===I)return i(),i=a})};return i=n(function(n){return n instanceof $?n.isInitial&&!e?(s=new z(n.value),D):(n.isInitial||o(),r=!0,s=new z(n.value),t(n)):(n.isEnd&&(u=o()),u!==I?t(n):u)}),e=!0,o(),i}}function yn(n,t){return new Mt(n,dn(R(),t))}function bn(t){var r=new Pt(new L("Bacon","once",[t]),function(n){return V.soonButNotYet(r,function(){n(un(t)),n(en())}),a});return r}function wn(t,n,e){void 0===e&&(e={});var i=n,r=[i],f=[],a=n._isProperty,h=!1,u=(a?yn:Nt)(e.desc||new L(n,"flatMap_",[t]),function(u){var r=new vn,o=[];function s(n){if(a&&n.isInitial){if(h)return D;h=!0}var i=mn(t(n));return f.push(i),r.add(function(r,e){return i.subscribeInternal(function(n){if(n.isEnd)return E.remove(i,f),function(){var n=o.shift();n&&s(n)}(),c(e),I;n=n.toNext();var t=u(n);return t===I&&r(),t})})}function c(n){return n(),r.empty()?u(en()):D}return r.add(function(n,t){return i.subscribeInternal(function(n){return n.isEnd?c(t):n.isError&&!e.mapError?u(n):e.firstOnly&&1<r.count()?D:r.unsubscribed?I:(e.limit&&r.count()>e.limit?o.push(n):s(n),D)})}),r.unsubscribe});return u.internalDeps=function(){return f.length?r.concat(f):r},u}function gn(t){return"function"==typeof t?function(n){return cn(n)?t(n.value):n}:function(n){return t}}function mn(n){return f(n)?n:bn(n)}function En(n,t){return wn(t,n,{mapError:!0,desc:new L(n,"flatMapEvent",[t])})}var Sn=function(){function n(n,t){this._isSource=!0,this.flatten=!0,this.ended=!1,this.obs=n,this.sync=t}return n.prototype.subscribe=function(n){return this.obs.subscribeInternal(n)},n.prototype.toString=function(){return this.obs.toString()},n.prototype.markEnded=function(){this.ended=!0},n.prototype.mayHave=function(n){return!0},n}(),Dn=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return o(t,n),t.prototype.consume=function(){return this.value},t.prototype.push=function(n){this.value=n},t.prototype.hasAtLeast=function(n){return!!this.value},t}(Sn),In=function(e){function n(n,t){var r=e.call(this,n,t)||this;return r.flatten=!1,r.queue=[],r}return o(n,e),n.prototype.consume=function(){return this.queue.shift()},n.prototype.push=function(n){this.queue.push(n)},n.prototype.mayHave=function(n){return!this.ended||this.queue.length>=n},n.prototype.hasAtLeast=function(n){return this.queue.length>=n},n}(Sn),An=function(r){function n(n){var t=r.call(this,n,!0)||this;return t.queue=[],t}return o(n,r),n.prototype.consume=function(){var n=this.queue;return this.queue=[],{value:n}},n.prototype.push=function(n){return this.queue.push(n.value)},n.prototype.hasAtLeast=function(n){return!0},n}(Sn);function kn(n){return null!=n&&n._isSource?n:null!=n&&n._isProperty?new Dn(n,!1):new In(n,!0)}function _n(){return new Pt(q("Bacon","never"),function(n){return n(en()),a})}function Bn(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return Mn(Tt,n)}function xn(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return Mn(yn,n)}function Mn(n,t){if(0===t.length)return _n();var r=function(n){for(var t=[],r=[],e=0;e<n.length;e++){for(var i,u=n[e],o=u[0],s=u[1],c={f:s,ixs:[]},f=!1,a=0;a<o.length;a++){i=o[a];var h=w(t,i);f||(f=null!=(v=i)&&(v._isSource?v.sync:v._isEventStream)),h<0&&(t.push(i),h=t.length-1);for(var p=0;p<c.ixs.length;p++){var l=c.ixs[p];l.index===h&&l.count++}c.ixs.push({index:h,count:1})}if(0<o.length&&!f)throw new Error("At least one EventStream required, none found in "+o);0<o.length&&r.push(c)}var v;return[g(kn,t),r]}(On(t)),l=r[0],v=r[1];if(!l.length)return _n();var c=i(l,function(n){return n.flatten})&&function(n,e){void 0===e&&(e=[]);return i(n,function n(t){{if(u(e,t))return!0;var r=t.internalDeps();return r.length?(e.push(t),i(r,n)):(e.push(t),!1)}})}(g(function(n){return n.obs},l)),d=n(new L("Bacon","when",Array.prototype.slice.call(t)),function(f){var a=[],s=!1;function h(n){for(var t=0;t<n.ixs.length;t++){var r=n.ixs[t];if(!l[r.index].hasAtLeast(r.count))return!1}return!0}function t(n){for(var t=0;t<n.ixs.length;t++){var r=n.ixs[t];if(!l[r.index].mayHave(r.count))return!0}return!1}function p(n){return!n.source.flatten}return new vn(g(function(o){return function(e){function i(){return V.whenDoneWith(d,u)}function u(){var n=function n(){var t;if(void 0!==(t=a.pop()))for(var r,e=D,i=0;i<v.length;i++)if(h(r=v[i])){for(var u=[],o=0;o<r.ixs.length;o++){var s=l[r.ixs[o].index].consume();if(!s)throw new Error("Event was undefined");u.push(s.value)}var c=r.f.apply(null,u);return e=f(t.e.apply(c)),a.length&&(a=b(p,a)),e===I?e:n()}return D}();s&&(y(l,Pn)||y(v,t))&&(n=I,f(en())),n===I&&e()}return o.subscribe(function(n){var t=D;if(n.isEnd)s=!0,o.markEnded(),i();else if(n.isError)t=f(n);else{var r=n;o.push(r),o.sync&&(a.push({source:o,e:r}),c||V.hasWaiters()?i():u())}return t===I&&e(),t})}},l)).unsubscribe});return d}function Wn(n){for(var t=0,r=n.length,e=[];t<r;){var i=d(n[t++]),u=m(n[t++]);e.push([i,u])}return e}function On(n){for(var t,r=[],e=0;e<n.length;e++){var i=n[e];if(!((t=i)instanceof Array)||f(t[t.length-1]))return Wn(n);if(i[0]instanceof Array)r.push([i[0],m(i[1])]);else{var u=i.slice(0,i.length-1),o=m(i[i.length-1]);r.push([u,o])}}return r}function Pn(n){return!n.sync||n.ended}function Tn(n,t,r){return Bn([new Dn(t.toProperty(),!1),new Dn(n,!0),s(r)]).withDesc(new L(n,"withLatestFrom",[t,r]))}function Nn(n,t,r){return xn([new Dn(t.toProperty(),!1),new Dn(n,!0),s(r)]).withDesc(new L(n,"withLatestFrom",[t,r]))}function Cn(n,t,r){if(n instanceof Mt)return Nn(n,t,r);if(n instanceof Pt)return Tn(n,t,r);throw new Error("Unknown observable: "+n)}function Fn(n,t){return t instanceof Mt?Cn(n,t,function(n,t){return t}):n.transform(Vn(t),new L(n,"map",[t]))}function Vn(n){var r=E.toFunction(n);return function(n,t){return t(n.fmap(r))}}function Ln(t){return new Mt(new L("Bacon","constant",[t]),function(n){return n(tn(t)),n(en()),a})}function qn(n){return n=Array.prototype.slice.call(n),E.flatMap(jn,n)}function jn(n){return f(n)?[n]:h(n)?qn(n):[Ln(n)]}function Un(n){return E.isFunction(n[0])?[qn(Array.prototype.slice.call(n,1)),n[0]]:[qn(Array.prototype.slice.call(n,0,n.length-1)),E.last(n)]}function Qn(n,r){return Mn(function(n,t){return new Pt(n,t,void 0,r)},[E.map(function(n){return new An(n)},n),function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return n}]).withDesc(new L("Bacon","groupSimultaneous",n))}function zn(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];if((n=qn(n)).length){for(var r=[],e=0;e<n.length;e++){var i=f(n[e])?n[e]:Ln(n[e]);r.push(Rn(i))}return xn([r,function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return n}]).withDesc(new L("Bacon","combineAsArray",n))}return Ln([])}function Hn(n,t,r){return xn([[Rn(n),Rn(t)],r]).withDesc(new L(n,"combine",[t,r]))}function Rn(n){return new Dn(n,!0)}function Yn(n,t){return wn(gn(t),n,{desc:new L(n,"flatMapConcat",[t]),limit:1})}function Xn(e,f){void 0===f&&(f=E.id);var n=new L("Bacon","fromBinder",[e,f]);return new Pt(n,function(s){var n=!1,t=!1,c=function(){if(!n)return null!=r?(r(),n=!0):t=!0},r=e(function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];for(var r=f.apply(void 0,n),e=h(r)&&on(E.last(r))?r:[r],i=D,u=0;u<e.length;u++){var o=un(e[u]);if((i=s(o))===I||o.isEnd)return c(),i}return i});return t&&c(),c})}function $n(r,n){var t=new L("Bacon","fromPoll",[r,n]);return Xn(function(n){var t=A.scheduler.setInterval(n,r);return function(){return A.scheduler.clearInterval(t)}},n).withDesc(t)}function Gn(n,t){return $n(n,function(){return rn(t)}).withDesc(new L("Bacon","interval",[n,t]))}function Jn(n,t,r){return n instanceof Pt?function(n,t,r){return Kn(n.toProperty(),t,r).withDesc(new L(n,"sampledBy",[t]))}(n,t,r):Kn(n,t,r)}function Kn(n,t,r){return Cn(t,n,s(function(n){return"function"==typeof n?n:E.id}(r))).withDesc(new L(n,"sampledBy",[t]))}function Zn(n,r,t){return new Mt(new L(n,"transform",[r]),function(t){return n.subscribeInternal(function(n){return r(n,t)})}).withDesc(t)}function nt(r,t){var e,i=function(n){return t(n,e)};return function(n,t){return e=t,r(n,i)}}function tt(n,t,r,e){return t instanceof Mt?Cn(n,t,function(n,t){return[n,t]}).transform(nt(r(function(n){return n[1]}),Vn(function(n){return n[0]})),e):n.transform(r(function(n){if("boolean"==typeof n)return E.always(n);if("function"!=typeof n)throw new Error("Not a function: "+n);return n}(t)),e)}function rt(r){return function(n,t){return n.filter(r)?t(n):D}}function et(n){return n.map(function(n){return!n}).withDesc(new L(n,"not",[]))}function it(n){return Wt(n)?n:Ln(n)}function ut(n,t){return wn(gn(t),n,{firstOnly:!0,desc:new L(n,"flatMapFirst",[t])})}function ot(e,n){var i=new Pt(q(e,"justInitValue"),function(n){var t,r=e.dispatcher.subscribe(function(n){return n.isEnd||(t=n),I});return V.whenDoneWith(i,function(){return null!=t&&n(t),n(en())}),r},void 0,Ot);return i.concat(n,Ot).toProperty()}function st(n,t,r){return n.scan(t,r).last().withDesc(new L(n,"fold",[t,r]))}var ct={};function ft(n,t){return wn(gn(t),n,{desc:new L(n,"flatMap",[t])})}function at(n,r){return wn(function(n){if(n instanceof nn){var t=n.error;return r(t)}return n},n,{mapError:!0,desc:new L(n,"flatMapError",[r])})}var ht=[],pt=!1;function lt(t){if(ht.length&&!pt)try{pt=!0,ht.forEach(function(n){n(t)})}finally{pt=!1}}function vt(n,t){var r=E.toFunction(t),e=Wt(n)?n.toEventStream(Ot):n,i=ft(e,function(n){return mn(r(n)).takeUntil(e)});return Wt(n)&&(i=i.toProperty()),i.withDesc(new L(n,"flatMapLatest",[r]))}var dt=function(){function n(n,t,r){this.pushing=!1,this.ended=!1,this.prevError=void 0,this.unsubSrc=void 0,this._subscribe=t,this._handleEvent=r,this.subscribe=E.bind(this.subscribe,this),this.handleEvent=E.bind(this.handleEvent,this),this.subscriptions=[],this.observable=n,this.queue=[]}return n.prototype.hasSubscribers=function(){return 0<this.subscriptions.length},n.prototype.removeSub=function(n){return this.subscriptions=E.without(n,this.subscriptions),this.subscriptions},n.prototype.push=function(n){return n.isEnd&&(this.ended=!0),V.inTransaction(n,this,this.pushIt,[n])},n.prototype.pushToSubscriptions=function(n){try{for(var t=this.subscriptions,r=t.length,e=0;e<r;e++){var i=t[e];(i.sink(n)===I||n.isEnd)&&this.removeSub(i)}return!0}catch(n){throw this.pushing=!1,this.queue=[],n}},n.prototype.pushIt=function(n){if(this.pushing)return this.queue.push(n),D;if(n!==this.prevError){for(n.isError&&(this.prevError=n),this.pushing=!0,this.pushToSubscriptions(n),this.pushing=!1;;){var t=this.queue.shift();if(!t)break;this.push(t)}return this.hasSubscribers()?D:(this.unsubscribeFromSource(),I)}},n.prototype.handleEvent=function(n){return this._handleEvent?this._handleEvent(n):this.push(n)},n.prototype.unsubscribeFromSource=function(){this.unsubSrc&&this.unsubSrc(),this.unsubSrc=void 0},n.prototype.subscribe=function(n){var t=this;if(this.ended)return n(en()),a;var r={sink:n};return this.subscriptions.push(r),1===this.subscriptions.length&&(this.unsubSrc=this._subscribe(this.handleEvent)),function(){if(t.removeSub(r),!t.hasSubscribers())return t.unsubscribeFromSource()}},n.prototype.inspect=function(){return this.observable.toString()},n}(),yt=function(i){function n(n,t,r){var e=i.call(this,n,t,r)||this;return e.current=R(),e.propertyEnded=!1,e.subscribe=E.bind(e.subscribe,e),e}return o(n,i),n.prototype.push=function(n){return n.isEnd&&(this.propertyEnded=!0),n instanceof $?(this.current=new z(n),this.currentValueRootId=V.currentEventId()):n.hasValue&&console.error("Unknown event, two Bacons loaded?",n.constructor),i.prototype.push.call(this,n)},n.prototype.maybeSubSource=function(n,t){return t===I?a:this.propertyEnded?(n(en()),a):i.prototype.subscribe.call(this,n)},n.prototype.subscribe=function(n){var t=this,r=D;if(this.current.isDefined&&(this.hasSubscribers()||this.propertyEnded)){var e=V.currentEventId(),i=this.currentValueRootId;return!this.propertyEnded&&i&&e&&e!==i?V.whenDoneWith(this.observable,function(){if(t.currentValueRootId===i)return n(tn(t.current.get().value))}):V.inTransaction(void 0,this,function(){return r=n(tn(t.current.get().value))},[]),this.maybeSubSource(n,r)}return this.maybeSubSource(n,r)},n.prototype.inspect=function(){return this.observable+" current= "+this.current},n}(dt);function bt(n,t,r){return wn(gn(r),n,{desc:new L(n,"flatMapWithConcurrencyLimit",[t,r]),limit:t})}function wt(n,t,r){var e=function(n){if(void 0===n)return;if("number"!=typeof n)return n;var t=n;return function(n){return A.scheduler.setTimeout(n,t)}}(t);function i(n){return n.values.length===r?n.flush():void 0!==e?n.schedule(e):void 0}var u=new L(n,"bufferWithTimeOrCount",[t,r]);return function(n,r,t){void 0===r&&(r=a);void 0===t&&(t=a);var e=D,i=new gt(t,r);return n.transform(function(n,t){return i.push=t,cn(n)?(i.values.push(n.value),r(i)):sn(n)?e=t(n):fn(n)&&(i.end=n,i.scheduled||i.flush()),e}).withDesc(new L(n,"buffer",[]))}(n,i,i).withDesc(u)}var gt=function(){function n(n,t){this.push=function(n){return D},this.scheduled=null,this.end=void 0,this.values=[],this.onFlush=n,this.onInput=t}return n.prototype.flush=function(){if(this.scheduled&&(A.scheduler.clearTimeout(this.scheduled),this.scheduled=null),0<this.values.length){var n=this.values;this.values=[];var t=this.push(rn(n));if(null!=this.end)return this.push(this.end);if(t!==I)return this.onFlush(this)}else if(null!=this.end)return this.push(this.end)},n.prototype.schedule=function(n){var t=this;if(!this.scheduled)return this.scheduled=n(function(){return t.flush()})},n}();function mt(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var u=qn(n);return u.length?new Pt(new L("Bacon","mergeAll",u),function(e){var i=0,n=g(function(n){return function(r){return n.subscribeInternal(function(n){if(n.isEnd)return++i===u.length?e(en()):D;n=n.toNext();var t=e(n);return t===I&&r(),t})}},u);return new vn(n).unsubscribe}):_n()}function Et(r,e){return Xn(function(n){var t=A.scheduler.setTimeout(function(){return n([un(e),en()])},r);return function(){return A.scheduler.clearTimeout(t)}}).withDesc(new L("Bacon","later",[r,e]))}function St(r){return function(n,t){return n.filter(r)?t(n):(t(en()),I)}}function Dt(r){var e=!1;return function(n,t){return!e&&cn(n)&&r(n.value)?D:(n.hasValue&&(e=!0),t(n))}}function It(u,o,s){void 0===s&&(s=E.id);var c={};return u.transform(nt(rt(function(n){return!c[o(n)]}),Vn(function(n){var e=o(n),t=u.changes().filter(function(n){return o(n)===e}),r=bn(n).concat(t),i=s(r,n).toEventStream().transform(function(n,t){var r=t(n);return n.isEnd&&delete c[e],r});return c[e]=i})))}var At={};function kt(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var e=Un(arguments);t=e[0],n=e[1];return Bn([t=E.map(function(n){return n.toEventStream()},t),n]).withDesc(new L("Bacon","zipWith",[n].concat(t)))}function _t(i){function u(n,t,r){return function(n){return n[n.length-1]}(n)[t]=r}function o(n){return h(n)?[]:{}}function r(n){if(f(n))return!0;if(n&&(n.constructor==Object||n.constructor==Array))for(var t in n){if(Object.prototype.hasOwnProperty.call(n,t))if(r(n[t]))return!0}}function t(n,t){if(f(t))c.push(t),s.push(function(r,e){return function(n,t){u(n,r,t[e])}}(n,c.length-1));else if(r(t)){s.push(function(r,e){return function(n){var t=o(e);u(n,r,t),n.push(t)}}(n,t)),e(t),s.push(function(n){n.pop()})}else s.push(function(t,r){return function(n){u(n,t,r)}}(n,t))}function e(n){E.each(n,t)}var s=[],c=[];return(r(i)?(e(i),zn(c).map(function(n){for(var t=o(i),r=[t],e=0;e<s.length;e++)(0,s[e])(r,n);return t})):Ln(i)).withDesc(new L("Bacon","combineTemplate",[i]))}var Bt=0,xt=function(){function n(n){this.id=++Bt,this._isObservable=!0,this.desc=n,this.initialDesc=n}return n.prototype.awaiting=function(n){return function(n,t){return Qn([n,t],Ot).map(function(n){return 0===n[1].length}).toProperty(!1).skipDuplicates().withDesc(new L(n,"awaiting",[t]))}(this,n)},n.prototype.bufferingThrottle=function(n){return function(n,t){var r=new L(n,"bufferingThrottle",[t]);return n.delayChanges(r,function(n){return n.flatMapConcat(function(n){return bn(n).concat(Et(t,n).errors())})})}(this,n)},n.prototype.combine=function(n,t){return Hn(this,n,t)},n.prototype.debounce=function(n){return function(n,t){return n.delayChanges(new L(n,"debounce",[t]),function(n){return n.flatMapLatest(function(n){return Et(t,n)})})}(this,n)},n.prototype.debounceImmediate=function(n){return function(n,t){return n.delayChanges(new L(n,"debounceImmediate",[t]),function(n){return n.flatMapFirst(function(n){return bn(n).concat(Et(t,n).errors())})})}(this,n)},n.prototype.decode=function(n){return function(n,t){return n.combine(_t(t),function(n,t){return t[n]}).withDesc(new L(n,"decode",[t]))}(this,n)},n.prototype.delay=function(n){return function(n,t){return n.delayChanges(new L(n,"delay",[t]),function(n){return n.flatMap(function(n){return Et(t,n)})})}(this,n)},n.prototype.deps=function(){return this.desc.deps()},n.prototype.diff=function(n,t){return function(n,t,r){return Zn(ln(n,[t,At],function(n,t){return[t,r(n[0],t)]}),nt(rt(function(n){return n[1]!==At}),Vn(function(n){return n[1]})),new L(n,"diff",[t,r]))}(this,n,t)},n.prototype.doAction=function(n){return this.transform(function(r){return function(n,t){return cn(n)&&r(n.value),t(n)}}(n),new L(this,"doAction",[n]))},n.prototype.doEnd=function(n){return this.transform(function(r){return function(n,t){return fn(n)&&r(),t(n)}}(n),new L(this,"doEnd",[n]))},n.prototype.doError=function(n){return this.transform(function(r){return function(n,t){return sn(n)&&r(n.error),t(n)}}(n),new L(this,"doError",[n]))},n.prototype.doLog=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return this.transform(function(r){return function(n,t){return"undefined"!=typeof console&&null!==console&&"function"==typeof console.log&&console.log.apply(console,r.concat([n.log()])),t(n)}}(n),new L(this,"doLog",n))},n.prototype.endAsValue=function(){return function(n){return n.transform(function(n,t){return fn(n)?(t(rn({})),t(en()),I):D})}(this)},n.prototype.endOnError=function(n){return void 0===n&&(n=function(n){return!0}),function(n,r){return void 0===r&&(r=function(n){return!0}),n.transform(function(n,t){return sn(n)&&r(n.error)?(t(n),t(en())):t(n)},new L(n,"endOnError",[]))}(this,n)},n.prototype.errors=function(){return this.filter(function(n){return!1}).withDesc(new L(this,"errors"))},n.prototype.filter=function(n){return function(n,t){return tt(n,t,rt,new L(n,"filter",[t]))}(this,n)},n.prototype.first=function(){return hn(1,this,new L(this,"first"))},n.prototype.firstToPromise=function(n){return function(n,t){if("function"!=typeof t){if("function"!=typeof Promise)throw new Error("There isn't default Promise, use shim or parameter");t=function(n){return new Promise(n)}}return new t(function(t,r){return n.subscribe(function(n){return cn(n)&&t(n.value),sn(n)&&r(n.error),I})})}(this,n)},n.prototype.fold=function(n,t){return st(this,n,t)},n.prototype.forEach=function(n){return void 0===n&&(n=j),this.onValue(n)},n.prototype.holdWhen=function(n){return function(e,s){var c=!1,f=[],a=!1;return new Pt(new L(e,"holdWhen",[s]),function(u){var t=new vn,r=!1,o=function(n){return n&&n(),t.empty()&&r?u(en()):D};return t.add(function(n,i){return s.subscribeInternal(function(n){if(cn(n)){c=n.value;var t=D;if(!c){var r=f;f=[];for(var e=0;e<r.length;e++)t=u(rn(r[e]));a&&(u(en()),i(),t=I)}return t}return n.isEnd?o(i):u(n)})}),t.add(function(n,t){return e.subscribeInternal(function(n){return c&&cn(n)?(f.push(n.value),D):n.isEnd&&f.length?(a=!0,o(t)):u(n)})}),r=!0,o(),t.unsubscribe})}(this,n)},n.prototype.inspect=function(){return this.toString()},n.prototype.internalDeps=function(){return this.initialDesc.deps()},n.prototype.last=function(){return function(n){var r;return n.transform(function(n,t){return fn(n)?(r&&t(r),t(en()),I):cn(n)?(r=n,D):t(n)}).withDesc(new L(n,"last",[]))}(this)},n.prototype.log=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return function(t,n){n.subscribe(function(n){return"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,t.concat([n.log()])),D})}(n,this),this},n.prototype.mapEnd=function(n){return this.transform(function(n){var r=E.toFunction(n);return function(n,t){return fn(n)?(t(rn(r(n))),t(en()),I):t(n)}}(n),new L(this,"mapEnd",[n]))},n.prototype.mapError=function(n){return this.transform(function(n){var r=E.toFunction(n);return function(n,t){return sn(n)?t(rn(r(n.error))):t(n)}}(n),new L(this,"mapError",[n]))},n.prototype.name=function(n){return this._name=n,this},n.prototype.onEnd=function(t){return void 0===t&&(t=U),this.subscribe(function(n){return n.isEnd?t():D})},n.prototype.onError=function(t){return void 0===t&&(t=j),this.subscribe(function(n){return sn(n)?t(n.error):D})},n.prototype.onValue=function(t){return void 0===t&&(t=j),this.subscribe(function(n){return cn(n)?t(n.value):D})},n.prototype.onValues=function(t){return this.onValue(function(n){return t.apply(void 0,n)})},n.prototype.reduce=function(n,t){return st(this,n,t)},n.prototype.sampledBy=function(n){return Jn(this,n,arguments[1])},n.prototype.scan=function(n,t){return ln(this,n,t)},n.prototype.skip=function(n){return function(n,r){return n.transform(function(n,t){return n.hasValue&&0<r?(r--,D):t(n)},new L(n,"skip",[r]))}(this,n)},n.prototype.skipDuplicates=function(n){return function(n,r){void 0===r&&(r=an);var t=new L(n,"skipDuplicates",[]);return Q(R(),function(n,t){return cn(t)?t.isInitial||function(n){return null!=n&&n._isNone}(n)||!r(n.get(),t.value)?[new z(t.value),[t]]:[n,[]]:[n,[t]]},n).withDesc(t)}(this,n)},n.prototype.skipErrors=function(){return function(n){return n.transform(function(n,t){return sn(n)?D:t(n)},new L(n,"skipErrors",[]))}(this)},n.prototype.skipUntil=function(n){return function(n,t){var r=t.transform(nt(pn(1),Vn(!0))).toProperty().startWith(!1);return n.filter(r).withDesc(new L(n,"skipUntil",[t]))}(this,n)},n.prototype.skipWhile=function(n){return function(n,t){return tt(n,t,Dt,new L(n,"skipWhile",[t]))}(this,n)},n.prototype.slidingWindow=function(n,t){return void 0===t&&(t=0),function(n,r,t){return void 0===t&&(t=0),n.scan([],function(n,t){return n.concat([t]).slice(-r)}).filter(function(n){return n.length>=t}).withDesc(new L(n,"slidingWindow",[r,t]))}(this,n,t)},n.prototype.subscribe=function(n){var t=this;return void 0===n&&(n=j),V.wrappedSubscribe(this,function(n){return t.subscribeInternal(n)},n)},n.prototype.take=function(n){return hn(n,this)},n.prototype.takeUntil=function(n){return function(n,t){var r=Qn([n.mapEnd(ct),t.skipErrors()],Ot);return n instanceof Mt&&(r=r.toProperty()),r.transform(function(n,t){if(cn(n)){var r=n.value,e=r[0];if(r[1].length)return t(en());for(var i=D,u=0;u<e.length;u++){var o=e[u];if(o===ct)return t(en());i=t(rn(o))}return i}return t(n)},new L(n,"takeUntil",[t]))}(this,n)},n.prototype.takeWhile=function(n){return function(n,t){return tt(n,t,St,new L(n,"takeWhile",[t]))}(this,n)},n.prototype.throttle=function(n){return function(n,t){return n.delayChanges(new L(n,"throttle",[t]),function(n){return n.bufferWithTime(t).map(function(n){return n[n.length-1]})})}(this,n)},n.prototype.toPromise=function(n){return function(n,t){return n.last().firstToPromise(t)}(this,n)},n.prototype.toString=function(){return this._name?this._name:this.desc.toString()},n.prototype.withDesc=function(n){return n&&(this.desc=n),this},n.prototype.withDescription=function(n,t){for(var r=[],e=2;e<arguments.length;e++)r[e-2]=arguments[e];return this.desc=q.apply(void 0,[n,t].concat(r)),this},n.prototype.zip=function(n,t){return function(n,t,r){return kt(r||Array,n,t).withDesc(new L(n,"zip",[t]))}(this,n,t)},n}(),Mt=function(i){function n(n,t,r){var e=i.call(this,n)||this;return e._isProperty=!0,e.dispatcher=new yt(e,t,r),lt(e),e}return o(n,i),n.prototype.and=function(n){return function(n,t){return n.combine(it(t),function(n,t){return!(!n||!t)}).withDesc(new L(n,"and",[t]))}(this,n)},n.prototype.changes=function(){var n=this;return new Pt(new L(this,"changes",[]),function(t){return n.dispatcher.subscribe(function(n){return n.isInitial?D:t(n)})})},n.prototype.concat=function(n){return ot(this,this.changes().concat(n))},n.prototype.delayChanges=function(n,t){return ot(this,t(this.changes())).withDesc(n)},n.prototype.flatMap=function(n){return ft(this,n)},n.prototype.flatMapConcat=function(n){return Yn(this,n)},n.prototype.flatMapError=function(n){return at(this,n)},n.prototype.flatMapEvent=function(n){return En(this,n)},n.prototype.flatMapFirst=function(n){return ut(this,n)},n.prototype.flatMapLatest=function(n){return vt(this,n)},n.prototype.flatMapWithConcurrencyLimit=function(n,t){return bt(this,n,t)},n.prototype.groupBy=function(n,t){return It(this,n,t)},n.prototype.map=function(n){return Fn(this,n)},n.prototype.not=function(){return et(this)},n.prototype.or=function(n){return function(n,t){return n.combine(it(t),function(n,t){return n||t}).withDesc(new L(n,"or",[t]))}(this,n)},n.prototype.sample=function(n){return function(n,t){return Kn(n,Gn(t,{}),function(n,t){return n}).withDesc(new L(n,"sample",[t]))}(this,n)},n.prototype.startWith=function(n){return function(n,t){return n.scan(t,function(n,t){return t}).withDesc(new L(n,"startWith",[t]))}(this,n)},n.prototype.subscribeInternal=function(n){return void 0===n&&(n=j),this.dispatcher.subscribe(n)},n.prototype.toEventStream=function(n){var r=this;return new Pt(new L(this,"toEventStream",[]),function(t){return r.subscribeInternal(function(n){return t(n.toNext())})},void 0,n)},n.prototype.toProperty=function(){return this},n.prototype.transform=function(n,t){return Zn(this,n,t)},n.prototype.withLatestFrom=function(n,t){return Nn(this,n,t)},n.prototype.withStateMachine=function(n,t){return Q(n,t,this)},n}(xt);function Wt(n){return!!n._isProperty}var Ot={forceAsync:!1},Pt=function(u){function n(n,t,r,e){var i=u.call(this,n)||this;return i._isEventStream=!0,e!==Ot&&(t=function(u,n){var o=!1;return function(e){var i,t=V.isInTransaction();function r(){var n=i||[];i=void 0;for(var t=0;t<n.length;t++){var r=n[t];e(r)}}o=!0;try{return n(function(n){return o||i?(i?i.push(n):(i=[n],t?V.soonButNotYet(u,r):A.scheduler.setTimeout(r,0)),D):e(n)})}finally{o=!1}}}(i,t)),i.dispatcher=new dt(i,t,r),lt(i),i}return o(n,u),n.prototype.bufferWithTime=function(n){return function(n,t){return wt(n,t,Number.MAX_VALUE).withDesc(new L(n,"bufferWithTime",[t]))}(this,n)},n.prototype.bufferWithCount=function(n){return function(n,t){return wt(n,void 0,t).withDesc(new L(n,"bufferWithCount",[t]))}(this,n)},n.prototype.bufferWithTimeOrCount=function(n,t){return wt(this,n,t)},n.prototype.changes=function(){return this},n.prototype.concat=function(n,t){return function(e,i,n){return new Pt(new L(e,"concat",[i]),function(t){var r=a,n=e.dispatcher.subscribe(function(n){return n.isEnd?(r=i.toEventStream().dispatcher.subscribe(t),D):t(n)});return function(){return n(),r()}},void 0,n)}(this,n,t)},n.prototype.delayChanges=function(n,t){return t(this).withDesc(n)},n.prototype.flatMap=function(n){return ft(this,n)},n.prototype.flatMapConcat=function(n){return Yn(this,n)},n.prototype.flatMapError=function(n){return at(this,n)},n.prototype.flatMapFirst=function(n){return ut(this,n)},n.prototype.flatMapLatest=function(n){return vt(this,n)},n.prototype.flatMapWithConcurrencyLimit=function(n,t){return bt(this,n,t)},n.prototype.flatMapEvent=function(n){return En(this,n)},n.prototype.flatScan=function(n,t){return function(n,t,r){var e=t;return n.flatMapConcat(function(n){return mn(r(e,n)).doAction(function(n){return e=n})}).toProperty().startWith(t).withDesc(new L(n,"flatScan",[t,r]))}(this,n,t)},n.prototype.groupBy=function(n,t){return It(this,n,t)},n.prototype.map=function(n){return Fn(this,n)},n.prototype.merge=function(n){return mt(this,n).withDesc(new L(this,"merge",[n]))},n.prototype.not=function(){return et(this)},n.prototype.startWith=function(n){return function(n,t){return bn(t).concat(n).withDesc(new L(n,"startWith",[t]))}(this,n)},n.prototype.subscribeInternal=function(n){return void 0===n&&(n=j),this.dispatcher.subscribe(n)},n.prototype.toEventStream=function(){return this},n.prototype.toProperty=function(n){var t=arguments.length?function(n){return n&&(n._isSome||n._isNone)?n:new z(n)}(n):R(),r=this.dispatcher,e=new L(this,"toProperty",Array.prototype.slice.apply(arguments)),i=r.subscribe;return new Mt(e,dn(t,i))},n.prototype.transform=function(n,t){return function(n,r,t){return new Pt(new L(n,"transform",[r]),function(t){return n.subscribeInternal(function(n){return r(n,t)})},void 0,Ot).withDesc(t)}(this,n,t)},n.prototype.withLatestFrom=function(n,t){return Tn(this,n,t)},n.prototype.withStateMachine=function(n,t){return Q(n,t,this)},n}(xt);function Tt(n,t){return new Pt(n,t)}function Nt(n,t){return new Pt(n,t,void 0,Ot)}function Ct(n){return"undefined"!=typeof Symbol&&Symbol[n]?Symbol[n]:"undefined"!=typeof Symbol&&"function"==typeof Symbol.for?Symbol[n]=Symbol.for(n):"@@"+n}var Ft=function(){function n(n){this.observable=n}return n.prototype.subscribe=function(n,t,r){var e="function"==typeof n?{next:n,error:t,complete:r}:n,i={closed:!1,unsubscribe:function(){i.closed=!0,u()}},u=this.observable.subscribe(function(n){cn(n)&&e.next?e.next(n.value):sn(n)?(e.error&&e.error(n.error),i.unsubscribe()):n.isEnd&&(i.closed=!0,e.complete&&e.complete())});return i},n}();function Vt(r){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return function(n){return r.apply(void 0,[n].concat(t))}}}Ft.prototype[Ct("observable")]=function(){return this},xt.prototype.toESObservable=function(){return new Ft(this)},xt.prototype[Ct("observable")]=xt.prototype.toESObservable;var Lt=[["addEventListener","removeEventListener"],["addListener","removeListener"],["on","off"],["bind","unbind"]];function qt(t,r,n){var e=function(n){for(var t,r=0;r<Lt.length;r++){var e=[n[(t=Lt[r])[0]],n[t[1]]];if(e[0]&&e[1])return e}for(var i=0;i<Lt.length;i++){var u=n[(t=Lt[i])[0]];if(u)return[u,function(){}]}throw new Error("No suitable event methods in "+n)}(t),i=e[0],u=e[1],o=new L("Bacon","fromEvent",[t,r]);return Xn(function(n){return function(n){return E.isFunction(n)}(r)?(r(i.bind(t),n),function(){return r(u.bind(t),n)}):(i.call(t,r,n),function(){return u.call(t,r,n)})},n).withDesc(o)}function jt(s){var c=0;return Xn(function(t){var r=!1,e=D,i=function(){};function u(n){return n.isEnd?(r?o():r=!0,D):e=t(n)}function o(){var n;for(r=!0;r&&e!==I;)n=s(c++),r=!1,n?i=n.subscribeInternal(u):t(en());r=!0}return o(),function(){return i()}}).withDesc(new L("Bacon","repeat",[s]))}function Ut(n){return Et(n,"").filter(!1).withDesc(new L("Bacon","silence",[n]))}function Qt(n){return[un(n),en()]}var zt,Ht=(zt=function(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return E.isFunction(n)?t.length?function(r,e){return function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return r.apply(void 0,e.concat(n))}}(n,t):n:E.always(n)},function(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if("object"==typeof n&&t.length){var e=n,i=t[0];n=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return e[i].apply(e,n)},t=t.slice(1)}return zt.apply(void 0,[n].concat(t))});function Rt(n,t){return Ht.apply(void 0,[n].concat(t))}var Yt=function(n){function t(){var t=n.call(this,new L("Bacon","Bus",[]),function(n){return t.subscribeAll(n)})||this;return t.pushing=!1,t.pushQueue=void 0,t.ended=!1,t.subscriptions=[],t.unsubAll=E.bind(t.unsubAll,t),t.subscriptions=[],t.ended=!1,t}return o(t,n),t.prototype.plug=function(n){var t=this;if(!this.ended){var r={input:n,unsub:void 0};return this.subscriptions.push(r),void 0!==this.sink&&this.subscribeInput(r),function(){return t.unsubscribeInput(n)}}},t.prototype.end=function(){if(this.ended=!0,this.unsubAll(),"function"==typeof this.sink)return this.sink(en())},t.prototype.push=function(n){if(!this.ended&&"function"==typeof this.sink){var t=!this.pushing;if(!t)return this.pushQueue||(this.pushQueue=[]),void this.pushQueue.push(n);this.pushing=!0;try{return this.sink(rn(n))}finally{if(t&&this.pushQueue){for(var r=0;r<this.pushQueue.length;){var e=this.pushQueue[r];this.sink(rn(e)),r++}this.pushQueue=void 0}this.pushing=!1}}},t.prototype.error=function(n){if("function"==typeof this.sink)return this.sink(new nn(n))},t.prototype.unsubAll=function(){for(var n,t=this.subscriptions,r=0;r<t.length;r++)"function"==typeof(n=t[r]).unsub&&n.unsub()},t.prototype.subscribeAll=function(n){if(this.ended)n(en());else{this.sink=n;for(var t,r=this.subscriptions.slice(),e=0;e<r.length;e++)t=r[e],this.subscribeInput(t)}return this.unsubAll},t.prototype.guardedSink=function(t){var r=this;return function(n){return n.isEnd?(r.unsubscribeInput(t),I):r.sink?r.sink(n):D}},t.prototype.subscribeInput=function(n){return n.unsub=n.input.subscribeInternal(this.guardedSink(n.input)),n.unsub},t.prototype.unsubscribeInput=function(n){for(var t,r=this.subscriptions,e=0;e<r.length;e++)if((t=r[e]).input===n)return"function"==typeof t.unsub&&t.unsub(),void this.subscriptions.splice(e,1)},t}(Pt);var Xt={asEventStream:function(t,r,n){var e=this;return E.isFunction(r)&&(n=r,r=void 0),Xn(function(n){return e.on(t,r,n),function(){return e.off(t,r,n)}},n).withDesc(new L(this.selector||this,"asEventStream",[t]))},init:function(n){n.fn.asEventStream=Xt.asEventStream}};n.$=Xt,n.Bus=Yt,n.CompositeUnsubscribe=vn,n.Desc=L,n.End=Z,n.Error=nn,n.Event=X,n.EventStream=Pt,n.Initial=J,n.Next=G,n.Observable=xt,n.Property=Mt,n.Value=$,n._=E,n.combine=Hn,n.combineAsArray=zn,n.combineTemplate=_t,n.combineWith=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var e=Un(arguments),i=(n=e[0],t=e[1],new L("Bacon","combineWith",[t].concat(n)));return zn(n).map(function(n){return t.apply(void 0,n)}).withDesc(i)},n.concatAll=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var r=qn(n);return(r.length?c(v(r),p(r).toEventStream(),function(n,t){return n.concat(t)}):_n()).withDesc(new L("Bacon","concatAll",r))},n.constant=Ln,n.fromArray=function(s){if(s.length){var c=0,f=new Pt(new L("Bacon","fromArray",[s]),function(r){var e=!1,i=D,u=!1,o=!1;return V.soonButNotYet(f,function n(){if(o=!0,!u){if(c===s.length)return r(en()),!1;for(u=!0;o;)if(o=!1,i!==I&&!e){var t=s[c++];(i=r(un(t)))!==I&&(c===s.length?r(en()):V.afterTransaction(f,n))}return u=!1}}),function(){return e=!0}});return f}return _n().withDesc(new L("Bacon","fromArray",s))},n.fromBinder=Xn,n.fromCallback=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return Xn(function(n){return Rt(t,r)(n),a},function(n){return[n,en()]}).withDesc(new L("Bacon","fromCallback",[t].concat(r)))},n.fromESObservable=function(n){var r;r=n[Ct("observable")]?n[Ct("observable")]():n;var t=new L("Bacon","fromESObservable",[r]);return new Pt(t,function(t){var n=r.subscribe({error:function(n){t(new nn(n)),t(new Z)},next:function(n){t(new G(n))},complete:function(){t(new Z)}});return n.unsubscribe?function(){n.unsubscribe()}:n})},n.fromEvent=qt,n.fromEventTarget=qt,n.fromNodeCallback=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return Xn(function(n){return Rt(t,r)(n),a},function(n,t){return n?[new nn(n),en()]:[t,en()]}).withDesc(new L("Bacon","fromNodeCallback",[t].concat(r)))},n.fromPoll=$n,n.fromPromise=function(r,e,n){return void 0===n&&(n=Qt),Xn(function(t){var n=r.then(t,function(n){return t(new nn(n))});return n&&"function"==typeof n.done&&n.done(),e?function(){if("function"==typeof r.abort)return r.abort()}:function(){}},n).withDesc(new L("Bacon","fromPromise",[r]))},n.getScheduler=function(){return A.scheduler},n.groupSimultaneous=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return Qn(qn(n))},n.hasValue=cn,n.interval=Gn,n.isEnd=fn,n.isError=sn,n.isEvent=on,n.isInitial=function(n){return n&&n._isInitial},n.isNext=function(n){return n.isNext},n.later=Et,n.mergeAll=mt,n.more=D,n.never=_n,n.noMore=I,n.nullSink=j,n.nullVoidSink=U,n.onValues=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return zn(n.slice(0,n.length-1)).onValues(n[arguments.length-1])},n.once=bn,n.repeat=jt,n.repeatedly=function(n,t){var r=0;return $n(n,function(){return t[r++%t.length]}).withDesc(new L("Bacon","repeatedly",[n,t]))},n.retry=function(n){if(!E.isFunction(n.source))throw new Error("'source' option has to be a function");var i=n.source,u=n.retries||0,o=0,s=n.delay||function(){return 0},c=n.isRetryable||function(){return!0},f=!1,a=null;return jt(function(n){function t(){return i(n).endOnError().transform(function(n,t){return sn(n)?c((a=n).error)&&(0===u||o<u)?D:(f=!0,t(n)):(cn(n)&&(f=!(a=null)),t(n))})}if(!f){if(a){var r={error:a.error,retriesDone:o},e=Ut(s(r));return o++,e.concat(bn(null).flatMap(t))}return t()}}).withDesc(new L("Bacon","retry",[n]))},n.sequentially=function(n,t){var r=0;return $n(n,function(){var n=t[r++];return r<t.length?n:r===t.length?[un(n),en()]:en()}).withDesc(new L("Bacon","sequentially",[n,t]))},n.setScheduler=function(n){A.scheduler=n},n.silence=Ut,n.spy=function(n){return ht.push(n)},n.try=function(t){return function(n){try{return bn(t(n))}catch(n){return bn(new nn(n))}}},n.update=function(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];for(var e=On(t),i=0;i<e.length;i++){var u=e[i];u[1]=Vt(u[1])}return Bn.apply(void 0,e).scan(n,function(n,t){return t(n)}).withDesc(new L("Bacon","update",[n].concat(t)))},n.version="3.0.11",n.when=Bn,n.zipAsArray=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return Bn([E.map(function(n){return n.toEventStream()},qn(n)),function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return n}]).withDesc(new L("Bacon","zipAsArray",n))},n.zipWith=kt,Object.defineProperty(n,"__esModule",{value:!0})}); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).Bacon={})}(this,function(n){"use strict";var e=function(n,t){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)t.hasOwnProperty(r)&&(n[r]=t[r])})(n,t)};function o(n,t){function r(){this.constructor=n}e(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function a(){}var h=Array.isArray||function(n){return n instanceof Array};function f(n){return n&&n._isObservable}function y(n,t){for(var r=0;r<n.length;r++)if(!t(n[r]))return!1;return!0}function i(n,t){for(var r=0;r<n.length;r++)if(t(n[r]))return!0;return!1}function u(n,t){return-1!==w(n,t)}function b(n,t){for(var r,e=[],i=0;i<t.length;i++)n(r=t[i])&&e.push(r);return e}function s(r){return function(n,t){return r(t,n)}}function c(n,t,r){for(var e=0;e<n.length;e++)t=r(t,n[e]);return t}function p(n){return n[0]}var w=Array.prototype.indexOf?function(n,t){return n.indexOf(t)}:function(n,t){for(var r=0;r<n.length;r++)if(t===n[r])return r;return-1};function l(n){return"function"==typeof n}function m(n,t){for(var r,e=[],i=0;i<t.length;i++)r=t[i],e.push(n(r));return e}function v(n){return n.slice(1,n.length)}function d(n){return h(n)?n:[n]}function g(t){return"function"==typeof t?t:function(n){return t}}var E={indexOf:w,indexWhere:function(n,t){for(var r=0;r<n.length;r++)if(t(n[r]))return r;return-1},head:p,always:function(n){return function(){return n}},negate:function(t){return function(n){return!t(n)}},empty:function(n){return 0===n.length},tail:v,filter:b,map:m,each:function(n,t){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t(r,n[r])},toArray:d,contains:u,id:function(n){return n},last:function(n){return n[n.length-1]},all:y,any:i,without:function(t,n){return b(function(n){return n!==t},n)},remove:function(n,t){var r=w(t,n);if(0<=r)return t.splice(r,1)},fold:c,flatMap:function(r,n){return c(n,[],function(n,t){return n.concat(r(t))})},bind:function(n,t){return function(){return n.apply(t,arguments)}},isFunction:l,toFunction:g,toString:function n(t){var r={}.hasOwnProperty;try{if(S++,null==t)return"undefined";if(l(t))return"function";if(h(t))return 5<S?"[..]":"["+m(n,t).toString()+"]";if(null!=(null!=t?t.toString:void 0)&&t.toString!==Object.prototype.toString)return t.toString();if("object"!=typeof t)return t;if(5<S)return"{..}";var e=[];for(var i in t)if(r.call(t,i)){var u=function(){try{return t[i]}catch(n){return n}}();e.push(n(i)+":"+n(u))}return"{"+e+"}"}finally{S--}}},S=0,D=void 0,I="<no-more>",A={scheduler:{setTimeout:function(n,t){return setTimeout(n,t)},setInterval:function(n,t){return setInterval(n,t)},clearInterval:function(n){return clearInterval(n)},clearTimeout:function(n){return clearTimeout(n)},now:function(){return(new Date).getTime()}}};var k=void 0,_=[],B={},x=[],M=0,W={},O=!1;function T(n){n<=M||(x[n-1]||(x[n-1]=[[],0]),M=n)}function P(n,t){if(!k&&!O)return t();T(1);for(var r=0;r<M-1&&!C(n,x[r][0]);)r++;x[r][0].push([n,t]),k||N()}function C(n,t){for(var r=0;r<t.length;r++)if(t[r][0].id==n.id)return!0;return!1}function N(){var n=M;if(n){var t=!O;O=!0;try{for(;n<=M;){var r=x[M-1];if(!r)throw new Error("Unexpected stack top: "+r);var e=r[0],i=r[1];if(!(i<e.length)){r[0]=[],r[1]=0;break}var u=e[i][1];r[1]++,T(M+1);var o=!1;try{for(u(),o=!0;n<M&&0==x[M-1][0].length;)M--}finally{o||(x=[],M=0)}}}finally{t&&(O=!1)}}}function r(n,t){if(k){var r=B[n.id];return void 0===r?(r=B[n.id]=[t],_.push(n)):r.push(t)}return t()}function F(n,t){var r=_[n],e=r.id,i=B[e];_.splice(n,1),delete B[e],t&&0<_.length&&function n(t){if(W[t.id])return;var r=t.internalDeps();for(var e,i=0;i<r.length;i++)if(e=r[i],n(e),B[e.id]){var u=E.indexOf(_,e);F(u,!1)}W[t.id]=!0}(r);for(var u=0;u<i.length;u++)(0,i[u])()}var L={toString:function(){return E.toString({rootEvent:k,processingAfters:O,waiterObs:_,waiters:B,aftersStack:x,aftersStackHeight:M,flushed:W})},whenDoneWith:r,hasWaiters:function(){return 0<_.length},inTransaction:function(n,t,r,e){if(k)return r.apply(t,e);k=n;try{var i=r.apply(t,e);!function(){for(;0<_.length;)F(0,!0);W={}}()}finally{k=void 0,N()}return i},currentEventId:function(){return k?k.id:void 0},wrappedSubscribe:function(t,n,r){var e=!1,i=!1,u=function(){i=!0},o=function(){e=!0,u()};return u=n(function(n){return P(t,function(){e||r(n)===I&&o()}),D}),i&&u(),o},afterTransaction:P,soonButNotYet:function(n,t){k?r(n,t):A.scheduler.setTimeout(t,0)},isInTransaction:function(){return void 0!==k}},V=function(){function n(n,t,r){void 0===r&&(r=[]),this._isDesc=!0,this.context=n,this.method=t,this.args=r}return n.prototype.deps=function(){return this.cachedDeps||(this.cachedDeps=t([this.context].concat(this.args))),this.cachedDeps},n.prototype.toString=function(){var n=E.map(E.toString,this.args);return E.toString(this.context)+"."+E.toString(this.method)+"("+n+")"},n}();function q(n,t){for(var r=[],e=2;e<arguments.length;e++)r[e-2]=arguments[e];var i=n||t;return i&&i._isDesc?n||t:new V(n,t,r)}function t(n){return h(n)?E.flatMap(t,n):f(n)?[n]:(null!=n?n._isSource:void 0)?[n.obs]:[]}var j=function(){return D},U=function(){return D};function Q(n,t,r){return r.transform(function(n,c){var f=n;return function(n,t){var r=c(f,n),e=r[0],i=r[1];f=e;for(var u=D,o=0;o<i.length;o++){var s=i[o];if((u=t(s))===I)return u}return u}}(n,t),new V(r,"withStateMachine",[n,t]))}var z=function(){function t(n){this._isSome=!0,this.isDefined=!0,this.value=n}return t.prototype.getOrElse=function(n){return this.value},t.prototype.get=function(){return this.value},t.prototype.filter=function(n){return n(this.value)?new t(this.value):H},t.prototype.map=function(n){return new t(n(this.value))},t.prototype.forEach=function(n){n(this.value)},t.prototype.toArray=function(){return[this.value]},t.prototype.inspect=function(){return"Some("+this.value+")"},t.prototype.toString=function(){return this.inspect()},t}(),H={_isNone:!0,getOrElse:function(n){return n},get:function(){throw new Error("None.get()")},filter:function(){return H},map:function(){return H},forEach:function(){},isDefined:!1,toArray:function(){return[]},inspect:function(){return"None"},toString:function(){return this.inspect()}};function R(){return H}var Y=0,X=function(){function n(){this.id=++Y,this.isEvent=!0,this._isEvent=!0,this.isEnd=!1,this.isInitial=!1,this.isNext=!1,this.isError=!1,this.hasValue=!1}return n.prototype.filter=function(n){return!0},n.prototype.inspect=function(){return this.toString()},n.prototype.log=function(){return this.toString()},n.prototype.toNext=function(){return this},n}(),$=function(r){function n(n){var t=r.call(this)||this;if(t.hasValue=!0,n instanceof X)throw new nn("Wrapping an event inside other event");return t.value=n,t}return o(n,r),n.prototype.fmap=function(n){return this.apply(n(this.value))},n.prototype.filter=function(n){return n(this.value)},n.prototype.toString=function(){return E.toString(this.value)},n.prototype.log=function(){return this.value},n}(X),G=function(r){function t(n){var t=r.call(this,n)||this;return t.isNext=!0,t._isNext=!0,t}return o(t,r),t.prototype.apply=function(n){return new t(n)},t}($),J=function(r){function t(n){var t=r.call(this,n)||this;return t.isInitial=!0,t._isInitial=!0,t}return o(t,r),t.prototype.apply=function(n){return new t(n)},t.prototype.toNext=function(){return new G(this.value)},t}($),K=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.hasValue=!1,n}return o(n,t),n.prototype.fmap=function(n){return this},n}(X),Z=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.isEnd=!0,n}return o(n,t),n.prototype.toString=function(){return"<end>"},n}(K),nn=function(r){function n(n){var t=r.call(this)||this;return t.isError=!0,t.error=n,t}return o(n,r),n.prototype.toString=function(){return"<error> "+E.toString(this.error)},n}(K);function tn(n){return new J(n)}function rn(n){return new G(n)}function en(){return new Z}function un(n){return n&&n._isEvent?n:rn(n)}function on(n){return n&&n._isEvent}function sn(n){return n&&n._isInitial}function cn(n){return n.isError}function fn(n){return n.hasValue}function an(n){return n.isEnd}function hn(n,t){return n===t}function pn(n,t,r){return t.transform(ln(n),r||new V(t,"take",[n]))}function ln(r){return function(n,t){return n.hasValue?0<--r?t(n):(0===r&&t(n),t(en()),I):t(n)}}function vn(t,n,o){var s,c=n,f=!1;return s=new Mt(new V(t,"scan",[n,o]),function(r){var e=!1,n=a,i=D,u=function(){return e||(e=f=!0,(i=r(new J(c)))===I&&(n(),n=a)),i};return n=t.subscribeInternal(function(n){if(fn(n)){if(f&&n.isInitial)return D;n.isInitial||u(),e=f=!0;var t=o(c,n.value);return c=t,r(n.apply(t))}return n.isEnd&&(i=u()),i!==I?r(n):i}),L.whenDoneWith(s,u),n})}var dn=function(){function n(n){void 0===n&&(n=[]),this.unsubscribed=!1,this.unsubscribe=E.bind(this.unsubscribe,this),this.unsubscribed=!1,this.subscriptions=[],this.starting=[];for(var t,r=0;r<n.length;r++)t=n[r],this.add(t)}return n.prototype.add=function(n){var t=this;if(!this.unsubscribed){var r=!1,e=a;this.starting.push(n);e=n(this.unsubscribe,function(){t.unsubscribed||(r=!0,t.remove(e),E.remove(n,t.starting))}),this.unsubscribed||r?e():this.subscriptions.push(e),E.remove(n,this.starting)}},n.prototype.remove=function(n){if(!this.unsubscribed)return void 0!==E.remove(n,this.subscriptions)?n():void 0},n.prototype.unsubscribe=function(){if(!this.unsubscribed){this.unsubscribed=!0;for(var n=this.subscriptions,t=0;t<n.length;t++)n[t]();this.subscriptions=[],this.starting=[]}},n.prototype.count=function(){return this.unsubscribed?0:this.subscriptions.length+this.starting.length},n.prototype.empty=function(){return 0===this.count()},n}();function yn(s,n){return function(t){var r=!1,e=!1,i=a,u=D,o=function(){if(!r)return s.forEach(function(n){if(r=!0,(u=t(new J(n)))===I)return i(),i=a})};return i=n(function(n){return n instanceof $?n.isInitial&&!e?(s=new z(n.value),D):(n.isInitial||o(),r=!0,s=new z(n.value),t(n)):(n.isEnd&&(u=o()),u!==I?t(n):u)}),e=!0,o(),i}}function bn(n,t){return new Mt(n,yn(R(),t))}function wn(t){var r=new Tt(new V("Bacon","once",[t]),function(n){return L.soonButNotYet(r,function(){n(un(t)),n(en())}),a});return r}function mn(t,n,e){void 0===e&&(e={});var i=n,r=[i],f=[],a=n._isProperty,h=!1,u=(a?bn:Ct)(e.desc||new V(n,"flatMap_",[t]),function(u){var r=new dn,o=[];function s(n){if(a&&n.isInitial){if(h)return D;h=!0}var i=En(t(n));return f.push(i),r.add(function(r,e){return i.subscribeInternal(function(n){if(n.isEnd)return E.remove(i,f),function(){var n=o.shift();n&&s(n)}(),c(e),I;n=n.toNext();var t=u(n);return t===I&&r(),t})})}function c(n){return n(),r.empty()?u(en()):D}return r.add(function(n,t){return i.subscribeInternal(function(n){return n.isEnd?c(t):n.isError&&!e.mapError?u(n):e.firstOnly&&1<r.count()?D:r.unsubscribed?I:(e.limit&&r.count()>e.limit?o.push(n):s(n),D)})}),r.unsubscribe});return u.internalDeps=function(){return f.length?r.concat(f):r},u}function gn(t){return"function"==typeof t?function(n){return fn(n)?t(n.value):n}:function(n){return t}}function En(n){return f(n)?n:wn(n)}function Sn(n,t){return mn(t,n,{mapError:!0,desc:new V(n,"flatMapEvent",[t])})}var Dn=function(){function n(n,t){this._isSource=!0,this.flatten=!0,this.ended=!1,this.obs=n,this.sync=t}return n.prototype.subscribe=function(n){return this.obs.subscribeInternal(n)},n.prototype.toString=function(){return this.obs.toString()},n.prototype.markEnded=function(){this.ended=!0},n.prototype.mayHave=function(n){return!0},n}(),In=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return o(t,n),t.prototype.consume=function(){return this.value},t.prototype.push=function(n){this.value=n},t.prototype.hasAtLeast=function(n){return!!this.value},t}(Dn),An=function(e){function n(n,t){var r=e.call(this,n,t)||this;return r.flatten=!1,r.queue=[],r}return o(n,e),n.prototype.consume=function(){return this.queue.shift()},n.prototype.push=function(n){this.queue.push(n)},n.prototype.mayHave=function(n){return!this.ended||this.queue.length>=n},n.prototype.hasAtLeast=function(n){return this.queue.length>=n},n}(Dn),kn=function(r){function n(n){var t=r.call(this,n,!0)||this;return t.queue=[],t}return o(n,r),n.prototype.consume=function(){var n=this.queue;return this.queue=[],{value:n}},n.prototype.push=function(n){return this.queue.push(n.value)},n.prototype.hasAtLeast=function(n){return!0},n}(Dn);function _n(n){return null!=n&&n._isSource?n:null!=n&&n._isProperty?new In(n,!1):new An(n,!0)}function Bn(){return new Tt(q("Bacon","never"),function(n){return n(en()),a})}function xn(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return Wn(Pt,n)}function Mn(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return Wn(bn,n)}function Wn(n,t){if(0===t.length)return Bn();var r=function(n){for(var t=[],r=[],e=0;e<n.length;e++){for(var i,u=n[e],o=u[0],s=u[1],c={f:s,ixs:[]},f=!1,a=0;a<o.length;a++){i=o[a];var h=w(t,i);f||(f=null!=(v=i)&&(v._isSource?v.sync:v._isEventStream)),h<0&&(t.push(i),h=t.length-1);for(var p=0;p<c.ixs.length;p++){var l=c.ixs[p];l.index===h&&l.count++}c.ixs.push({index:h,count:1})}if(0<o.length&&!f)throw new Error("At least one EventStream required, none found in "+o);0<o.length&&r.push(c)}var v;return[m(_n,t),r]}(Tn(t)),l=r[0],v=r[1];if(!l.length)return Bn();var c=i(l,function(n){return n.flatten})&&function(n,e){void 0===e&&(e=[]);return i(n,function n(t){{if(u(e,t))return!0;var r=t.internalDeps();return r.length?(e.push(t),i(r,n)):(e.push(t),!1)}})}(m(function(n){return n.obs},l)),d=n(new V("Bacon","when",Array.prototype.slice.call(t)),function(f){var a=[],s=!1;function h(n){for(var t=0;t<n.ixs.length;t++){var r=n.ixs[t];if(!l[r.index].hasAtLeast(r.count))return!1}return!0}function t(n){for(var t=0;t<n.ixs.length;t++){var r=n.ixs[t];if(!l[r.index].mayHave(r.count))return!0}return!1}function p(n){return!n.source.flatten}return new dn(m(function(o){return function(e){function i(){return L.whenDoneWith(d,u)}function u(){var n=function n(){var t;if(void 0!==(t=a.pop()))for(var r,e=D,i=0;i<v.length;i++)if(h(r=v[i])){for(var u=[],o=0;o<r.ixs.length;o++){var s=l[r.ixs[o].index].consume();if(!s)throw new Error("Event was undefined");u.push(s.value)}var c=r.f.apply(null,u);return e=f(t.e.apply(c)),a.length&&(a=b(p,a)),e===I?e:n()}return D}();s&&(y(l,Pn)||y(v,t))&&(n=I,f(en())),n===I&&e()}return o.subscribe(function(n){var t=D;if(n.isEnd)s=!0,o.markEnded(),i();else if(n.isError)t=f(n);else{var r=n;o.push(r),o.sync&&(a.push({source:o,e:r}),c||L.hasWaiters()?i():u())}return t===I&&e(),t})}},l)).unsubscribe});return d}function On(n){for(var t=0,r=n.length,e=[];t<r;){var i=d(n[t++]),u=g(n[t++]);e.push([i,u])}return e}function Tn(n){for(var t,r=[],e=0;e<n.length;e++){var i=n[e];if(!((t=i)instanceof Array)||f(t[t.length-1]))return On(n);if(i[0]instanceof Array)r.push([i[0],g(i[1])]);else{var u=i.slice(0,i.length-1),o=g(i[i.length-1]);r.push([u,o])}}return r}function Pn(n){return!n.sync||n.ended}function Cn(n,t,r){return xn([new In(t.toProperty(),!1),new In(n,!0),s(r)]).withDesc(new V(n,"withLatestFrom",[t,r]))}function Nn(n,t,r){return Mn([new In(t.toProperty(),!1),new In(n,!0),s(r)]).withDesc(new V(n,"withLatestFrom",[t,r]))}function Fn(n,t,r){if(n instanceof Mt)return Nn(n,t,r);if(n instanceof Tt)return Cn(n,t,r);throw new Error("Unknown observable: "+n)}function Ln(n,t){return t instanceof Mt?Fn(n,t,function(n,t){return t}):n.transform(Vn(t),new V(n,"map",[t]))}function Vn(n){var r=E.toFunction(n);return function(n,t){return t(n.fmap(r))}}function qn(t){return new Mt(new V("Bacon","constant",[t]),function(n){return n(tn(t)),n(en()),a})}function jn(n){return n=Array.prototype.slice.call(n),E.flatMap(Un,n)}function Un(n){return f(n)?[n]:h(n)?jn(n):[qn(n)]}function Qn(n){return E.isFunction(n[0])?[jn(Array.prototype.slice.call(n,1)),n[0]]:[jn(Array.prototype.slice.call(n,0,n.length-1)),E.last(n)]}function zn(n,r){return Wn(function(n,t){return new Tt(n,t,void 0,r)},[E.map(function(n){return new kn(n)},n),function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return n}]).withDesc(new V("Bacon","groupSimultaneous",n))}function Hn(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];if((n=jn(n)).length){for(var r=[],e=0;e<n.length;e++){var i=f(n[e])?n[e]:qn(n[e]);r.push(Yn(i))}return Mn([r,function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return n}]).withDesc(new V("Bacon","combineAsArray",n))}return qn([])}function Rn(n,t,r){return Mn([[Yn(n),Yn(t)],r]).withDesc(new V(n,"combine",[t,r]))}function Yn(n){return new In(n,!0)}function Xn(n,t){return mn(gn(t),n,{desc:new V(n,"flatMapConcat",[t]),limit:1})}function $n(e,f){void 0===f&&(f=E.id);var n=new V("Bacon","fromBinder",[e,f]);return new Tt(n,function(s){var n=!1,t=!1,c=function(){if(!n)return null!=r?(r(),n=!0):t=!0},r=e(function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];for(var r=f.apply(void 0,n),e=h(r)&&on(E.last(r))?r:[r],i=D,u=0;u<e.length;u++){var o=un(e[u]);if((i=s(o))===I||o.isEnd)return c(),i}return i});return t&&c(),c})}function Gn(r,n){var t=new V("Bacon","fromPoll",[r,n]);return $n(function(n){var t=A.scheduler.setInterval(n,r);return function(){return A.scheduler.clearInterval(t)}},n).withDesc(t)}function Jn(n,t){return Gn(n,function(){return rn(t)}).withDesc(new V("Bacon","interval",[n,t]))}function Kn(n,t,r){return n instanceof Tt?function(n,t,r){return Zn(n.toProperty(),t,r).withDesc(new V(n,"sampledBy",[t]))}(n,t,r):Zn(n,t,r)}function Zn(n,t,r){return Fn(t,n,s(function(n){return"function"==typeof n?n:E.id}(r))).withDesc(new V(n,"sampledBy",[t]))}function nt(n,r,t){return new Mt(new V(n,"transform",[r]),function(t){return n.subscribeInternal(function(n){return r(n,t)})}).withDesc(t)}function tt(r,t){var e,i=function(n){return t(n,e)};return function(n,t){return e=t,r(n,i)}}function rt(n,t,r,e){return t instanceof Mt?Fn(n,t,function(n,t){return[n,t]}).transform(tt(r(function(n){return n[1]}),Vn(function(n){return n[0]})),e):n.transform(r(function(n){if("boolean"==typeof n)return E.always(n);if("function"!=typeof n)throw new Error("Not a function: "+n);return n}(t)),e)}function et(r){return function(n,t){return n.filter(r)?t(n):D}}function it(n){return n.map(function(n){return!n}).withDesc(new V(n,"not",[]))}function ut(n){return Wt(n)?n:qn(n)}function ot(n,t){return mn(gn(t),n,{firstOnly:!0,desc:new V(n,"flatMapFirst",[t])})}function st(n,t,r){return n.scan(t,r).last().withDesc(new V(n,"fold",[t,r]))}var ct={};function ft(n,t){return mn(gn(t),n,{desc:new V(n,"flatMap",[t])})}function at(n,r){return mn(function(n){if(n instanceof nn){var t=n.error;return r(t)}return n},n,{mapError:!0,desc:new V(n,"flatMapError",[r])})}var ht=[],pt=!1;function lt(t){if(ht.length&&!pt)try{pt=!0,ht.forEach(function(n){n(t)})}finally{pt=!1}}function vt(n,t){var r=E.toFunction(t),e=Wt(n)?n.toEventStream(Ot):n,i=ft(e,function(n){return En(r(n)).takeUntil(e)});return Wt(n)&&(i=i.toProperty()),i.withDesc(new V(n,"flatMapLatest",[r]))}var dt=function(){function n(n,t,r){this.pushing=!1,this.ended=!1,this.prevError=void 0,this.unsubSrc=void 0,this._subscribe=t,this._handleEvent=r,this.subscribe=E.bind(this.subscribe,this),this.handleEvent=E.bind(this.handleEvent,this),this.subscriptions=[],this.observable=n,this.queue=[]}return n.prototype.hasSubscribers=function(){return 0<this.subscriptions.length},n.prototype.removeSub=function(n){return this.subscriptions=E.without(n,this.subscriptions),this.subscriptions},n.prototype.push=function(n){return n.isEnd&&(this.ended=!0),L.inTransaction(n,this,this.pushIt,[n])},n.prototype.pushToSubscriptions=function(n){try{for(var t=this.subscriptions,r=t.length,e=0;e<r;e++){var i=t[e];(i.sink(n)===I||n.isEnd)&&this.removeSub(i)}return!0}catch(n){throw this.pushing=!1,this.queue=[],n}},n.prototype.pushIt=function(n){if(this.pushing)return this.queue.push(n),D;if(n!==this.prevError){for(n.isError&&(this.prevError=n),this.pushing=!0,this.pushToSubscriptions(n),this.pushing=!1;;){var t=this.queue.shift();if(!t)break;this.push(t)}return this.hasSubscribers()?D:(this.unsubscribeFromSource(),I)}},n.prototype.handleEvent=function(n){return this._handleEvent?this._handleEvent(n):this.push(n)},n.prototype.unsubscribeFromSource=function(){this.unsubSrc&&this.unsubSrc(),this.unsubSrc=void 0},n.prototype.subscribe=function(n){var t=this;if(this.ended)return n(en()),a;var r={sink:n};return this.subscriptions.push(r),1===this.subscriptions.length&&(this.unsubSrc=this._subscribe(this.handleEvent)),function(){if(t.removeSub(r),!t.hasSubscribers())return t.unsubscribeFromSource()}},n.prototype.inspect=function(){return this.observable.toString()},n}(),yt=function(i){function n(n,t,r){var e=i.call(this,n,t,r)||this;return e.current=R(),e.propertyEnded=!1,e.subscribe=E.bind(e.subscribe,e),e}return o(n,i),n.prototype.push=function(n){return n.isEnd&&(this.propertyEnded=!0),n instanceof $?(this.current=new z(n),this.currentValueRootId=L.currentEventId()):n.hasValue&&console.error("Unknown event, two Bacons loaded?",n.constructor),i.prototype.push.call(this,n)},n.prototype.maybeSubSource=function(n,t){return t===I?a:this.propertyEnded?(n(en()),a):i.prototype.subscribe.call(this,n)},n.prototype.subscribe=function(n){var t=this,r=D;if(this.current.isDefined&&(this.hasSubscribers()||this.propertyEnded)){var e=L.currentEventId(),i=this.currentValueRootId;return!this.propertyEnded&&i&&e&&e!==i?L.whenDoneWith(this.observable,function(){if(t.currentValueRootId===i)return n(tn(t.current.get().value))}):L.inTransaction(void 0,this,function(){return r=n(tn(t.current.get().value))},[]),this.maybeSubSource(n,r)}return this.maybeSubSource(n,r)},n.prototype.inspect=function(){return this.observable+" current= "+this.current},n}(dt);function bt(n,t,r){return mn(gn(r),n,{desc:new V(n,"flatMapWithConcurrencyLimit",[t,r]),limit:t})}function wt(n,t,r){var e=function(n){if(void 0===n)return;if("number"!=typeof n)return n;var t=n;return function(n){return A.scheduler.setTimeout(n,t)}}(t);function i(n){return n.values.length===r?n.flush():void 0!==e?n.schedule(e):void 0}var u=new V(n,"bufferWithTimeOrCount",[t,r]);return function(n,r,t){void 0===r&&(r=a);void 0===t&&(t=a);var e=D,i=new mt(t,r);return n.transform(function(n,t){return i.push=t,fn(n)?(i.values.push(n.value),r(i)):cn(n)?e=t(n):an(n)&&(i.end=n,i.scheduled||i.flush()),e}).withDesc(new V(n,"buffer",[]))}(n,i,i).withDesc(u)}var mt=function(){function n(n,t){this.push=function(n){return D},this.scheduled=null,this.end=void 0,this.values=[],this.onFlush=n,this.onInput=t}return n.prototype.flush=function(){if(this.scheduled&&(A.scheduler.clearTimeout(this.scheduled),this.scheduled=null),0<this.values.length){var n=this.values;this.values=[];var t=this.push(rn(n));if(null!=this.end)return this.push(this.end);if(t!==I)return this.onFlush(this)}else if(null!=this.end)return this.push(this.end)},n.prototype.schedule=function(n){var t=this;if(!this.scheduled)return this.scheduled=n(function(){return t.flush()})},n}();function gt(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var u=jn(n);return u.length?new Tt(new V("Bacon","mergeAll",u),function(e){var i=0,n=m(function(n){return function(r){return n.subscribeInternal(function(n){if(n.isEnd)return++i===u.length?e(en()):D;n=n.toNext();var t=e(n);return t===I&&r(),t})}},u);return new dn(n).unsubscribe}):Bn()}function Et(r,e){return $n(function(n){var t=A.scheduler.setTimeout(function(){return n([un(e),en()])},r);return function(){return A.scheduler.clearTimeout(t)}}).withDesc(new V("Bacon","later",[r,e]))}function St(r){return function(n,t){return n.filter(r)?t(n):(t(en()),I)}}function Dt(r){var e=!1;return function(n,t){return!e&&fn(n)&&r(n.value)?D:(n.hasValue&&(e=!0),t(n))}}function It(u,o,s){void 0===s&&(s=E.id);var c={};return u.transform(tt(et(function(n){return!c[o(n)]}),Vn(function(n){var e=o(n),t=u.changes().filter(function(n){return o(n)===e}),r=wn(n).concat(t),i=s(r,n).toEventStream().transform(function(n,t){var r=t(n);return n.isEnd&&delete c[e],r});return c[e]=i})))}var At={};function kt(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var e=Qn(arguments);t=e[0],n=e[1];return xn([t=E.map(function(n){return n.toEventStream()},t),n]).withDesc(new V("Bacon","zipWith",[n].concat(t)))}function _t(i){function u(n,t,r){return function(n){return n[n.length-1]}(n)[t]=r}function o(n){return h(n)?[]:{}}function r(n){if(f(n))return!0;if(n&&(n.constructor==Object||n.constructor==Array))for(var t in n){if(Object.prototype.hasOwnProperty.call(n,t))if(r(n[t]))return!0}}function t(n,t){if(f(t))c.push(t),s.push(function(r,e){return function(n,t){u(n,r,t[e])}}(n,c.length-1));else if(r(t)){s.push(function(r,e){return function(n){var t=o(e);u(n,r,t),n.push(t)}}(n,t)),e(t),s.push(function(n){n.pop()})}else s.push(function(t,r){return function(n){u(n,t,r)}}(n,t))}function e(n){E.each(n,t)}var s=[],c=[];return(r(i)?(e(i),Hn(c).map(function(n){for(var t=o(i),r=[t],e=0;e<s.length;e++)(0,s[e])(r,n);return t})):qn(i)).withDesc(new V("Bacon","combineTemplate",[i]))}var Bt=0,xt=function(){function n(n){this.id=++Bt,this._isObservable=!0,this.desc=n,this.initialDesc=n}return n.prototype.awaiting=function(n){return function(n,t){return zn([n,t],Ot).map(function(n){return 0===n[1].length}).toProperty(!1).skipDuplicates().withDesc(new V(n,"awaiting",[t]))}(this,n)},n.prototype.bufferingThrottle=function(n){return function(n,t){var r=new V(n,"bufferingThrottle",[t]);return n.transformChanges(r,function(n){return n.flatMapConcat(function(n){return wn(n).concat(Et(t,n).errors())})})}(this,n)},n.prototype.combine=function(n,t){return Rn(this,n,t)},n.prototype.debounce=function(n){return function(n,t){return n.transformChanges(new V(n,"debounce",[t]),function(n){return n.flatMapLatest(function(n){return Et(t,n)})})}(this,n)},n.prototype.debounceImmediate=function(n){return function(n,t){return n.transformChanges(new V(n,"debounceImmediate",[t]),function(n){return n.flatMapFirst(function(n){return wn(n).concat(Et(t,n).errors())})})}(this,n)},n.prototype.decode=function(n){return function(n,t){return n.combine(_t(t),function(n,t){return t[n]}).withDesc(new V(n,"decode",[t]))}(this,n)},n.prototype.delay=function(n){return function(n,t){return n.transformChanges(new V(n,"delay",[t]),function(n){return n.flatMap(function(n){return Et(t,n)})})}(this,n)},n.prototype.deps=function(){return this.desc.deps()},n.prototype.diff=function(n,t){return function(n,t,r){return nt(vn(n,[t,At],function(n,t){return[t,r(n[0],t)]}),tt(et(function(n){return n[1]!==At}),Vn(function(n){return n[1]})),new V(n,"diff",[t,r]))}(this,n,t)},n.prototype.doAction=function(n){return this.transform(function(r){return function(n,t){return fn(n)&&r(n.value),t(n)}}(n),new V(this,"doAction",[n]))},n.prototype.doEnd=function(n){return this.transform(function(r){return function(n,t){return an(n)&&r(),t(n)}}(n),new V(this,"doEnd",[n]))},n.prototype.doError=function(n){return this.transform(function(r){return function(n,t){return cn(n)&&r(n.error),t(n)}}(n),new V(this,"doError",[n]))},n.prototype.doLog=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return this.transform(function(r){return function(n,t){return"undefined"!=typeof console&&null!==console&&"function"==typeof console.log&&console.log.apply(console,r.concat([n.log()])),t(n)}}(n),new V(this,"doLog",n))},n.prototype.endAsValue=function(){return function(n){return n.transform(function(n,t){return an(n)?(t(rn({})),t(en()),I):D})}(this)},n.prototype.endOnError=function(n){return void 0===n&&(n=function(n){return!0}),function(n,r){return void 0===r&&(r=function(n){return!0}),n.transform(function(n,t){return cn(n)&&r(n.error)?(t(n),t(en())):t(n)},new V(n,"endOnError",[]))}(this,n)},n.prototype.errors=function(){return this.filter(function(n){return!1}).withDesc(new V(this,"errors"))},n.prototype.filter=function(n){return function(n,t){return rt(n,t,et,new V(n,"filter",[t]))}(this,n)},n.prototype.first=function(){return pn(1,this,new V(this,"first"))},n.prototype.firstToPromise=function(n){return function(n,t){if("function"!=typeof t){if("function"!=typeof Promise)throw new Error("There isn't default Promise, use shim or parameter");t=function(n){return new Promise(n)}}return new t(function(t,r){return n.subscribe(function(n){return fn(n)&&t(n.value),cn(n)&&r(n.error),I})})}(this,n)},n.prototype.fold=function(n,t){return st(this,n,t)},n.prototype.forEach=function(n){return void 0===n&&(n=j),this.onValue(n)},n.prototype.holdWhen=function(n){return function(e,s){var c=!1,f=[],a=!1;return new Tt(new V(e,"holdWhen",[s]),function(u){var t=new dn,r=!1,o=function(n){return n&&n(),t.empty()&&r?u(en()):D};return t.add(function(n,i){return s.subscribeInternal(function(n){if(fn(n)){c=n.value;var t=D;if(!c){var r=f;f=[];for(var e=0;e<r.length;e++)t=u(rn(r[e]));a&&(u(en()),i(),t=I)}return t}return n.isEnd?o(i):u(n)})}),t.add(function(n,t){return e.subscribeInternal(function(n){return c&&fn(n)?(f.push(n.value),D):n.isEnd&&f.length?(a=!0,o(t)):u(n)})}),r=!0,o(),t.unsubscribe})}(this,n)},n.prototype.inspect=function(){return this.toString()},n.prototype.internalDeps=function(){return this.initialDesc.deps()},n.prototype.last=function(){return function(n){var r;return n.transform(function(n,t){return an(n)?(r&&t(r),t(en()),I):fn(n)?(r=n,D):t(n)}).withDesc(new V(n,"last",[]))}(this)},n.prototype.log=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return function(t,n){n.subscribe(function(n){return"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,t.concat([n.log()])),D})}(n,this),this},n.prototype.mapEnd=function(n){return this.transform(function(n){var r=E.toFunction(n);return function(n,t){return an(n)?(t(rn(r(n))),t(en()),I):t(n)}}(n),new V(this,"mapEnd",[n]))},n.prototype.mapError=function(n){return this.transform(function(n){var r=E.toFunction(n);return function(n,t){return cn(n)?t(rn(r(n.error))):t(n)}}(n),new V(this,"mapError",[n]))},n.prototype.name=function(n){return this._name=n,this},n.prototype.onEnd=function(t){return void 0===t&&(t=U),this.subscribe(function(n){return n.isEnd?t():D})},n.prototype.onError=function(t){return void 0===t&&(t=j),this.subscribe(function(n){return cn(n)?t(n.error):D})},n.prototype.onValue=function(t){return void 0===t&&(t=j),this.subscribe(function(n){return fn(n)?t(n.value):D})},n.prototype.onValues=function(t){return this.onValue(function(n){return t.apply(void 0,n)})},n.prototype.reduce=function(n,t){return st(this,n,t)},n.prototype.sampledBy=function(n){return Kn(this,n,arguments[1])},n.prototype.scan=function(n,t){return vn(this,n,t)},n.prototype.skip=function(n){return function(n,r){return n.transform(function(n,t){return n.hasValue&&0<r?(r--,D):t(n)},new V(n,"skip",[r]))}(this,n)},n.prototype.skipDuplicates=function(n){return function(n,r){void 0===r&&(r=hn);var t=new V(n,"skipDuplicates",[]);return Q(R(),function(n,t){return fn(t)?t.isInitial||function(n){return null!=n&&n._isNone}(n)||!r(n.get(),t.value)?[new z(t.value),[t]]:[n,[]]:[n,[t]]},n).withDesc(t)}(this,n)},n.prototype.skipErrors=function(){return function(n){return n.transform(function(n,t){return cn(n)?D:t(n)},new V(n,"skipErrors",[]))}(this)},n.prototype.skipUntil=function(n){return function(n,t){var r=t.transform(tt(ln(1),Vn(!0))).toProperty().startWith(!1);return n.filter(r).withDesc(new V(n,"skipUntil",[t]))}(this,n)},n.prototype.skipWhile=function(n){return function(n,t){return rt(n,t,Dt,new V(n,"skipWhile",[t]))}(this,n)},n.prototype.slidingWindow=function(n,t){return void 0===t&&(t=0),function(n,r,t){return void 0===t&&(t=0),n.scan([],function(n,t){return n.concat([t]).slice(-r)}).filter(function(n){return n.length>=t}).withDesc(new V(n,"slidingWindow",[r,t]))}(this,n,t)},n.prototype.subscribe=function(n){var t=this;return void 0===n&&(n=j),L.wrappedSubscribe(this,function(n){return t.subscribeInternal(n)},n)},n.prototype.take=function(n){return pn(n,this)},n.prototype.takeUntil=function(n){return function(n,t){var r=zn([n.mapEnd(ct),t.skipErrors()],Ot);return n instanceof Mt&&(r=r.toProperty()),r.transform(function(n,t){if(fn(n)){var r=n.value,e=r[0];if(r[1].length)return t(en());for(var i=D,u=0;u<e.length;u++){var o=e[u];if(o===ct)return t(en());i=t(rn(o))}return i}return t(n)},new V(n,"takeUntil",[t]))}(this,n)},n.prototype.takeWhile=function(n){return function(n,t){return rt(n,t,St,new V(n,"takeWhile",[t]))}(this,n)},n.prototype.throttle=function(n){return function(n,t){return n.transformChanges(new V(n,"throttle",[t]),function(n){return n.bufferWithTime(t).map(function(n){return n[n.length-1]})})}(this,n)},n.prototype.toPromise=function(n){return function(n,t){return n.last().firstToPromise(t)}(this,n)},n.prototype.toString=function(){return this._name?this._name:this.desc.toString()},n.prototype.withDesc=function(n){return n&&(this.desc=n),this},n.prototype.withDescription=function(n,t){for(var r=[],e=2;e<arguments.length;e++)r[e-2]=arguments[e];return this.desc=q.apply(void 0,[n,t].concat(r)),this},n.prototype.zip=function(n,t){return function(n,t,r){return kt(r||Array,n,t).withDesc(new V(n,"zip",[t]))}(this,n,t)},n}(),Mt=function(i){function n(n,t,r){var e=i.call(this,n)||this;return e._isProperty=!0,e.dispatcher=new yt(e,t,r),lt(e),e}return o(n,i),n.prototype.and=function(n){return function(n,t){return n.combine(ut(t),function(n,t){return!(!n||!t)}).withDesc(new V(n,"and",[t]))}(this,n)},n.prototype.changes=function(){var n=this;return new Tt(new V(this,"changes",[]),function(t){return n.dispatcher.subscribe(function(n){return n.isInitial?D:t(n)})})},n.prototype.concat=function(t){return this.transformChanges(q(this,"concat",t),function(n){return n.concat(t)})},n.prototype.transformChanges=function(n,t){return function(n,t,r){var e,i,u=t(new Tt(q(n,"changes",[]),function(t){return n.dispatcher.subscribe(function(n){return!e&&sn(n)&&(e=n,L.whenDoneWith(o,function(){if(!i)throw new Error("Init sequence fail");i(e)})),n.isInitial?D:t(n)})},void 0,Ot)),o=bn(r,function(t){return i=t,u.dispatcher.subscribe(function(n){t(n)})});return o}(this,t,n)},n.prototype.flatMap=function(n){return ft(this,n)},n.prototype.flatMapConcat=function(n){return Xn(this,n)},n.prototype.flatMapError=function(n){return at(this,n)},n.prototype.flatMapEvent=function(n){return Sn(this,n)},n.prototype.flatMapFirst=function(n){return ot(this,n)},n.prototype.flatMapLatest=function(n){return vt(this,n)},n.prototype.flatMapWithConcurrencyLimit=function(n,t){return bt(this,n,t)},n.prototype.groupBy=function(n,t){return It(this,n,t)},n.prototype.map=function(n){return Ln(this,n)},n.prototype.not=function(){return it(this)},n.prototype.or=function(n){return function(n,t){return n.combine(ut(t),function(n,t){return n||t}).withDesc(new V(n,"or",[t]))}(this,n)},n.prototype.sample=function(n){return function(n,t){return Zn(n,Jn(t,{}),function(n,t){return n}).withDesc(new V(n,"sample",[t]))}(this,n)},n.prototype.startWith=function(n){return function(n,t){return n.scan(t,function(n,t){return t}).withDesc(new V(n,"startWith",[t]))}(this,n)},n.prototype.subscribeInternal=function(n){return void 0===n&&(n=j),this.dispatcher.subscribe(n)},n.prototype.toEventStream=function(n){var r=this;return new Tt(new V(this,"toEventStream",[]),function(t){return r.subscribeInternal(function(n){return t(n.toNext())})},void 0,n)},n.prototype.toProperty=function(){return this},n.prototype.transform=function(n,t){return nt(this,n,t)},n.prototype.withLatestFrom=function(n,t){return Nn(this,n,t)},n.prototype.withStateMachine=function(n,t){return Q(n,t,this)},n}(xt);function Wt(n){return!!n._isProperty}var Ot={forceAsync:!1},Tt=function(u){function n(n,t,r,e){var i=u.call(this,n)||this;return i._isEventStream=!0,e!==Ot&&(t=function(u,n){var o=!1;return function(e){var i,t=L.isInTransaction();function r(){var n=i||[];i=void 0;for(var t=0;t<n.length;t++){var r=n[t];e(r)}}o=!0;try{return n(function(n){return o||i?(i?i.push(n):(i=[n],t?L.soonButNotYet(u,r):A.scheduler.setTimeout(r,0)),D):e(n)})}finally{o=!1}}}(i,t)),i.dispatcher=new dt(i,t,r),lt(i),i}return o(n,u),n.prototype.bufferWithTime=function(n){return function(n,t){return wt(n,t,Number.MAX_VALUE).withDesc(new V(n,"bufferWithTime",[t]))}(this,n)},n.prototype.bufferWithCount=function(n){return function(n,t){return wt(n,void 0,t).withDesc(new V(n,"bufferWithCount",[t]))}(this,n)},n.prototype.bufferWithTimeOrCount=function(n,t){return wt(this,n,t)},n.prototype.changes=function(){return this},n.prototype.concat=function(n,t){return function(e,i,n){return new Tt(new V(e,"concat",[i]),function(t){var r=a,n=e.dispatcher.subscribe(function(n){return n.isEnd?(r=i.toEventStream().dispatcher.subscribe(t),D):t(n)});return function(){return n(),r()}},void 0,n)}(this,n,t)},n.prototype.transformChanges=function(n,t){return t(this).withDesc(n)},n.prototype.flatMap=function(n){return ft(this,n)},n.prototype.flatMapConcat=function(n){return Xn(this,n)},n.prototype.flatMapError=function(n){return at(this,n)},n.prototype.flatMapFirst=function(n){return ot(this,n)},n.prototype.flatMapLatest=function(n){return vt(this,n)},n.prototype.flatMapWithConcurrencyLimit=function(n,t){return bt(this,n,t)},n.prototype.flatMapEvent=function(n){return Sn(this,n)},n.prototype.flatScan=function(n,t){return function(n,t,r){var e=t;return n.flatMapConcat(function(n){return En(r(e,n)).doAction(function(n){return e=n})}).toProperty().startWith(t).withDesc(new V(n,"flatScan",[t,r]))}(this,n,t)},n.prototype.groupBy=function(n,t){return It(this,n,t)},n.prototype.map=function(n){return Ln(this,n)},n.prototype.merge=function(n){return gt(this,n).withDesc(new V(this,"merge",[n]))},n.prototype.not=function(){return it(this)},n.prototype.startWith=function(n){return function(n,t){return wn(t).concat(n).withDesc(new V(n,"startWith",[t]))}(this,n)},n.prototype.subscribeInternal=function(n){return void 0===n&&(n=j),this.dispatcher.subscribe(n)},n.prototype.toEventStream=function(){return this},n.prototype.toProperty=function(n){var t=arguments.length?function(n){return n&&(n._isSome||n._isNone)?n:new z(n)}(n):R(),r=this.dispatcher,e=new V(this,"toProperty",Array.prototype.slice.apply(arguments)),i=r.subscribe;return new Mt(e,yn(t,i))},n.prototype.transform=function(n,t){return function(n,r,t){return new Tt(new V(n,"transform",[r]),function(t){return n.subscribeInternal(function(n){return r(n,t)})},void 0,Ot).withDesc(t)}(this,n,t)},n.prototype.withLatestFrom=function(n,t){return Cn(this,n,t)},n.prototype.withStateMachine=function(n,t){return Q(n,t,this)},n}(xt);function Pt(n,t){return new Tt(n,t)}function Ct(n,t){return new Tt(n,t,void 0,Ot)}function Nt(n){return"undefined"!=typeof Symbol&&Symbol[n]?Symbol[n]:"undefined"!=typeof Symbol&&"function"==typeof Symbol.for?Symbol[n]=Symbol.for(n):"@@"+n}var Ft=function(){function n(n){this.observable=n}return n.prototype.subscribe=function(n,t,r){var e="function"==typeof n?{next:n,error:t,complete:r}:n,i={closed:!1,unsubscribe:function(){i.closed=!0,u()}},u=this.observable.subscribe(function(n){fn(n)&&e.next?e.next(n.value):cn(n)?(e.error&&e.error(n.error),i.unsubscribe()):n.isEnd&&(i.closed=!0,e.complete&&e.complete())});return i},n}();function Lt(r){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return function(n){return r.apply(void 0,[n].concat(t))}}}Ft.prototype[Nt("observable")]=function(){return this},xt.prototype.toESObservable=function(){return new Ft(this)},xt.prototype[Nt("observable")]=xt.prototype.toESObservable;var Vt=[["addEventListener","removeEventListener"],["addListener","removeListener"],["on","off"],["bind","unbind"]];function qt(t,r,n){var e=function(n){for(var t,r=0;r<Vt.length;r++){var e=[n[(t=Vt[r])[0]],n[t[1]]];if(e[0]&&e[1])return e}for(var i=0;i<Vt.length;i++){var u=n[(t=Vt[i])[0]];if(u)return[u,function(){}]}throw new Error("No suitable event methods in "+n)}(t),i=e[0],u=e[1],o=new V("Bacon","fromEvent",[t,r]);return $n(function(n){return function(n){return E.isFunction(n)}(r)?(r(i.bind(t),n),function(){return r(u.bind(t),n)}):(i.call(t,r,n),function(){return u.call(t,r,n)})},n).withDesc(o)}function jt(s){var c=0;return $n(function(t){var r=!1,e=D,i=function(){};function u(n){return n.isEnd?(r?o():r=!0,D):e=t(n)}function o(){var n;for(r=!0;r&&e!==I;)n=s(c++),r=!1,n?i=n.subscribeInternal(u):t(en());r=!0}return o(),function(){return i()}}).withDesc(new V("Bacon","repeat",[s]))}function Ut(n){return Et(n,"").filter(!1).withDesc(new V("Bacon","silence",[n]))}function Qt(n){return[un(n),en()]}var zt,Ht=(zt=function(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return E.isFunction(n)?t.length?function(r,e){return function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return r.apply(void 0,e.concat(n))}}(n,t):n:E.always(n)},function(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if("object"==typeof n&&t.length){var e=n,i=t[0];n=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return e[i].apply(e,n)},t=t.slice(1)}return zt.apply(void 0,[n].concat(t))});function Rt(n,t){return Ht.apply(void 0,[n].concat(t))}var Yt=function(n){function t(){var t=n.call(this,new V("Bacon","Bus",[]),function(n){return t.subscribeAll(n)})||this;return t.pushing=!1,t.pushQueue=void 0,t.ended=!1,t.subscriptions=[],t.unsubAll=E.bind(t.unsubAll,t),t.subscriptions=[],t.ended=!1,t}return o(t,n),t.prototype.plug=function(n){var t=this;if(!this.ended){var r={input:n,unsub:void 0};return this.subscriptions.push(r),void 0!==this.sink&&this.subscribeInput(r),function(){return t.unsubscribeInput(n)}}},t.prototype.end=function(){if(this.ended=!0,this.unsubAll(),"function"==typeof this.sink)return this.sink(en())},t.prototype.push=function(n){if(!this.ended&&"function"==typeof this.sink){var t=!this.pushing;if(!t)return this.pushQueue||(this.pushQueue=[]),void this.pushQueue.push(n);this.pushing=!0;try{return this.sink(rn(n))}finally{if(t&&this.pushQueue){for(var r=0;r<this.pushQueue.length;){var e=this.pushQueue[r];this.sink(rn(e)),r++}this.pushQueue=void 0}this.pushing=!1}}},t.prototype.error=function(n){if("function"==typeof this.sink)return this.sink(new nn(n))},t.prototype.unsubAll=function(){for(var n,t=this.subscriptions,r=0;r<t.length;r++)"function"==typeof(n=t[r]).unsub&&n.unsub()},t.prototype.subscribeAll=function(n){if(this.ended)n(en());else{this.sink=n;for(var t,r=this.subscriptions.slice(),e=0;e<r.length;e++)t=r[e],this.subscribeInput(t)}return this.unsubAll},t.prototype.guardedSink=function(t){var r=this;return function(n){return n.isEnd?(r.unsubscribeInput(t),I):r.sink?r.sink(n):D}},t.prototype.subscribeInput=function(n){return n.unsub=n.input.subscribeInternal(this.guardedSink(n.input)),n.unsub},t.prototype.unsubscribeInput=function(n){for(var t,r=this.subscriptions,e=0;e<r.length;e++)if((t=r[e]).input===n)return"function"==typeof t.unsub&&t.unsub(),void this.subscriptions.splice(e,1)},t}(Tt);var Xt={asEventStream:function(t,r,n){var e=this;return E.isFunction(r)&&(n=r,r=void 0),$n(function(n){return e.on(t,r,n),function(){return e.off(t,r,n)}},n).withDesc(new V(this.selector||this,"asEventStream",[t]))},init:function(n){n.fn.asEventStream=Xt.asEventStream}};n.$=Xt,n.Bus=Yt,n.CompositeUnsubscribe=dn,n.Desc=V,n.End=Z,n.Error=nn,n.Event=X,n.EventStream=Tt,n.Initial=J,n.Next=G,n.Observable=xt,n.Property=Mt,n.Value=$,n._=E,n.combine=Rn,n.combineAsArray=Hn,n.combineTemplate=_t,n.combineWith=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var e=Qn(arguments),i=(n=e[0],t=e[1],new V("Bacon","combineWith",[t].concat(n)));return Hn(n).map(function(n){return t.apply(void 0,n)}).withDesc(i)},n.concatAll=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];var r=jn(n);return(r.length?c(v(r),p(r).toEventStream(),function(n,t){return n.concat(t)}):Bn()).withDesc(new V("Bacon","concatAll",r))},n.constant=qn,n.fromArray=function(s){if(s.length){var c=0,f=new Tt(new V("Bacon","fromArray",[s]),function(r){var e=!1,i=D,u=!1,o=!1;return L.soonButNotYet(f,function n(){if(o=!0,!u){if(c===s.length)return r(en()),!1;for(u=!0;o;)if(o=!1,i!==I&&!e){var t=s[c++];(i=r(un(t)))!==I&&(c===s.length?r(en()):L.afterTransaction(f,n))}return u=!1}}),function(){return e=!0}});return f}return Bn().withDesc(new V("Bacon","fromArray",s))},n.fromBinder=$n,n.fromCallback=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return $n(function(n){return Rt(t,r)(n),a},function(n){return[n,en()]}).withDesc(new V("Bacon","fromCallback",[t].concat(r)))},n.fromESObservable=function(n){var r;r=n[Nt("observable")]?n[Nt("observable")]():n;var t=new V("Bacon","fromESObservable",[r]);return new Tt(t,function(t){var n=r.subscribe({error:function(n){t(new nn(n)),t(new Z)},next:function(n){t(new G(n))},complete:function(){t(new Z)}});return n.unsubscribe?function(){n.unsubscribe()}:n})},n.fromEvent=qt,n.fromEventTarget=qt,n.fromNodeCallback=function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];return $n(function(n){return Rt(t,r)(n),a},function(n,t){return n?[new nn(n),en()]:[t,en()]}).withDesc(new V("Bacon","fromNodeCallback",[t].concat(r)))},n.fromPoll=Gn,n.fromPromise=function(r,e,n){return void 0===n&&(n=Qt),$n(function(t){var n=r.then(t,function(n){return t(new nn(n))});return n&&"function"==typeof n.done&&n.done(),e?function(){if("function"==typeof r.abort)return r.abort()}:function(){}},n).withDesc(new V("Bacon","fromPromise",[r]))},n.getScheduler=function(){return A.scheduler},n.groupSimultaneous=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return zn(jn(n))},n.hasValue=fn,n.interval=Jn,n.isEnd=an,n.isError=cn,n.isEvent=on,n.isInitial=sn,n.isNext=function(n){return n.isNext},n.later=Et,n.mergeAll=gt,n.more=D,n.never=Bn,n.noMore=I,n.nullSink=j,n.nullVoidSink=U,n.onValues=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return Hn(n.slice(0,n.length-1)).onValues(n[arguments.length-1])},n.once=wn,n.repeat=jt,n.repeatedly=function(n,t){var r=0;return Gn(n,function(){return t[r++%t.length]}).withDesc(new V("Bacon","repeatedly",[n,t]))},n.retry=function(n){if(!E.isFunction(n.source))throw new Error("'source' option has to be a function");var i=n.source,u=n.retries||0,o=0,s=n.delay||function(){return 0},c=n.isRetryable||function(){return!0},f=!1,a=null;return jt(function(n){function t(){return i(n).endOnError().transform(function(n,t){return cn(n)?c((a=n).error)&&(0===u||o<u)?D:(f=!0,t(n)):(fn(n)&&(f=!(a=null)),t(n))})}if(!f){if(a){var r={error:a.error,retriesDone:o},e=Ut(s(r));return o++,e.concat(wn(null).flatMap(t))}return t()}}).withDesc(new V("Bacon","retry",[n]))},n.sequentially=function(n,t){var r=0;return Gn(n,function(){var n=t[r++];return r<t.length?n:r===t.length?[un(n),en()]:en()}).withDesc(new V("Bacon","sequentially",[n,t]))},n.setScheduler=function(n){A.scheduler=n},n.silence=Ut,n.spy=function(n){return ht.push(n)},n.try=function(t){return function(n){try{return wn(t(n))}catch(n){return wn(new nn(n))}}},n.update=function(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];for(var e=Tn(t),i=0;i<e.length;i++){var u=e[i];u[1]=Lt(u[1])}return xn.apply(void 0,e).scan(n,function(n,t){return t(n)}).withDesc(new V("Bacon","update",[n].concat(t)))},n.version="3.0.12",n.when=xn,n.zipAsArray=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return xn([E.map(function(n){return n.toEventStream()},jn(n)),function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return n}]).withDesc(new V("Bacon","zipAsArray",n))},n.zipWith=kt,Object.defineProperty(n,"__esModule",{value:!0})}); |
{ | ||
"name": "baconjs", | ||
"description": "A small functional reactive programming lib for JavaScript.", | ||
"version": "3.0.11", | ||
"version": "3.0.12", | ||
"keywords": [ | ||
@@ -79,3 +79,3 @@ "bacon.js", | ||
"prepublish": "npm run lint && npm run dist", | ||
"version": "3.0.11", | ||
"version": "3.0.12", | ||
"browsertest-bundle": "browsertest/browserify", | ||
@@ -82,0 +82,0 @@ "browsertest-open": "open browsertest/mocha.runner.html", |
@@ -123,3 +123,3 @@ /** | ||
*/ | ||
export declare function isInitial<V>(e: any): e is Initial<V>; | ||
export declare function isInitial<V>(e: Event<V>): e is Initial<V>; | ||
/** | ||
@@ -126,0 +126,0 @@ * Returns true if the given event is an [Error](classes/error.html) event of an [Observable](classes/observable.html). |
@@ -154,3 +154,3 @@ import { Desc } from "./describe"; | ||
/** @hidden */ | ||
abstract delayChanges(desc: Desc, f: EventStreamDelay<V>): this; | ||
abstract transformChanges(desc: Desc, f: EventStreamDelay<V>): this; | ||
/** | ||
@@ -752,3 +752,3 @@ * Returns the an array of dependencies that the Observable has. For instance, for `a.map(function() {}).deps()`, would return `[a]`. | ||
/** @hidden */ | ||
delayChanges(desc: Desc, f: EventStreamDelay<V>): this; | ||
transformChanges(desc: Desc, f: EventStreamDelay<V>): this; | ||
/** | ||
@@ -1005,3 +1005,3 @@ For each element in the source stream, spawn a new | ||
/** @hidden */ | ||
delayChanges(desc: Desc, f: EventStreamDelay<V>): this; | ||
transformChanges(desc: Desc, f: EventStreamDelay<V>): this; | ||
/** | ||
@@ -1008,0 +1008,0 @@ For each element in the source stream, spawn a new |
@@ -14,3 +14,3 @@ import { Event } from "./event"; | ||
export declare const nullVoidSink: VoidSink; | ||
export declare type Subscribe<T> = (arg: EventSink<T>) => any; | ||
export declare type Subscribe<T> = (arg: EventSink<T>) => Unsub; | ||
/** @hidden */ | ||
@@ -17,0 +17,0 @@ export declare type EventStreamDelay<V> = (stream: EventStream<V>) => EventStream<V>; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
717379
118
16593