!function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L={}.hasOwnProperty,M=function(a,b){function c(){this.constructor=a}for(var d in b)L.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},N=[].slice,O=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1},P=this;"undefined"==typeof exports?this.rx=z={}:z=exports,w=0,v=function(){return w+=1},x=function(a,b){var c;if(!b in a)throw"object has no key "+b;return c=a[b],delete a[b],c},t=function(){return Object.create(null)},k=z.Recorder=function(){function a(){this.stack=[]}return a.prototype.start=function(a){return this.stack.push(a)},a.prototype.stop=function(){return this.stack.pop()},a.prototype.sub=function(a){var b,c;return this.stack.length>0?(c=_(this.stack).last(),b=a(c),c.addSub(b)):void 0},a.prototype.warnMutate=function(){return this.stack.length>0?console.warn("Mutation to observable detected during a bind context"):void 0},a}(),y=new k,z.bind=o=function(a){var b;return b=z.depCell(a),b.refresh(),b},z.lagBind=s=function(a,b){var c;return c=z.lagDepCell(b,a),c.refresh(),c},c=z.DepMgr=function(){function a(){this.uid2src={}}return a.prototype.sub=function(a,b){return this.uid2src[a]=b},a.prototype.unsub=function(a){return this.uid2src[a].unsub(a),x(this.uid2src,a)},a}(),p=new c,e=z.Ev=function(){function a(a){this.inits=a,this.subs=[]}return a.prototype.sub=function(a){var b,c,d,e,f;if(c=v(),null!=this.inits)for(f=this.inits(),d=0,e=f.length;e>d;d++)b=f[d],a(b);return this.subs[c]=a,p.sub(c,this),c},a.prototype.pub=function(a){var b,c,d,e;d=this.subs,e=[];for(c in d)b=d[c],e.push(b(a));return e},a.prototype.unsub=function(a){return x(this.subs,a)},a}(),h=z.ObsCell=function(){function a(a){var b,c=this;this.x=a,this.x=null!=(b=this.x)?b:null,this.onSet=new e(function(){return[[null,c.x]]})}return a.prototype.get=function(){var a=this;return y.sub(function(b){return a.onSet.sub(function(){return b.refresh()})}),this.x},a}(),m=z.SrcCell=function(a){function b(){return H=b.__super__.constructor.apply(this,arguments)}return M(b,a),b.prototype.set=function(a){var b;return y.warnMutate(),b=this.x,this.x=a,this.onSet.pub([b,a]),b},b}(h),b=z.DepCell=function(a){function b(a,c,d){this.body=a,b.__super__.constructor.call(this,null!=c?c:null),this.subs=[],this.refreshing=!1,this.lag=null!=d?d:!1,this.timeout=null}return M(b,a),b.prototype.refresh=function(){var a,b=this;return a=function(){var a,c,d,e,f;if(!b.refreshing){for(a=b.x,f=b.subs,d=0,e=f.length;e>d;d++)c=f[d],p.unsub(c);b.subs=[],y.start(b),b.refreshing=!0;try{b.x=b.body()}finally{b.refreshing=!1,y.stop()}return b.onSet.pub([a,b.x])}},this.refreshing?void 0:this.lag?(null!=this.timeout&&clearTimeout(this.timeout),console.log("setting timeout"),this.timeout=setTimeout(a,500)):a()},b.prototype.addSub=function(a){return this.subs.push(a)},b}(h),g=z.ObsArray=function(){function a(a){var b,c=this;this.xs=a,this.xs=null!=(b=this.xs)?b:[],this.onChange=new e(function(){return[[0,[],c.xs]]})}return a.prototype.all=function(){var a=this;return y.sub(function(b){return a.onChange.sub(function(){return b.refresh()})}),this.xs},a.prototype.at=function(a){var b=this;return y.sub(function(c){return b.onChange.sub(function(b){var d,e,f;return e=b[0],f=b[1],d=b[2],e===a?c.refresh():void 0})}),this.xs[a]},a.prototype.length=function(){var a=this;return y.sub(function(b){return a.onChange.sub(function(a){var c,d,e;return d=a[0],e=a[1],c=a[2],e.length!==c.length?b.refresh():void 0})}),this.xs.length},a.prototype.map=function(a){var b;return b=new f,this.onChange.sub(function(c){var d,e,f;return e=c[0],f=c[1],d=c[2],b.realSplice(e,f.length,d.map(a))}),b},a.prototype.realSplice=function(a,b,c){var d;return d=this.xs.splice.apply(this.xs,[a,b].concat(c)),this.onChange.pub([a,d,c])},a}(),l=z.SrcArray=function(a){function b(){return I=b.__super__.constructor.apply(this,arguments)}return M(b,a),b.prototype.spliceArray=function(a,b,c){return y.warnMutate(),this.realSplice(a,b,c)},b.prototype.splice=function(){var a,b,c;return c=arguments[0],b=arguments[1],a=3<=arguments.length?N.call(arguments,2):[],this.spliceArray(c,b,a)},b.prototype.insert=function(a,b){return this.splice(b,0,a)},b.prototype.remove=function(a){return this.removeAt(_(this.all()).indexOf(a))},b.prototype.removeAt=function(a){return this.splice(a,1)},b.prototype.push=function(a){return this.splice(this.length(),0,a)},b.prototype.put=function(a,b){return this.splice(a,1,b)},b.prototype.replace=function(a){return this.spliceArray(0,this.length(),a)},b}(g),f=z.MappedDepArray=function(a){function b(){return J=b.__super__.constructor.apply(this,arguments)}return M(b,a),b}(g),a=z.DepArray=function(a){function c(a){this.f=a,c.__super__.constructor.call(this),new b(this.f).onSet.sub(function(a){var b,c,d,e,f,g,h;return e=a[0],f=a[1],g=firstWhere(function(){h=[];for(var a=0,b=Math.min(e.length,f.length);b>=0?b>=a:a>=b;b>=0?a++:a--)h.push(a);return h}.apply(this),function(a){return e[a]!==f[a]}),d=g[0],d=g[1],d>-1?(c=e.length-d,b=f.slice(d),this.realSplice(d,c,b)):void 0})}return M(c,a),c}(g),i=z.ObsMap=function(){function a(a){this.x=null!=a?a:{},this.onAdd=new e(function(){var b,c,d;d=[];for(b in a)c=a[b],d.push([b,c]);return d}),this.onRemove=new e,this.onChange=new e}return a.prototype.get=function(a){var b=this;return y.sub(function(c){return b.onChange.sub(function(b){var d,e,f;return e=b[0],d=b[1],f=b[2],a===e?c.refresh():void 0})}),this.x[a]},a.prototype.all=function(){var a=this;return y.sub(function(b){return a.onChange.sub(function(){return b.refresh()})}),_.clone(this.x)},a.prototype.realPut=function(a,b){var c;return O.call(this.x,a)>=0?(c=this.x[a],this.x[a]=b,this.onChange.pub([a,c,b]),c):(this.x[a]=b,this.onAdd.pub([a,b]),void 0)},a.prototype.realRemove=function(a){var b;return b=x(this.x,a),this.onRemove.pub([a,b]),b},a}(),n=z.SrcMap=function(a){function b(){return K=b.__super__.constructor.apply(this,arguments)}return M(b,a),b.prototype.put=function(a,b){return y.warnMutate(),this.realPut(a,b)},b.prototype.remove=function(a){return y.warnMutate(),this.realRemove(a)},b}(i),d=z.DepMap=function(a){function c(a){this.f=a,c.__super__.constructor.call(this),new b(this.f).onSet.sub(function(a){var b,c,d,e,f;c=a[0],e=a[1];for(b in c)d=c[b],!b in e&&this.realRemove(b);f=[];for(b in e)d=e[b],this.x[b]!==d?f.push(this.realPut(b,d)):f.push(void 0);return f})}return M(c,a),c}(i),_.extend(z,{cell:function(a){return new m(a)},array:function(a){return new l(a)},map:function(a){return new n(a)},depCell:function(a){return new b(a)},lagDepCell:function(a,c){return new b(a,c,!0)},depMap:function(a){return new DepMap(a)},depArray:function(b){return new a(b)}}),$.fn.rx=function(a){var b,c,d,e;return d=this.data("rx-map"),null==d&&this.data("rx-map",d=t()),a in d?d[a]:d[a]=function(){var d=this;switch(a){case"focused":return c=z.cell(this.is(":focus")),this.focus(function(){return c.set(!0)}),this.blur(function(){return c.set(!1)}),c;case"val":return e=z.cell(this.val()),this.change(function(){return e.set(d.val())}),this.on("input",function(){return e.set(d.val())}),e;case"checked":return b=z.cell(this.is(":checked")),this.change(function(){return b.set(d.is(":checked"))}),b;default:throw"Unknown reactive property type"}}.call(this)},"undefined"==typeof exports?this.rxt=A={}:A=exports,j=A.RawHtml=function(){function a(a){this.html=a}return a}(),r=["blur","change","click","dblclick","error","focus","focusin","focusout","hover","keydown","keypress","keyup","load","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","ready","resize","scroll","select","submit","toggle","unload"],B=A.specialAttrs={init:function(a,b){return b.call(a)}},E=function(a){return B[a]=function(b,c){return b[a](function(a){return c.call(b,a)})}};for(F=0,G=r.length;G>F;F++)q=r[F],E(q);A.mktag=u=function(a){return function(b,c){var d,e,f,i,k,l,m,n,o;n=null==b&&null==c?[{},null]:null!=c?[b,c]:_.isString(b)||b instanceof j||_.isArray(b)||b instanceof h||b instanceof g?[{},b]:[b,null],d=n[0],e=n[1],f=$("<"+a+"/>"),o=_.omit(d,_.keys(B));for(k in o)m=o[k],m instanceof h?function(a){return m.onSet.sub(function(b){var c,d;return c=b[0],d=b[1],f.attr(a,d)})}(k):f.attr(k,m);null!=e&&(l=function(a){var b,c,d,e;if(f.html(""),_.isArray(a)){for(e=[],c=0,d=a.length;d>c;c++)b=a[c],_.isString(b)?b=$("").text(b):b instanceof j&&(b=$("").html(b.html)),e.push(f.append(b));return e}if(_.isString(a)||a instanceof j)return l([a]);throw"Unknown type for contents: "+a.constructor.name},e instanceof g?e.onChange.sub(function(a){var b,c,d,e,g;return d=a[0],e=a[1],b=a[2],f.children().slice(d,d+e.length).remove(),g=$(function(){var a,d,e;for(e=[],a=0,d=b.length;d>a;a++)c=b[a],e.push(c.get(0));return e}()),d===f.children().length?f.append(g):f.children().slice(d,d+1).before(g)}):e instanceof h?e.onSet.sub(function(a){var b,c;return b=a[0],c=a[1],l(c)}):l(e));for(i in d)i in B&&B[i](f,d[i],d,e);return f}},D=["html","head","title","base","link","meta","style","script","noscript","body","body","section","nav","article","aside","h1","h2","h3","h4","h5","h6","h1","h6","header","footer","address","main","main","p","hr","pre","blockquote","ol","ul","li","dl","dt","dd","dd","figure","figcaption","div","a","em","strong","small","s","cite","q","dfn","abbr","data","time","code","var","samp","kbd","sub","sup","i","b","u","mark","ruby","rt","rp","bdi","bdo","span","br","wbr","ins","del","img","iframe","embed","object","param","object","video","audio","source","video","audio","track","video","audio","canvas","map","area","area","map","svg","math","table","caption","colgroup","col","tbody","thead","tfoot","tr","td","th","form","fieldset","legend","fieldset","label","input","button","select","datalist","optgroup","option","select","datalist","textarea","keygen","output","progress","meter","details","summary","details","menuitem","menu"],A.tags=_.object(function(){var a,b,c;for(c=[],a=0,b=D.length;b>a;a++)C=D[a],c.push([C,A.mktag(C)]);return c}()),A.rawHtml=function(a){return new j(a)},A.importTags=function(a){return _(null!=a?a:P).extend(A.tags)}}.call(this);