// Compiled by ClojureScript 1.9.562 {}
goog.provide('rum.core');
goog.require('cljs.core');
goog.require('sablono.core');
goog.require('rum.cursor');
goog.require('rum.util');
goog.require('rum.derived_atom');
/**
 * Given React component, returns Rum state associated with it
 */
rum.core.state = (function rum$core$state(comp){
return (comp.state[":rum/state"]);
});
rum.core.build_class = (function rum$core$build_class(render,mixins,display_name){
var init = rum.util.collect.call(null,new cljs.core.Keyword(null,"init","init",-1875481434),mixins);
var will_mount = rum.util.collect_STAR_.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"will-mount","will-mount",-434633071),new cljs.core.Keyword(null,"before-render","before-render",71256781)], null),mixins);
var render__$1 = render;
var wrap_render = rum.util.collect.call(null,new cljs.core.Keyword(null,"wrap-render","wrap-render",1782000986),mixins);
var wrapped_render = cljs.core.reduce.call(null,((function (init,will_mount,render__$1,wrap_render){
return (function (p1__38037_SHARP_,p2__38036_SHARP_){
return p2__38036_SHARP_.call(null,p1__38037_SHARP_);
});})(init,will_mount,render__$1,wrap_render))
,render__$1,wrap_render);
var did_mount = rum.util.collect_STAR_.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"did-mount","did-mount",918232960),new cljs.core.Keyword(null,"after-render","after-render",1997533433)], null),mixins);
var did_remount = rum.util.collect.call(null,new cljs.core.Keyword(null,"did-remount","did-remount",1362550500),mixins);
var should_update = rum.util.collect.call(null,new cljs.core.Keyword(null,"should-update","should-update",-1292781795),mixins);
var will_update = rum.util.collect_STAR_.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"will-update","will-update",328062998),new cljs.core.Keyword(null,"before-render","before-render",71256781)], null),mixins);
var did_update = rum.util.collect_STAR_.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"did-update","did-update",-2143702256),new cljs.core.Keyword(null,"after-render","after-render",1997533433)], null),mixins);
var will_unmount = rum.util.collect.call(null,new cljs.core.Keyword(null,"will-unmount","will-unmount",-808051550),mixins);
var child_context = rum.util.collect.call(null,new cljs.core.Keyword(null,"child-context","child-context",-1375270295),mixins);
var class_props = cljs.core.reduce.call(null,cljs.core.merge,rum.util.collect.call(null,new cljs.core.Keyword(null,"class-properties","class-properties",1351279702),mixins));
return React.createClass(cljs.core.clj__GT_js.call(null,rum.util.filter_vals.call(null,cljs.core.some_QMARK_,cljs.core.merge.call(null,cljs.core.PersistentHashMap.fromArrays([new cljs.core.Keyword(null,"componentDidUpdate","componentDidUpdate",-1983477981),new cljs.core.Keyword(null,"displayName","displayName",-809144601),new cljs.core.Keyword(null,"componentWillUnmount","componentWillUnmount",1573788814),new cljs.core.Keyword(null,"componentWillReceiveProps","componentWillReceiveProps",559988974),new cljs.core.Keyword(null,"shouldComponentUpdate","shouldComponentUpdate",1795750960),new cljs.core.Keyword(null,"render","render",-1408033454),new cljs.core.Keyword(null,"getChildContext","getChildContext",-1321948108),new cljs.core.Keyword(null,"componentWillUpdate","componentWillUpdate",657390932),new cljs.core.Keyword(null,"getInitialState","getInitialState",1541760916),new cljs.core.Keyword(null,"componentDidMount","componentDidMount",955710936),new cljs.core.Keyword(null,"componentWillMount","componentWillMount",-285327619)],[((cljs.core.empty_QMARK_.call(null,did_update))?null:((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (_,___$1){
var this$ = this;
return cljs.core._vreset_BANG_.call(null,rum.core.state.call(null,this$),rum.util.call_all.call(null,cljs.core._deref.call(null,rum.core.state.call(null,this$)),did_update));
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
),display_name,((cljs.core.empty_QMARK_.call(null,will_unmount))?null:((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (){
var this$ = this;
return cljs.core._vreset_BANG_.call(null,rum.core.state.call(null,this$),rum.util.call_all.call(null,cljs.core._deref.call(null,rum.core.state.call(null,this$)),will_unmount));
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
),((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (next_props){
var this$ = this;
var old_state = cljs.core.deref.call(null,rum.core.state.call(null,this$));
var state = cljs.core.merge.call(null,old_state,(next_props[":rum/initial-state"]));
var next_state = cljs.core.reduce.call(null,((function (old_state,state,this$,init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (p1__38039_SHARP_,p2__38038_SHARP_){
return p2__38038_SHARP_.call(null,old_state,p1__38039_SHARP_);
});})(old_state,state,this$,init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
,state,did_remount);
return this$.setState(({":rum/state": cljs.core.volatile_BANG_.call(null,next_state)}));
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
,((cljs.core.empty_QMARK_.call(null,should_update))?null:((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (next_props,next_state){
var this$ = this;
var old_state = cljs.core.deref.call(null,rum.core.state.call(null,this$));
var new_state = cljs.core.deref.call(null,(next_state[":rum/state"]));
var or__23338__auto__ = cljs.core.some.call(null,((function (old_state,new_state,this$,init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (p1__38040_SHARP_){
return p1__38040_SHARP_.call(null,old_state,new_state);
});})(old_state,new_state,this$,init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
,should_update);
if(cljs.core.truth_(or__23338__auto__)){
return or__23338__auto__;
} else {
return false;
}
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
),((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (){
var this$ = this;
var state = rum.core.state.call(null,this$);
var vec__38045 = wrapped_render.call(null,cljs.core.deref.call(null,state));
var dom = cljs.core.nth.call(null,vec__38045,(0),null);
var next_state = cljs.core.nth.call(null,vec__38045,(1),null);
cljs.core.vreset_BANG_.call(null,state,next_state);

return dom;
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
,((cljs.core.empty_QMARK_.call(null,child_context))?null:((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (){
var this$ = this;
var state = cljs.core.deref.call(null,rum.core.state.call(null,this$));
return cljs.core.clj__GT_js.call(null,cljs.core.transduce.call(null,cljs.core.map.call(null,((function (state,this$,init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (p1__38041_SHARP_){
return p1__38041_SHARP_.call(null,state);
});})(state,this$,init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
),cljs.core.merge,cljs.core.PersistentArrayMap.EMPTY,child_context));
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
),((cljs.core.empty_QMARK_.call(null,will_update))?null:((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (_,next_state){
var this$ = this;
var new_state = (next_state[":rum/state"]);
return cljs.core._vreset_BANG_.call(null,new_state,rum.util.call_all.call(null,cljs.core._deref.call(null,new_state),will_update));
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
),((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (){
var this$ = this;
var props = this$.props;
var state = rum.util.call_all.call(null,cljs.core.assoc.call(null,(props[":rum/initial-state"]),new cljs.core.Keyword("rum","react-component","rum/react-component",-1879897248),this$),init,props);
return ({":rum/state": cljs.core.volatile_BANG_.call(null,state)});
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
,((cljs.core.empty_QMARK_.call(null,did_mount))?null:((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (){
var this$ = this;
return cljs.core._vreset_BANG_.call(null,rum.core.state.call(null,this$),rum.util.call_all.call(null,cljs.core._deref.call(null,rum.core.state.call(null,this$)),did_mount));
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
),((cljs.core.empty_QMARK_.call(null,will_mount))?null:((function (init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props){
return (function (){
var this$ = this;
return cljs.core._vreset_BANG_.call(null,rum.core.state.call(null,this$),rum.util.call_all.call(null,cljs.core._deref.call(null,rum.core.state.call(null,this$)),will_mount));
});})(init,will_mount,render__$1,wrap_render,wrapped_render,did_mount,did_remount,should_update,will_update,did_update,will_unmount,child_context,class_props))
)]),class_props))));
});
rum.core.build_ctor = (function rum$core$build_ctor(render,mixins,display_name){
var class$ = rum.core.build_class.call(null,render,mixins,display_name);
var key_fn = cljs.core.first.call(null,rum.util.collect.call(null,new cljs.core.Keyword(null,"key-fn","key-fn",-636154479),mixins));
var ctor = ((!((key_fn == null)))?((function (class$,key_fn){
return (function() { 
var G__38048__delegate = function (args){
var props = ({":rum/initial-state": new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword("rum","args","rum/args",1315791754),args], null), "key": cljs.core.apply.call(null,key_fn,args)});
return React.createElement(class$,props);
};
var G__38048 = function (var_args){
var args = null;
if (arguments.length > 0) {
var G__38049__i = 0, G__38049__a = new Array(arguments.length -  0);
while (G__38049__i < G__38049__a.length) {G__38049__a[G__38049__i] = arguments[G__38049__i + 0]; ++G__38049__i;}
  args = new cljs.core.IndexedSeq(G__38049__a,0,null);
} 
return G__38048__delegate.call(this,args);};
G__38048.cljs$lang$maxFixedArity = 0;
G__38048.cljs$lang$applyTo = (function (arglist__38050){
var args = cljs.core.seq(arglist__38050);
return G__38048__delegate(args);
});
G__38048.cljs$core$IFn$_invoke$arity$variadic = G__38048__delegate;
return G__38048;
})()
;})(class$,key_fn))
:((function (class$,key_fn){
return (function() { 
var G__38051__delegate = function (args){
var props = ({":rum/initial-state": new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword("rum","args","rum/args",1315791754),args], null)});
return React.createElement(class$,props);
};
var G__38051 = function (var_args){
var args = null;
if (arguments.length > 0) {
var G__38052__i = 0, G__38052__a = new Array(arguments.length -  0);
while (G__38052__i < G__38052__a.length) {G__38052__a[G__38052__i] = arguments[G__38052__i + 0]; ++G__38052__i;}
  args = new cljs.core.IndexedSeq(G__38052__a,0,null);
} 
return G__38051__delegate.call(this,args);};
G__38051.cljs$lang$maxFixedArity = 0;
G__38051.cljs$lang$applyTo = (function (arglist__38053){
var args = cljs.core.seq(arglist__38053);
return G__38051__delegate(args);
});
G__38051.cljs$core$IFn$_invoke$arity$variadic = G__38051__delegate;
return G__38051;
})()
;})(class$,key_fn))
);
return cljs.core.with_meta.call(null,ctor,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword("rum","class","rum/class",-2030775258),class$], null));
});
rum.core.build_defc = (function rum$core$build_defc(render_body,mixins,display_name){
if(cljs.core.empty_QMARK_.call(null,mixins)){
var class$ = (function (props){
return cljs.core.apply.call(null,render_body,(props[":rum/args"]));
});
var _ = (class$["displayName"] = display_name);
var ctor = ((function (class$,_){
return (function() { 
var G__38054__delegate = function (args){
return React.createElement(class$,({":rum/args": args}));
};
var G__38054 = function (var_args){
var args = null;
if (arguments.length > 0) {
var G__38055__i = 0, G__38055__a = new Array(arguments.length -  0);
while (G__38055__i < G__38055__a.length) {G__38055__a[G__38055__i] = arguments[G__38055__i + 0]; ++G__38055__i;}
  args = new cljs.core.IndexedSeq(G__38055__a,0,null);
} 
return G__38054__delegate.call(this,args);};
G__38054.cljs$lang$maxFixedArity = 0;
G__38054.cljs$lang$applyTo = (function (arglist__38056){
var args = cljs.core.seq(arglist__38056);
return G__38054__delegate(args);
});
G__38054.cljs$core$IFn$_invoke$arity$variadic = G__38054__delegate;
return G__38054;
})()
;})(class$,_))
;
return cljs.core.with_meta.call(null,ctor,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword("rum","class","rum/class",-2030775258),class$], null));
} else {
var render = (function (state){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.apply.call(null,render_body,new cljs.core.Keyword("rum","args","rum/args",1315791754).cljs$core$IFn$_invoke$arity$1(state)),state], null);
});
return rum.core.build_ctor.call(null,render,mixins,display_name);
}
});
rum.core.build_defcs = (function rum$core$build_defcs(render_body,mixins,display_name){
var render = (function (state){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.apply.call(null,render_body,state,new cljs.core.Keyword("rum","args","rum/args",1315791754).cljs$core$IFn$_invoke$arity$1(state)),state], null);
});
return rum.core.build_ctor.call(null,render,mixins,display_name);
});
rum.core.build_defcc = (function rum$core$build_defcc(render_body,mixins,display_name){
var render = (function (state){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.apply.call(null,render_body,new cljs.core.Keyword("rum","react-component","rum/react-component",-1879897248).cljs$core$IFn$_invoke$arity$1(state),new cljs.core.Keyword("rum","args","rum/args",1315791754).cljs$core$IFn$_invoke$arity$1(state)),state], null);
});
return rum.core.build_ctor.call(null,render,mixins,display_name);
});
rum.core.schedule = (function (){var or__23338__auto__ = (function (){var and__23326__auto__ = typeof window !== 'undefined';
if(and__23326__auto__){
var or__23338__auto__ = window.requestAnimationFrame;
if(cljs.core.truth_(or__23338__auto__)){
return or__23338__auto__;
} else {
var or__23338__auto____$1 = window.webkitRequestAnimationFrame;
if(cljs.core.truth_(or__23338__auto____$1)){
return or__23338__auto____$1;
} else {
var or__23338__auto____$2 = window.mozRequestAnimationFrame;
if(cljs.core.truth_(or__23338__auto____$2)){
return or__23338__auto____$2;
} else {
return window.msRequestAnimationFrame;
}
}
}
} else {
return and__23326__auto__;
}
})();
if(cljs.core.truth_(or__23338__auto__)){
return or__23338__auto__;
} else {
return ((function (or__23338__auto__){
return (function (p1__38057_SHARP_){
return setTimeout(p1__38057_SHARP_,(16));
});
;})(or__23338__auto__))
}
})();
rum.core.batch = (function (){var or__23338__auto__ = ((typeof ReactNative !== 'undefined')?ReactNative.unstable_batchedUpdates:null);
if(cljs.core.truth_(or__23338__auto__)){
return or__23338__auto__;
} else {
var or__23338__auto____$1 = ((typeof ReactDOM !== 'undefined')?ReactDOM.unstable_batchedUpdates:null);
if(cljs.core.truth_(or__23338__auto____$1)){
return or__23338__auto____$1;
} else {
return ((function (or__23338__auto____$1,or__23338__auto__){
return (function (f,a){
return f.call(null,a);
});
;})(or__23338__auto____$1,or__23338__auto__))
}
}
})();
rum.core.empty_queue = cljs.core.PersistentVector.EMPTY;
rum.core.render_queue = cljs.core.volatile_BANG_.call(null,rum.core.empty_queue);
rum.core.render_all = (function rum$core$render_all(queue){
var seq__38064 = cljs.core.seq.call(null,queue);
var chunk__38066 = null;
var count__38067 = (0);
var i__38068 = (0);
while(true){
if((i__38068 < count__38067)){
var comp = cljs.core._nth.call(null,chunk__38066,i__38068);
if(cljs.core.truth_(comp.isMounted())){
comp.forceUpdate();

var G__38070 = seq__38064;
var G__38071 = chunk__38066;
var G__38072 = count__38067;
var G__38073 = (i__38068 + (1));
seq__38064 = G__38070;
chunk__38066 = G__38071;
count__38067 = G__38072;
i__38068 = G__38073;
continue;
} else {
var G__38074 = seq__38064;
var G__38075 = chunk__38066;
var G__38076 = count__38067;
var G__38077 = (i__38068 + (1));
seq__38064 = G__38074;
chunk__38066 = G__38075;
count__38067 = G__38076;
i__38068 = G__38077;
continue;
}
} else {
var temp__5278__auto__ = cljs.core.seq.call(null,seq__38064);
if(temp__5278__auto__){
var seq__38064__$1 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__38064__$1)){
var c__24249__auto__ = cljs.core.chunk_first.call(null,seq__38064__$1);
var G__38078 = cljs.core.chunk_rest.call(null,seq__38064__$1);
var G__38079 = c__24249__auto__;
var G__38080 = cljs.core.count.call(null,c__24249__auto__);
var G__38081 = (0);
seq__38064 = G__38078;
chunk__38066 = G__38079;
count__38067 = G__38080;
i__38068 = G__38081;
continue;
} else {
var comp = cljs.core.first.call(null,seq__38064__$1);
if(cljs.core.truth_(comp.isMounted())){
comp.forceUpdate();

var G__38082 = cljs.core.next.call(null,seq__38064__$1);
var G__38083 = null;
var G__38084 = (0);
var G__38085 = (0);
seq__38064 = G__38082;
chunk__38066 = G__38083;
count__38067 = G__38084;
i__38068 = G__38085;
continue;
} else {
var G__38086 = cljs.core.next.call(null,seq__38064__$1);
var G__38087 = null;
var G__38088 = (0);
var G__38089 = (0);
seq__38064 = G__38086;
chunk__38066 = G__38087;
count__38067 = G__38088;
i__38068 = G__38089;
continue;
}
}
} else {
return null;
}
}
break;
}
});
rum.core.render = (function rum$core$render(){
var queue = cljs.core.deref.call(null,rum.core.render_queue);
cljs.core.vreset_BANG_.call(null,rum.core.render_queue,rum.core.empty_queue);

return rum.core.batch.call(null,rum.core.render_all,queue);
});
/**
 * Schedules react component to be rendered on next animation frame
 */
rum.core.request_render = (function rum$core$request_render(component){
if(cljs.core.empty_QMARK_.call(null,cljs.core.deref.call(null,rum.core.render_queue))){
rum.core.schedule.call(null,rum.core.render);
} else {
}

return cljs.core._vreset_BANG_.call(null,rum.core.render_queue,cljs.core.conj.call(null,cljs.core._deref.call(null,rum.core.render_queue),component));
});
/**
 * Add component to the DOM tree. Idempotent. Subsequent mounts will just update component
 */
rum.core.mount = (function rum$core$mount(component,node){
ReactDOM.render(component,node);

return null;
});
/**
 * Removes component from the DOM tree
 */
rum.core.unmount = (function rum$core$unmount(node){
return ReactDOM.unmountComponentAtNode(node);
});
/**
 * Adds React key to component
 */
rum.core.with_key = (function rum$core$with_key(component,key){
return React.cloneElement(component,({"key": key}),null);
});
/**
 * Adds React ref (string or callback) to component
 */
rum.core.with_ref = (function rum$core$with_ref(component,ref){
return React.cloneElement(component,({"ref": ref}),null);
});
/**
 * Given state, returns top-level DOM node. Can’t be called during render
 */
rum.core.dom_node = (function rum$core$dom_node(state){
return ReactDOM.findDOMNode(new cljs.core.Keyword("rum","react-component","rum/react-component",-1879897248).cljs$core$IFn$_invoke$arity$1(state));
});
/**
 * Given state and ref handle, returns React component
 */
rum.core.ref = (function rum$core$ref(state,key){
return ((new cljs.core.Keyword("rum","react-component","rum/react-component",-1879897248).cljs$core$IFn$_invoke$arity$1(state)["refs"])[cljs.core.name.call(null,key)]);
});
/**
 * Given state and ref handle, returns DOM node associated with ref
 */
rum.core.ref_node = (function rum$core$ref_node(state,key){
return ReactDOM.findDOMNode(rum.core.ref.call(null,state,cljs.core.name.call(null,key)));
});
/**
 * Mixin. Will avoid re-render if none of component’s arguments have changed.
 * Does equality check (=) on all arguments
 */
rum.core.static$ = new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"should-update","should-update",-1292781795),(function (old_state,new_state){
return cljs.core.not_EQ_.call(null,new cljs.core.Keyword("rum","args","rum/args",1315791754).cljs$core$IFn$_invoke$arity$1(old_state),new cljs.core.Keyword("rum","args","rum/args",1315791754).cljs$core$IFn$_invoke$arity$1(new_state));
})], null);
/**
 * Mixin constructor. Adds an atom to component’s state that can be used to keep stuff
 * during component’s lifecycle. Component will be re-rendered if atom’s value changes.
 * Atom is stored under user-provided key or under `:rum/local` by default
 */
rum.core.local = (function rum$core$local(var_args){
var args38090 = [];
var len__24559__auto___38093 = arguments.length;
var i__24560__auto___38094 = (0);
while(true){
if((i__24560__auto___38094 < len__24559__auto___38093)){
args38090.push((arguments[i__24560__auto___38094]));

var G__38095 = (i__24560__auto___38094 + (1));
i__24560__auto___38094 = G__38095;
continue;
} else {
}
break;
}

var G__38092 = args38090.length;
switch (G__38092) {
case 1:
return rum.core.local.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));

break;
case 2:
return rum.core.local.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));

break;
default:
throw (new Error([cljs.core.str.cljs$core$IFn$_invoke$arity$1("Invalid arity: "),cljs.core.str.cljs$core$IFn$_invoke$arity$1(args38090.length)].join('')));

}
});

rum.core.local.cljs$core$IFn$_invoke$arity$1 = (function (initial){
return rum.core.local.call(null,initial,new cljs.core.Keyword("rum","local","rum/local",-1497916586));
});

rum.core.local.cljs$core$IFn$_invoke$arity$2 = (function (initial,key){
return new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"will-mount","will-mount",-434633071),(function (state){
var local_state = cljs.core.atom.call(null,initial);
var component = new cljs.core.Keyword("rum","react-component","rum/react-component",-1879897248).cljs$core$IFn$_invoke$arity$1(state);
cljs.core.add_watch.call(null,local_state,key,((function (local_state,component){
return (function (_,___$1,___$2,___$3){
return rum.core.request_render.call(null,component);
});})(local_state,component))
);

return cljs.core.assoc.call(null,state,key,local_state);
})], null);
});

rum.core.local.cljs$lang$maxFixedArity = 2;

/**
 * Mixin. Works in conjunction with `rum.core/react`
 */
rum.core.reactive = new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"init","init",-1875481434),(function (state,props){
return cljs.core.assoc.call(null,state,new cljs.core.Keyword("rum.reactive","key","rum.reactive/key",-803425142),cljs.core.random_uuid.call(null));
}),new cljs.core.Keyword(null,"wrap-render","wrap-render",1782000986),(function (render_fn){
return (function (state){
var _STAR_reactions_STAR_38097 = rum.core._STAR_reactions_STAR_;
rum.core._STAR_reactions_STAR_ = cljs.core.volatile_BANG_.call(null,cljs.core.PersistentHashSet.EMPTY);

try{var comp = new cljs.core.Keyword("rum","react-component","rum/react-component",-1879897248).cljs$core$IFn$_invoke$arity$1(state);
var old_reactions = new cljs.core.Keyword("rum.reactive","refs","rum.reactive/refs",-814076325).cljs$core$IFn$_invoke$arity$2(state,cljs.core.PersistentHashSet.EMPTY);
var vec__38098 = render_fn.call(null,state);
var dom = cljs.core.nth.call(null,vec__38098,(0),null);
var next_state = cljs.core.nth.call(null,vec__38098,(1),null);
var new_reactions = cljs.core.deref.call(null,rum.core._STAR_reactions_STAR_);
var key = new cljs.core.Keyword("rum.reactive","key","rum.reactive/key",-803425142).cljs$core$IFn$_invoke$arity$1(state);
var seq__38101_38113 = cljs.core.seq.call(null,old_reactions);
var chunk__38102_38114 = null;
var count__38103_38115 = (0);
var i__38104_38116 = (0);
while(true){
if((i__38104_38116 < count__38103_38115)){
var ref_38117 = cljs.core._nth.call(null,chunk__38102_38114,i__38104_38116);
if(cljs.core.contains_QMARK_.call(null,new_reactions,ref_38117)){
} else {
cljs.core.remove_watch.call(null,ref_38117,key);
}

var G__38118 = seq__38101_38113;
var G__38119 = chunk__38102_38114;
var G__38120 = count__38103_38115;
var G__38121 = (i__38104_38116 + (1));
seq__38101_38113 = G__38118;
chunk__38102_38114 = G__38119;
count__38103_38115 = G__38120;
i__38104_38116 = G__38121;
continue;
} else {
var temp__5278__auto___38122 = cljs.core.seq.call(null,seq__38101_38113);
if(temp__5278__auto___38122){
var seq__38101_38123__$1 = temp__5278__auto___38122;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__38101_38123__$1)){
var c__24249__auto___38124 = cljs.core.chunk_first.call(null,seq__38101_38123__$1);
var G__38125 = cljs.core.chunk_rest.call(null,seq__38101_38123__$1);
var G__38126 = c__24249__auto___38124;
var G__38127 = cljs.core.count.call(null,c__24249__auto___38124);
var G__38128 = (0);
seq__38101_38113 = G__38125;
chunk__38102_38114 = G__38126;
count__38103_38115 = G__38127;
i__38104_38116 = G__38128;
continue;
} else {
var ref_38129 = cljs.core.first.call(null,seq__38101_38123__$1);
if(cljs.core.contains_QMARK_.call(null,new_reactions,ref_38129)){
} else {
cljs.core.remove_watch.call(null,ref_38129,key);
}

var G__38130 = cljs.core.next.call(null,seq__38101_38123__$1);
var G__38131 = null;
var G__38132 = (0);
var G__38133 = (0);
seq__38101_38113 = G__38130;
chunk__38102_38114 = G__38131;
count__38103_38115 = G__38132;
i__38104_38116 = G__38133;
continue;
}
} else {
}
}
break;
}

var seq__38105_38134 = cljs.core.seq.call(null,new_reactions);
var chunk__38106_38135 = null;
var count__38107_38136 = (0);
var i__38108_38137 = (0);
while(true){
if((i__38108_38137 < count__38107_38136)){
var ref_38138 = cljs.core._nth.call(null,chunk__38106_38135,i__38108_38137);
if(cljs.core.contains_QMARK_.call(null,old_reactions,ref_38138)){
} else {
cljs.core.add_watch.call(null,ref_38138,key,((function (seq__38105_38134,chunk__38106_38135,count__38107_38136,i__38108_38137,ref_38138,comp,old_reactions,vec__38098,dom,next_state,new_reactions,key,_STAR_reactions_STAR_38097){
return (function (_,___$1,___$2,___$3){
return rum.core.request_render.call(null,comp);
});})(seq__38105_38134,chunk__38106_38135,count__38107_38136,i__38108_38137,ref_38138,comp,old_reactions,vec__38098,dom,next_state,new_reactions,key,_STAR_reactions_STAR_38097))
);
}

var G__38139 = seq__38105_38134;
var G__38140 = chunk__38106_38135;
var G__38141 = count__38107_38136;
var G__38142 = (i__38108_38137 + (1));
seq__38105_38134 = G__38139;
chunk__38106_38135 = G__38140;
count__38107_38136 = G__38141;
i__38108_38137 = G__38142;
continue;
} else {
var temp__5278__auto___38143 = cljs.core.seq.call(null,seq__38105_38134);
if(temp__5278__auto___38143){
var seq__38105_38144__$1 = temp__5278__auto___38143;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__38105_38144__$1)){
var c__24249__auto___38145 = cljs.core.chunk_first.call(null,seq__38105_38144__$1);
var G__38146 = cljs.core.chunk_rest.call(null,seq__38105_38144__$1);
var G__38147 = c__24249__auto___38145;
var G__38148 = cljs.core.count.call(null,c__24249__auto___38145);
var G__38149 = (0);
seq__38105_38134 = G__38146;
chunk__38106_38135 = G__38147;
count__38107_38136 = G__38148;
i__38108_38137 = G__38149;
continue;
} else {
var ref_38150 = cljs.core.first.call(null,seq__38105_38144__$1);
if(cljs.core.contains_QMARK_.call(null,old_reactions,ref_38150)){
} else {
cljs.core.add_watch.call(null,ref_38150,key,((function (seq__38105_38134,chunk__38106_38135,count__38107_38136,i__38108_38137,ref_38150,seq__38105_38144__$1,temp__5278__auto___38143,comp,old_reactions,vec__38098,dom,next_state,new_reactions,key,_STAR_reactions_STAR_38097){
return (function (_,___$1,___$2,___$3){
return rum.core.request_render.call(null,comp);
});})(seq__38105_38134,chunk__38106_38135,count__38107_38136,i__38108_38137,ref_38150,seq__38105_38144__$1,temp__5278__auto___38143,comp,old_reactions,vec__38098,dom,next_state,new_reactions,key,_STAR_reactions_STAR_38097))
);
}

var G__38151 = cljs.core.next.call(null,seq__38105_38144__$1);
var G__38152 = null;
var G__38153 = (0);
var G__38154 = (0);
seq__38105_38134 = G__38151;
chunk__38106_38135 = G__38152;
count__38107_38136 = G__38153;
i__38108_38137 = G__38154;
continue;
}
} else {
}
}
break;
}

return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [dom,cljs.core.assoc.call(null,next_state,new cljs.core.Keyword("rum.reactive","refs","rum.reactive/refs",-814076325),new_reactions)], null);
}finally {rum.core._STAR_reactions_STAR_ = _STAR_reactions_STAR_38097;
}});
}),new cljs.core.Keyword(null,"will-unmount","will-unmount",-808051550),(function (state){
var key_38155 = new cljs.core.Keyword("rum.reactive","key","rum.reactive/key",-803425142).cljs$core$IFn$_invoke$arity$1(state);
var seq__38109_38156 = cljs.core.seq.call(null,new cljs.core.Keyword("rum.reactive","refs","rum.reactive/refs",-814076325).cljs$core$IFn$_invoke$arity$1(state));
var chunk__38110_38157 = null;
var count__38111_38158 = (0);
var i__38112_38159 = (0);
while(true){
if((i__38112_38159 < count__38111_38158)){
var ref_38160 = cljs.core._nth.call(null,chunk__38110_38157,i__38112_38159);
cljs.core.remove_watch.call(null,ref_38160,key_38155);

var G__38161 = seq__38109_38156;
var G__38162 = chunk__38110_38157;
var G__38163 = count__38111_38158;
var G__38164 = (i__38112_38159 + (1));
seq__38109_38156 = G__38161;
chunk__38110_38157 = G__38162;
count__38111_38158 = G__38163;
i__38112_38159 = G__38164;
continue;
} else {
var temp__5278__auto___38165 = cljs.core.seq.call(null,seq__38109_38156);
if(temp__5278__auto___38165){
var seq__38109_38166__$1 = temp__5278__auto___38165;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__38109_38166__$1)){
var c__24249__auto___38167 = cljs.core.chunk_first.call(null,seq__38109_38166__$1);
var G__38168 = cljs.core.chunk_rest.call(null,seq__38109_38166__$1);
var G__38169 = c__24249__auto___38167;
var G__38170 = cljs.core.count.call(null,c__24249__auto___38167);
var G__38171 = (0);
seq__38109_38156 = G__38168;
chunk__38110_38157 = G__38169;
count__38111_38158 = G__38170;
i__38112_38159 = G__38171;
continue;
} else {
var ref_38172 = cljs.core.first.call(null,seq__38109_38166__$1);
cljs.core.remove_watch.call(null,ref_38172,key_38155);

var G__38173 = cljs.core.next.call(null,seq__38109_38166__$1);
var G__38174 = null;
var G__38175 = (0);
var G__38176 = (0);
seq__38109_38156 = G__38173;
chunk__38110_38157 = G__38174;
count__38111_38158 = G__38175;
i__38112_38159 = G__38176;
continue;
}
} else {
}
}
break;
}

return cljs.core.dissoc.call(null,state,new cljs.core.Keyword("rum.reactive","refs","rum.reactive/refs",-814076325),new cljs.core.Keyword("rum.reactive","key","rum.reactive/key",-803425142));
})], null);
/**
 * Works in conjunction with `rum.core/reactive` mixin. Use this function instead of
 * `deref` inside render, and your component will subscribe to changes happening
 * to the derefed atom.
 */
rum.core.react = (function rum$core$react(ref){
if(cljs.core.truth_(rum.core._STAR_reactions_STAR_)){
} else {
throw (new Error([cljs.core.str.cljs$core$IFn$_invoke$arity$1("Assert failed: "),cljs.core.str.cljs$core$IFn$_invoke$arity$1("rum.core/react is only supported in conjunction with rum.core/reactive"),cljs.core.str.cljs$core$IFn$_invoke$arity$1("\n"),cljs.core.str.cljs$core$IFn$_invoke$arity$1("*reactions*")].join('')));
}

cljs.core._vreset_BANG_.call(null,rum.core._STAR_reactions_STAR_,cljs.core.conj.call(null,cljs.core._deref.call(null,rum.core._STAR_reactions_STAR_),ref));

return cljs.core.deref.call(null,ref);
});
/**
 * Use this to create “chains” and acyclic graphs of dependent atoms.
 * `derived-atom` will:
 *  - Take N “source” refs
 *  - Set up a watch on each of them
 *  - Create “sink” atom
 *  - When any of source refs changes:
 *     - re-run function `f`, passing N dereferenced values of source refs
 *     - `reset!` result of `f` to the sink atom
 *  - return sink atom
 * 
 *  (def *a (atom 0))
 *  (def *b (atom 1))
 *  (def *x (derived-atom [*a *b] ::key
 *            (fn [a b]
 *              (str a ":" b))))
 *  (type *x) ;; => clojure.lang.Atom
 *  \@*x     ;; => 0:1
 *  (swap! *a inc)
 *  \@*x     ;; => 1:1
 *  (reset! *b 7)
 *  \@*x     ;; => 1:7
 * 
 * Arguments:
 *   refs - sequence of source refs
 *   key  - unique key to register watcher, see `clojure.core/add-watch`
 *   f    - function that must accept N arguments (same as number of source refs)
 *          and return a value to be written to the sink ref.
 *          Note: `f` will be called with already dereferenced values
 *   opts - optional. Map of:
 *     :ref           - Use this as sink ref. By default creates new atom
 *     :check-equals? - Do an equality check on each update: `(= @sink (f new-vals))`.
 *                      If result of `f` is equal to the old one, do not call `reset!`.
 *                      Defaults to `true`. Set to false if calling `=` would be expensive
 */
rum.core.derived_atom = rum.derived_atom.derived_atom;
/**
 * Given atom with deep nested value and path inside it, creates an atom-like structure
 * that can be used separately from main atom, but will sync changes both ways:
 *   
 *   (def db (atom { :users { "Ivan" { :age 30 }}}))
 *   (def ivan (rum/cursor db [:users "Ivan"]))
 *   \@ivan ;; => { :age 30 }
 *   (swap! ivan update :age inc) ;; => { :age 31 }
 *   \@db ;; => { :users { "Ivan" { :age 31 }}}
 *   (swap! db update-in [:users "Ivan" :age] inc) ;; => { :users { "Ivan" { :age 32 }}}
 *   \@ivan ;; => { :age 32 }
 *   
 *   Returned value supports deref, swap!, reset!, watches and metadata.
 *   The only supported option is `:meta`
 */
rum.core.cursor_in = (function rum$core$cursor_in(var_args){
var args__24566__auto__ = [];
var len__24559__auto___38183 = arguments.length;
var i__24560__auto___38184 = (0);
while(true){
if((i__24560__auto___38184 < len__24559__auto___38183)){
args__24566__auto__.push((arguments[i__24560__auto___38184]));

var G__38185 = (i__24560__auto___38184 + (1));
i__24560__auto___38184 = G__38185;
continue;
} else {
}
break;
}

var argseq__24567__auto__ = ((((2) < args__24566__auto__.length))?(new cljs.core.IndexedSeq(args__24566__auto__.slice((2)),(0),null)):null);
return rum.core.cursor_in.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__24567__auto__);
});

rum.core.cursor_in.cljs$core$IFn$_invoke$arity$variadic = (function (ref,path,p__38180){
var map__38181 = p__38180;
var map__38181__$1 = ((((!((map__38181 == null)))?((((map__38181.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__38181.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__38181):map__38181);
var options = map__38181__$1;
if((ref instanceof rum.cursor.Cursor)){
return (new rum.cursor.Cursor(ref.ref,cljs.core.into.call(null,ref.path,path),new cljs.core.Keyword(null,"meta","meta",1499536964).cljs$core$IFn$_invoke$arity$1(options)));
} else {
return (new rum.cursor.Cursor(ref,path,new cljs.core.Keyword(null,"meta","meta",1499536964).cljs$core$IFn$_invoke$arity$1(options)));
}
});

rum.core.cursor_in.cljs$lang$maxFixedArity = (2);

rum.core.cursor_in.cljs$lang$applyTo = (function (seq38177){
var G__38178 = cljs.core.first.call(null,seq38177);
var seq38177__$1 = cljs.core.next.call(null,seq38177);
var G__38179 = cljs.core.first.call(null,seq38177__$1);
var seq38177__$2 = cljs.core.next.call(null,seq38177__$1);
return rum.core.cursor_in.cljs$core$IFn$_invoke$arity$variadic(G__38178,G__38179,seq38177__$2);
});

/**
 * Same as `rum.core/cursor-in` but accepts single key instead of path vector
 */
rum.core.cursor = (function rum$core$cursor(var_args){
var args__24566__auto__ = [];
var len__24559__auto___38189 = arguments.length;
var i__24560__auto___38190 = (0);
while(true){
if((i__24560__auto___38190 < len__24559__auto___38189)){
args__24566__auto__.push((arguments[i__24560__auto___38190]));

var G__38191 = (i__24560__auto___38190 + (1));
i__24560__auto___38190 = G__38191;
continue;
} else {
}
break;
}

var argseq__24567__auto__ = ((((2) < args__24566__auto__.length))?(new cljs.core.IndexedSeq(args__24566__auto__.slice((2)),(0),null)):null);
return rum.core.cursor.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__24567__auto__);
});

rum.core.cursor.cljs$core$IFn$_invoke$arity$variadic = (function (ref,key,options){
return cljs.core.apply.call(null,rum.core.cursor_in,ref,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [key], null),options);
});

rum.core.cursor.cljs$lang$maxFixedArity = (2);

rum.core.cursor.cljs$lang$applyTo = (function (seq38186){
var G__38187 = cljs.core.first.call(null,seq38186);
var seq38186__$1 = cljs.core.next.call(null,seq38186);
var G__38188 = cljs.core.first.call(null,seq38186__$1);
var seq38186__$2 = cljs.core.next.call(null,seq38186__$1);
return rum.core.cursor.cljs$core$IFn$_invoke$arity$variadic(G__38187,G__38188,seq38186__$2);
});

