text: (function(){var e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,C,k,L,A,O,M,_,D,P,H,B,j,F,I,q=[].slice,R={}.hasOwnProperty,U=function(e,t){function r(){this.constructor=e}for(var n in t)R.call(t,n)&&(e[n]=t[n]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e},z=function(e,t){return function(){return e.apply(t,arguments)}};(I=this.jQuery||this.Zepto)!=null&&(I.fn.asEventStream=function(t,n,r){var i;return r==null&&(r=F.id),x(n)&&(r=n,n=null),i=this,new o(function(s){var o,u;return o=function(){var t,n;t=1<=arguments.length?q.call(arguments,0):[],n=s(k(r.apply(null,t)));if(n===e.noMore)return u()},u=function(){return i.off(t,n,o)},i.on(t,n,o),u})}),e=this.Bacon={},e.fromPromise=function(e){return new o(function(t){var n,r;return r=function(e){return t(k(e)),t(g())},n=function(e){return t(new i(e)),t(g())},e.then(r,n),L})},e.noMore=["<no-more>"],e.more=["<more>"],e.later=function(t,n){return e.sequentially(t,[n])},e.sequentially=function(t,n){var r,i;return r=-1,i=function(){return r++,r<n.length?D(n[r]):g()},e.fromPoll(t,i)},e.repeatedly=function(t,n){var r,i;return r=-1,i=function(){return r++,D(n[r%n.length])},e.fromPoll(t,i)},e.fromCallback=function(){var e,t;return t=arguments[0],e=2<=arguments.length?q.call(arguments,1):[],t=N(t,e),new o(function(e){var n;return n=function(t){return e(k(t)),e(g())},t(n),L})},e.fromPoll=function(t,n){return new o(function(r){var i,s,o;return s=void 0,i=function(){var t,i;i=n(),t=r(i);if(t===e.noMore||i.isEnd())return o()},o=function(){return clearInterval(s)},s=setInterval(i,t),o})},e.fromEventTarget=function(t,n,r){return r==null&&(r=F.id),new o(function(i){var s,o;return s=function(){var t,n;t=1<=arguments.length?q.call(arguments,0):[],n=i(k(r.apply(null,t)));if(n===e.noMore)return o()},t.addEventListener?(o=function(){return t.removeEventListener(n,s,!1)},t.addEventListener(n,s,!1)):(o=function(){return t.removeListener(n,s)},t.addListener(n,s)),o})},e.interval=function(t,n){var r;return n==null&&(n={}),r=function(){return k(n)},e.fromPoll(t,r)},e.constant=function(e){return new c(M([e],w))},e.never=function(){return e.fromArray([])},e.once=function(t){return e.fromArray([t])},e.fromArray=function(e){return new o(M(e,k))},M=function(e,t){return function(n){var r,i,s;for(i=0,s=e.length;i<s;i++)r=e[i],n(t(r));return n(g()),L}},e.combineAll=function(e,t){var n,r,i,s,o;r=F.head(e),o=F.tail(e);for(i=0,s=o.length;i<s;i++)n=o[i],r=t(r,n);return r},e.mergeAll=function(t){return e.combineAll(t,function(e,t){return e.merge(t)})},e.combineAsArray=function(){var t,n,r,i,s,o,u;i=arguments[0],t=2<=arguments.length?q.call(arguments,1):[],i instanceof Array||(i=[i].concat(t));if(i.length){r=F.head(i).toProperty().map(function(e){return[e]}),u=F.tail(i);for(s=0,o=u.length;s<o;s++)n=u[s],r=r.combine(n,function(e,t){return e.concat([t])});return r}return e.constant([])},e.combineWith=function(t,n){return e.combineAll(t,function(e,t){return e.toProperty().combine(t,n)})},e.combineTemplate=function(t){var n,r,i,s,o,u,a,f,c,h;return a=[],h=[],u=function(e){return e[e.length-1]},c=function(e,t,n){return u(e)[t]=n},n=function(e,t){return function(n,r){return c(n,e,r[t])}},o=function(e,t){return function(n,r){return c(n,e,t)}},f=function(e){return e instanceof Array?[]:{}},i=function(e,t){var r,i;return t instanceof l?(h.push(t),a.push(n(e,h.length-1))):typeof t=="object"?(i=function(e){return function(n,r){var i;return i=f(t),c(n,e,i),n.push(i)}},r=function(e,t){return e.pop()},a.push(i(e)),s(t),a.push(r)):a.push(o(e,t))},s=function(e){return F.each(e,i)},s(t),r=function(e){var n,r,i,s,o;i=f(t),n=[i];for(s=0,o=a.length;s<o;s++)r=a[s],r(n,e);return i},e.combineAsArray(h).map(r)},s=function(){function e(){}return e.prototype.isEvent=function(){return!0},e.prototype.isEnd=function(){return!1},e.prototype.isInitial=function(){return!1},e.prototype.isNext=function(){return!1},e.prototype.isError=function(){return!1},e.prototype.hasValue=function(){return!1},e.prototype.filter=function(e){return!0},e.prototype.getOriginalEvent=function(){return this.sourceEvent!=null?this.sourceEvent.getOriginalEvent():this},e.prototype.onDone=function(e){return e()},e}(),a=function(e){function t(e,t){this.value=x(e)?e:F.always(e)}return U(t,e),t.prototype.isNext=function(){return!0},t.prototype.hasValue=function(){return!0},t.prototype.fmap=function(e){return this.apply(e(this.value()))},t.prototype.apply=function(e){return k(e,this.getOriginalEvent())},t.prototype.filter=function(e){return e(this.value())},t.prototype.describe=function(){return this.value()},t}(s),u=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return U(t,e),t.prototype.isInitial=function(){return!0},t.prototype.isNext=function(){return!1},t.prototype.apply=function(e){return w(e,this.getOriginalEvent())},t.prototype.toNext=function(){return new a(this.value,this.getOriginalEvent())},t}(a),r=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return U(t,e),t.prototype.isEnd=function(){return!0},t.prototype.fmap=function(){return this},t.prototype.apply=function(){return this},t.prototype.describe=function(){return"<end>"},t}(s),i=function(e){function t(e){this.error=e}return U(t,e),t.prototype.isError=function(){return!0},t.prototype.fmap=function(){return this},t.prototype.apply=function(){return this},t.prototype.describe=function(){return"<error> "+this.error},t}(s),l=function(){function t(){this.flatMapLatest=z(this.flatMapLatest,this),this.scan=z(this.scan,this),this.takeUntil=z(this.takeUntil,this),this.assign=this.onValue}return t.prototype.onValue=function(){var e,t;return t=arguments[0],e=2<=arguments.length?q.call(arguments,1):[],t=N(t,e),this.subscribe(function(e){if(e.hasValue())return t(e.value())})},t.prototype.onValues=function(e){return this.onValue(function(t){return e.apply(null,t)})},t.prototype.onError=function(){var e,t;return t=arguments[0],e=2<=arguments.length?q.call(arguments,1):[],t=N(t,e),this.subscribe(function(e){if(e.isError())return t(e.error)})},t.prototype.onEnd=function(){var e,t;return t=arguments[0],e=2<=arguments.length?q.call(arguments,1):[],t=N(t,e),this.subscribe(function(e){if(e.isEnd())return t()})},t.prototype.errors=function(){return this.filter(function(){return!1})},t.prototype.filter=function(){var t,n;return n=arguments[0],t=2<=arguments.length?q.call(arguments,1):[],n=N(n,t),this.withHandler(function(t){return t.filter(n)?this.push(t):e.more})},t.prototype.takeWhile=function(){var t,n;return n=arguments[0],t=2<=arguments.length?q.call(arguments,1):[],n=N(n,t),this.withHandler(function(t){return t.filter(n)?this.push(t):(this.push(g()),e.noMore)})},t.prototype.endOnError=function(){return this.withHandler(function(e){return e.isError()?(this.push(e),this.push(g())):this.push(e)})},t.prototype.take=function(t){return this.withHandler(function(n){return n.hasValue()?t===1?(this.push(n),this.push(g()),e.noMore):(t--,this.push(n)):this.push(n)})},t.prototype.map=function(){var e,t;return t=arguments[0],e=2<=arguments.length?q.call(arguments,1):[],t=N(t,e),this.withHandler(function(e){return this.push(e.fmap(t))})},t.prototype.mapError=function(){var e,t;return t=arguments[0],e=2<=arguments.length?q.call(arguments,1):[],t=N(t,e),this.withHandler(function(e){return e.isError()?this.push(k(t(e.error))):this.push(e)})},t.prototype.doAction=function(){var e,t;return t=arguments[0],e=2<=arguments.length?q.call(arguments,1):[],t=N(t,e),this.withHandler(function(e){return e.hasValue()&&t(e.value()),this.push(e)})},t.prototype.takeUntil=function(t){var n;return n=this,this.withSubscribe(function(r){var i,s,o,u,a,f;return f=!1,u=L,a=L,o=function(){return u(),a(),f=!0},i=function(t){return t.isEnd()?(a(),r(t),e.noMore):(t.getOriginalEvent().onDone(function(){var n;if(!f){n=r(t);if(n===e.noMore)return o()}}),e.more)},s=function(t){return t.isError()?e.more:t.isEnd()?e.noMore:(u(),r(g()),e.noMore)},u=n.subscribe(i),f||(a=t.subscribe(s)),o})},t.prototype.skip=function(t){return this.withHandler(function(n){return n.hasValue()?t>0?(t--,e.more):this.push(n):this.push(n)})},t.prototype.distinctUntilChanged=function(){return this.skipDuplicates()},t.prototype.skipDuplicates=function(e){return e==null&&(e=function(e,t){return e===t}),this.withStateMachine(f,function(t,n){return n.hasValue()?t===f||!e(t.get(),n.value())?[new p(n.value()),[n]]:[t,[]]:[t,[n]]})},t.prototype.withStateMachine=function(t,n){var r;return r=t,this.withHandler(function(t){var i,s,o,u,a,f,l;i=n(r,t),s=i[0],u=i[1],r=s,a=e.more;for(f=0,l=u.length;f<l;f++){o=u[f],a=this.push(o);if(a===e.noMore)return a}return a})},t.prototype.scan=function(t,n){var r,i,s=this;return n=_(n),r=B(t),i=function(t){var i,o;return i=!1,o=s.subscribe(function(s){return s.hasValue()?i&&s.isInitial()?e.more:(i=!0,r=new p(n(r.getOrElse(void 0),s.value())),t(s.apply(r.get()))):(s.isEnd()&&(i=!0),t(s))}),i||r.forEach(function(n){var r;r=t(w(n));if(r===e.noMore)return o(),o=L}),o},new c((new h(i)).subscribe)},t.prototype.diff=function(e,t){return t=_(t),this.scan([e],function(e,n){return[n,t(e[0],n)]}).filter(function(e){return e.length===2}).map(function(e){return e[1]})},t.prototype.flatMap=function(t){var n;return n=this,new o(function(r){var i,s,o,a,f,l;return s=[],o=!1,l=function(){},f=function(){var e,t,n;l();for(t=0,n=s.length;t<n;t++)e=s[t],e();return s=[]},i=function(){if(o&&s.length===0)return r(g())},a=function(n){var a,l,c,h,p;if(n.isEnd())return o=!0,i();if(n.isError())return r(n);a=t(n.value()),p=void 0,l=!1,h=function(){return p!=null&&O(p,s),i()},c=function(t){var n;return t.isEnd()?(h(),l=!0,e.noMore):(t instanceof u&&(t=t.toNext()),n=r(t),n===e.noMore&&f(),n)},p=a.subscribe(c);if(!l)return s.push(p)},l=n.subscribe(a),f})},t.prototype.flatMapLatest=function(e){var t,n=this;return t=this.toEventStream(),t.flatMap(function(n){return e(n).takeUntil(t)})},t.prototype.not=function(){return this.map(function(e){return!e})},t.prototype.log=function(){return this.subscribe(function(e){return console.log(e.describe())}),this},t.prototype.slidingWindow=function(e){return this.scan([],function(t,n){return t.concat([n]).slice(-e)})},t}(),o=function(t){function r(e){var t;r.__super__.constructor.call(this),t=new n(e),this.subscribe=t.subscribe,this.hasSubscribers=t.hasSubscribers}return U(r,t),r.prototype.map=function(){var e,t;return t=arguments[0],e=2<=arguments.length?q.call(arguments,1):[],t instanceof c?t.sampledBy(this,y):r.__super__.map.apply(this,[t].concat(q.call(e)))},r.prototype.filter=function(){var e,t;return t=arguments[0],e=2<=arguments.length?q.call(arguments,1):[],t instanceof c?t.sampledBy(this,function(e,t){return[e,t]}).filter(function(e){var t,n;return t=e[0],n=e[1],t}).map(function(e){var t,n;return t=e[0],n=e[1],n}):r.__super__.filter.apply(this,[t].concat(q.call(e)))},r.prototype.delay=function(t){return this.flatMap(function(n){return e.later(t,n)})},r.prototype.throttle=function(t){return this.flatMapLatest(function(n){return e.later(t,n)})},r.prototype.bufferWithTime=function(t){var n,r,i,s;return s=[],i=function(e){return s.push(e),s.length===1},r=function(){var e;return e=s,s=[],e},n=function(){return e.later(t).map(r)},this.filter(i).flatMap(n)},r.prototype.bufferWithCount=function(e){var t;return t=[],this.withHandler(function(n){var r,i=this;r=function(){return i.push(k(t,n)),t=[]};if(n.isError())return this.push(n);if(n.isEnd())return r(),this.push(n);t.push(n.value());if(t.length===e)return r()})},r.prototype.merge=function(t){var n;return n=this,new r(function(r){var i,s,o,u,a,f;return u=L,a=L,f=!1,o=function(){return u(),a(),f=!0},i=0,s=function(t){var n;return t.isEnd()?(i++,i===2?r(g()):e.more):(n=r(t),n===e.noMore&&o(),n)},u=n.subscribe(s),f||(a=t.subscribe(s)),o})},r.prototype.toProperty=function(e){return arguments.length===0&&(e=f),this.scan(e,T)},r.prototype.toEventStream=function(){return this},r.prototype.concat=function(e){var t;return t=this,new r(function(n){var r;return r=t.subscribe(function(t){return t.isEnd()?r=e.subscribe(n):n(t)}),function(){return r()}})},r.prototype.awaiting=function(e){return this.map(!0).merge(e.map(!1)).toProperty(!1)},r.prototype.startWith=function(t){return e.once(t).concat(this)},r.prototype.mapEnd=function(){var t,n;return n=arguments[0],t=2<=arguments.length?q.call(arguments,1):[],n=N(n,t),this.withHandler(function(t){return t.isEnd()?(this.push(k(n(t))),this.push(g()),e.noMore):this.push(t)})},r.prototype.withHandler=function(e){var t;return t=new n(this.subscribe,e),new r(t.subscribe)},r.prototype.withSubscribe=function(e){return new r(e)},r}(l),c=function(t){function n(t){var r,i=this;this.subscribe=t,this.toEventStream=z(this.toEventStream,this),this.toProperty=z(this.toProperty,this),this.changes=z(this.changes,this),this.sample=z(this.sample,this),n.__super__.constructor.call(this),r=function(t,r,s){var o,u;return o=f,u=f,new n(function(n){var a,f,l,c,h,d,v,m,y,b,w;return w=!1,y=L,b=L,m=function(){return y(),b(),w=!0},c=!1,d=!1,a=function(){var t;if(c&&d)return t=n(g()),t===e.noMore&&m(),t},l=!1,f=function(t,r,i){return function(s){var f;return s.isEnd()?(t(),a(),e.noMore):s.isError()?(f=n(s),f===e.noMore&&m(),f):(r(new p(s.value())),o.isDefined&&u.isDefined?l&&s.isInitial()?e.more:(l=!0,f=i(n,s,o.value,u.value),f===e.noMore&&m(),f):e.more)}},h=f(function(){return c=!0},function(e){return o=e},r),v=f(function(){return d=!0},function(e){return u=e},s),y=i.subscribe(h),w||(b=t.subscribe(v)),m})},this.combine=function(e,t){var n,i;return n=_(t),i=function(e,t,r,i){return e(t.apply(n(r,i)))},r(e,i,i)},this.sampledBy=function(e,t){var n;return t==null&&(t=y),t=_(t),n=function(e,n,r,i){return e(n.apply(t(r,i)))},r(e,L,n).changes().takeUntil(e.filter(!1).mapEnd())}}return U(n,t),n.prototype.sample=function(t){return this.sampledBy(e.interval(t,{}))},n.prototype.changes=function(){var e=this;return new o(function(t){return e.subscribe(function(e){if(!e.isInitial())return t(e)})})},n.prototype.withHandler=function(e){return new n((new h(this.subscribe,e)).subscribe)},n.prototype.withSubscribe=function(e){return new n((new h(e)).subscribe)},n.prototype.toProperty=function(){return this},n.prototype.toEventStream=function(){var e=this;return new o(function(t){return e.subscribe(function(e){return e.isInitial()&&(e=e.toNext()),t(e)})})},n.prototype.and=function(e){return this.combine(e,function(e,t){return e&&t})},n.prototype.or=function(e){return this.combine(e,function(e,t){return e||t})},n.prototype.decode=function(t){return this.combine(e.combineTemplate(t),function(e,t){return t[e]})},n.prototype.delay=function(e){return d(this,this.changes().delay(e))},n.prototype.throttle=function(e){return d(this,this.changes().throttle(e))},n}(l),d=function(t,n){var r;return r=function(t){var n;return n=f,t.subscribe(function(t){return t.isInitial()&&(n=new p(t.value())),e.noMore}),n},n.toProperty(r(t))},n=function(){function t(t,n){var r,i,o,u,a=this;t==null&&(t=function(){return L}),o=[],r=!1,this.hasSubscribers=function(){return o.length>0},u=L,i=function(e){return O(e,o)},this.push=function(t){var n,r,u,f,l,c,h;f=void 0,n=function(){var e,n,r,i;if(f!=null){n=f,f=void 0;for(r=0,i=n.length;r<i;r++)e=n[r],e()}return t.onDone=s.prototype.onDone},t.onDone=function(e){return f!=null&&!F.contains(f,e)?f.push(e):f=[e]},h=v(o);for(l=0,c=h.length;l<c;l++)u=h[l],r=u(t),(r===e.noMore||t.isEnd())&&i(u);return n(),a.hasSubscribers()?e.more:e.noMore},n==null&&(n=function(e){return this.push(e)}),this.handleEvent=function(e){return e.isEnd()&&(r=!0),n.apply(a,[e])},this.subscribe=function(e){return r?(e(g()),L):(o.push(e),o.length===1&&(u=t(a.handleEvent)),function(){i(e);if(!a.hasSubscribers())return u()})}}return t}(),h=function(t){function n(t,r){var i,s,o,u=this;n.__super__.constructor.call(this,t,r),i=f,o=this.push,t=this.subscribe,s=!1,this.push=function(e){return e.isEnd()&&(s=!0),e.hasValue()&&(i=new p(e.value())),o.apply(u,[e])},this.subscribe=function(n){var r,o,a;return r=!1,a=function(){return u.hasSubscribers()||s},o=i.filter(a).map(function(e){return n(w(e))}),o.getOrElse(e.more)===e.noMore?L:s?(n(g()),L):t.apply(u,[n])}}return U(n,t),n}(n),t=function(t){function r(){var t,s,o,u,a,f,l,c,h,p,d=this;u=void 0,c=[],s=!1,o=function(t){return function(n){return n.isEnd()?(p(t),e.noMore):u(n)}},h=function(){var e,t,n;for(t=0,n=c.length;t<n;t++)e=c[t],e.unsub!=null&&e.unsub();return c=[]},f=function(e){return e.unsub=e.input.subscribe(o(e.input))},p=function(e){var t,n,r,i;for(t=r=0,i=c.length;r<i;t=++r){n=c[t];if(n.input===e){n.unsub!=null&&n.unsub(),c.splice(t,1);return}}},a=function(e){var t,n,r,i,s;u=e,n=[],s=v(c);for(r=0,i=s.length;r<i;r++)t=s[r],f(t);return h},t=new n(a),l=function(e){return t.subscribe(e)},r.__super__.constructor.call(this,l),this.plug=function(e){var t;if(s)return;return t={input:e},c.push(t),u!=null&&f(t),function(){return p(e)}},this.push=function(e){if(u!=null)return u(k(e))},this.error=function(e){if(u!=null)return u(new i(e))},this.end=function(){s=!0,h();if(u!=null)return u(g())}}return U(r,t),r}(o),p=function(){function e(e){this.value=e}return e.prototype.getOrElse=function(){return this.value},e.prototype.get=function(){return this.value},e.prototype.filter=function(t){return t(this.value)?new e(this.value):f},e.prototype.map=function(t){return new e(t(this.value))},e.prototype.forEach=function(e){return e(this.value)},e.prototype.isDefined=!0,e.prototype.toArray=function(){return[this.value]},e}(),f={getOrElse:function(e){return e},filter:function(){return f},map:function(){return f},forEach:function(){},isDefined:!1,toArray:function(){return[]}},e.EventStream=o,e.Property=c,e.Observable=l,e.Bus=t,e.Initial=u,e.Next=a,e.End=r,e.Error=i,L=function(){},T=function(e,t){return t},y=function(e,t){return e},w=function(e){return new u(F.always(e))},k=function(e){return new a(F.always(e))},g=function(){return new r},E=function(e){return e!=null&&e.isEvent!=null&&e.isEvent()},D=function(e){return E(e)?e:k(e)},v=function(e){return e.slice(0)},m=function(e){var t,n,r;t={};for(n in e)r=e[n],t[n]=r;return t},b=Array.prototype.indexOf?function(e,t){return e.indexOf(t)}:function(e,t){var n,r,i,s;for(n=i=0,s=e.length;i<s;n=++i){r=e[n];if(t===r)return n}return-1},O=function(e,t){var n;n=b(t,e);if(n>=0)return t.splice(n,1)},x=function(e){return typeof e=="function"},C=function(e,t,n){return n===void 0&&(n=[]),function(r){return e[t].apply(e,n.concat([r]))}},A=function(e,t){return function(n){return e.apply(null,t.concat([n]))}},N=function(e,t){return x(e)?t.length?A(e,t):e:S(e)?P(e,t):typeof e=="object"&&t.length?C(e,F.head(t),F.tail(t)):F.always(e)},S=function(e){return typeof e=="string"&&e.length>1&&e[0]==="."},P=function(e,t){var n,r;return r=e.slice(1).split("."),n=F.map(j(t),r),function(t){var r,i;for(r=0,i=n.length;r<i;r++)e=n[r],t=e(t);return t}},j=function(e){return function(t){return function(n){var r;return r=n[t],x(r)?r.apply(n,e):r}}},H=function(e){return e.slice(1)},_=function(e){var t;if(x(e))return e;if(S(e))return t=H(e),function(e,n){return e[t](n)}},B=function(e){return e instanceof p||e===f?e:new p(e)},typeof define!="undefined"&&define!==null&&define.amd!=null&&typeof define=="function"&&define(function(){return e}),F={head:function(e){return e[0]},always:function(e){return function(){return e}},empty:function(e){return e.length===0},tail:function(e){return e.slice(1,e.length)},filter:function(e,t){var n,r,i,s;n=[];for(i=0,s=t.length;i<s;i++)r=t[i],e(r)&&n.push(r);return n},map:function(e,t){var n,r,i,s;s=[];for(r=0,i=t.length;r<i;r++)n=t[r],s.push(e(n));return s},each:function(e,t){var n,r,i;i=[];for(n in e)r=e[n],i.push(t(n,r));return i},contains:function(e,t){return b(e,t)!==-1},id:function(e){return e},last:function(e){return e[e.length-1]}},e._=F}).call(this);