goog.provide('shadow.remote.runtime.shared');
shadow.remote.runtime.shared.init_state = (function shadow$remote$runtime$shared$init_state(client_info){
return new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,"extensions","extensions",-1103629196),cljs.core.PersistentArrayMap.EMPTY,new cljs.core.Keyword(null,"ops","ops",1237330063),cljs.core.PersistentArrayMap.EMPTY,new cljs.core.Keyword(null,"client-info","client-info",1958982504),client_info,new cljs.core.Keyword(null,"call-id-seq","call-id-seq",-1679248218),(0),new cljs.core.Keyword(null,"call-handlers","call-handlers",386605551),cljs.core.PersistentArrayMap.EMPTY], null);
});
shadow.remote.runtime.shared.now = (function shadow$remote$runtime$shared$now(){
return Date.now();
});
shadow.remote.runtime.shared.get_client_id = (function shadow$remote$runtime$shared$get_client_id(p__14724){
var map__14725 = p__14724;
var map__14725__$1 = cljs.core.__destructure_map(map__14725);
var runtime = map__14725__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14725__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
var or__5002__auto__ = new cljs.core.Keyword(null,"client-id","client-id",-464622140).cljs$core$IFn$_invoke$arity$1(cljs.core.deref(state_ref));
if(cljs.core.truth_(or__5002__auto__)){
return or__5002__auto__;
} else {
throw cljs.core.ex_info.cljs$core$IFn$_invoke$arity$2("runtime has no assigned runtime-id",new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"runtime","runtime",-1331573996),runtime], null));
}
});
shadow.remote.runtime.shared.relay_msg = (function shadow$remote$runtime$shared$relay_msg(runtime,msg){
var self_id_15046 = shadow.remote.runtime.shared.get_client_id(runtime);
if(cljs.core.not_EQ_.cljs$core$IFn$_invoke$arity$2(new cljs.core.Keyword(null,"to","to",192099007).cljs$core$IFn$_invoke$arity$1(msg),self_id_15046)){
shadow.remote.runtime.api.relay_msg(runtime,msg);
} else {
Promise.resolve((1)).then((function (){
var G__14734 = runtime;
var G__14735 = cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(msg,new cljs.core.Keyword(null,"from","from",1815293044),self_id_15046);
return (shadow.remote.runtime.shared.process.cljs$core$IFn$_invoke$arity$2 ? shadow.remote.runtime.shared.process.cljs$core$IFn$_invoke$arity$2(G__14734,G__14735) : shadow.remote.runtime.shared.process.call(null,G__14734,G__14735));
}));
}

return msg;
});
shadow.remote.runtime.shared.reply = (function shadow$remote$runtime$shared$reply(runtime,p__14745,res){
var map__14746 = p__14745;
var map__14746__$1 = cljs.core.__destructure_map(map__14746);
var call_id = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14746__$1,new cljs.core.Keyword(null,"call-id","call-id",1043012968));
var from = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14746__$1,new cljs.core.Keyword(null,"from","from",1815293044));
var res__$1 = (function (){var G__14752 = res;
var G__14752__$1 = (cljs.core.truth_(call_id)?cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(G__14752,new cljs.core.Keyword(null,"call-id","call-id",1043012968),call_id):G__14752);
if(cljs.core.truth_(from)){
return cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(G__14752__$1,new cljs.core.Keyword(null,"to","to",192099007),from);
} else {
return G__14752__$1;
}
})();
return shadow.remote.runtime.api.relay_msg(runtime,res__$1);
});
shadow.remote.runtime.shared.call = (function shadow$remote$runtime$shared$call(var_args){
var G__14797 = arguments.length;
switch (G__14797) {
case 3:
return shadow.remote.runtime.shared.call.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));

break;
case 4:
return shadow.remote.runtime.shared.call.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));

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

}
});

(shadow.remote.runtime.shared.call.cljs$core$IFn$_invoke$arity$3 = (function (runtime,msg,handlers){
return shadow.remote.runtime.shared.call.cljs$core$IFn$_invoke$arity$4(runtime,msg,handlers,(0));
}));

(shadow.remote.runtime.shared.call.cljs$core$IFn$_invoke$arity$4 = (function (p__14813,msg,handlers,timeout_after_ms){
var map__14814 = p__14813;
var map__14814__$1 = cljs.core.__destructure_map(map__14814);
var runtime = map__14814__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14814__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
if(cljs.core.map_QMARK_(msg)){
} else {
throw (new Error("Assert failed: (map? msg)"));
}

if(cljs.core.map_QMARK_(handlers)){
} else {
throw (new Error("Assert failed: (map? handlers)"));
}

if(cljs.core.nat_int_QMARK_(timeout_after_ms)){
} else {
throw (new Error("Assert failed: (nat-int? timeout-after-ms)"));
}

var call_id = new cljs.core.Keyword(null,"call-id-seq","call-id-seq",-1679248218).cljs$core$IFn$_invoke$arity$1(cljs.core.deref(state_ref));
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$4(state_ref,cljs.core.update,new cljs.core.Keyword(null,"call-id-seq","call-id-seq",-1679248218),cljs.core.inc);

cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$4(state_ref,cljs.core.assoc_in,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"call-handlers","call-handlers",386605551),call_id], null),new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"handlers","handlers",79528781),handlers,new cljs.core.Keyword(null,"called-at","called-at",607081160),shadow.remote.runtime.shared.now(),new cljs.core.Keyword(null,"msg","msg",-1386103444),msg,new cljs.core.Keyword(null,"timeout","timeout",-318625318),timeout_after_ms], null));

return shadow.remote.runtime.api.relay_msg(runtime,cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(msg,new cljs.core.Keyword(null,"call-id","call-id",1043012968),call_id));
}));

(shadow.remote.runtime.shared.call.cljs$lang$maxFixedArity = 4);

shadow.remote.runtime.shared.trigger_BANG_ = (function shadow$remote$runtime$shared$trigger_BANG_(var_args){
var args__5732__auto__ = [];
var len__5726__auto___15057 = arguments.length;
var i__5727__auto___15058 = (0);
while(true){
if((i__5727__auto___15058 < len__5726__auto___15057)){
args__5732__auto__.push((arguments[i__5727__auto___15058]));

var G__15059 = (i__5727__auto___15058 + (1));
i__5727__auto___15058 = G__15059;
continue;
} else {
}
break;
}

var argseq__5733__auto__ = ((((2) < args__5732__auto__.length))?(new cljs.core.IndexedSeq(args__5732__auto__.slice((2)),(0),null)):null);
return shadow.remote.runtime.shared.trigger_BANG_.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__5733__auto__);
});

(shadow.remote.runtime.shared.trigger_BANG_.cljs$core$IFn$_invoke$arity$variadic = (function (p__14826,ev,args){
var map__14827 = p__14826;
var map__14827__$1 = cljs.core.__destructure_map(map__14827);
var runtime = map__14827__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14827__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
var seq__14828 = cljs.core.seq(cljs.core.vals(new cljs.core.Keyword(null,"extensions","extensions",-1103629196).cljs$core$IFn$_invoke$arity$1(cljs.core.deref(state_ref))));
var chunk__14831 = null;
var count__14832 = (0);
var i__14833 = (0);
while(true){
if((i__14833 < count__14832)){
var ext = chunk__14831.cljs$core$IIndexed$_nth$arity$2(null,i__14833);
var ev_fn = cljs.core.get.cljs$core$IFn$_invoke$arity$2(ext,ev);
if(cljs.core.truth_(ev_fn)){
cljs.core.apply.cljs$core$IFn$_invoke$arity$2(ev_fn,args);


var G__15060 = seq__14828;
var G__15061 = chunk__14831;
var G__15062 = count__14832;
var G__15063 = (i__14833 + (1));
seq__14828 = G__15060;
chunk__14831 = G__15061;
count__14832 = G__15062;
i__14833 = G__15063;
continue;
} else {
var G__15064 = seq__14828;
var G__15065 = chunk__14831;
var G__15066 = count__14832;
var G__15067 = (i__14833 + (1));
seq__14828 = G__15064;
chunk__14831 = G__15065;
count__14832 = G__15066;
i__14833 = G__15067;
continue;
}
} else {
var temp__5804__auto__ = cljs.core.seq(seq__14828);
if(temp__5804__auto__){
var seq__14828__$1 = temp__5804__auto__;
if(cljs.core.chunked_seq_QMARK_(seq__14828__$1)){
var c__5525__auto__ = cljs.core.chunk_first(seq__14828__$1);
var G__15068 = cljs.core.chunk_rest(seq__14828__$1);
var G__15069 = c__5525__auto__;
var G__15070 = cljs.core.count(c__5525__auto__);
var G__15071 = (0);
seq__14828 = G__15068;
chunk__14831 = G__15069;
count__14832 = G__15070;
i__14833 = G__15071;
continue;
} else {
var ext = cljs.core.first(seq__14828__$1);
var ev_fn = cljs.core.get.cljs$core$IFn$_invoke$arity$2(ext,ev);
if(cljs.core.truth_(ev_fn)){
cljs.core.apply.cljs$core$IFn$_invoke$arity$2(ev_fn,args);


var G__15072 = cljs.core.next(seq__14828__$1);
var G__15073 = null;
var G__15074 = (0);
var G__15075 = (0);
seq__14828 = G__15072;
chunk__14831 = G__15073;
count__14832 = G__15074;
i__14833 = G__15075;
continue;
} else {
var G__15076 = cljs.core.next(seq__14828__$1);
var G__15077 = null;
var G__15078 = (0);
var G__15079 = (0);
seq__14828 = G__15076;
chunk__14831 = G__15077;
count__14832 = G__15078;
i__14833 = G__15079;
continue;
}
}
} else {
return null;
}
}
break;
}
}));

(shadow.remote.runtime.shared.trigger_BANG_.cljs$lang$maxFixedArity = (2));

/** @this {Function} */
(shadow.remote.runtime.shared.trigger_BANG_.cljs$lang$applyTo = (function (seq14819){
var G__14820 = cljs.core.first(seq14819);
var seq14819__$1 = cljs.core.next(seq14819);
var G__14821 = cljs.core.first(seq14819__$1);
var seq14819__$2 = cljs.core.next(seq14819__$1);
var self__5711__auto__ = this;
return self__5711__auto__.cljs$core$IFn$_invoke$arity$variadic(G__14820,G__14821,seq14819__$2);
}));

shadow.remote.runtime.shared.welcome = (function shadow$remote$runtime$shared$welcome(p__14865,p__14866){
var map__14868 = p__14865;
var map__14868__$1 = cljs.core.__destructure_map(map__14868);
var runtime = map__14868__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14868__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
var map__14869 = p__14866;
var map__14869__$1 = cljs.core.__destructure_map(map__14869);
var msg = map__14869__$1;
var client_id = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14869__$1,new cljs.core.Keyword(null,"client-id","client-id",-464622140));
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$variadic(state_ref,cljs.core.assoc,new cljs.core.Keyword(null,"client-id","client-id",-464622140),client_id,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.Keyword(null,"welcome","welcome",-578152123),true], 0));

var map__14870 = cljs.core.deref(state_ref);
var map__14870__$1 = cljs.core.__destructure_map(map__14870);
var client_info = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14870__$1,new cljs.core.Keyword(null,"client-info","client-info",1958982504));
var extensions = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14870__$1,new cljs.core.Keyword(null,"extensions","extensions",-1103629196));
shadow.remote.runtime.shared.relay_msg(runtime,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"op","op",-1882987955),new cljs.core.Keyword(null,"hello","hello",-245025397),new cljs.core.Keyword(null,"client-info","client-info",1958982504),client_info], null));

return shadow.remote.runtime.shared.trigger_BANG_(runtime,new cljs.core.Keyword(null,"on-welcome","on-welcome",1895317125));
});
shadow.remote.runtime.shared.ping = (function shadow$remote$runtime$shared$ping(runtime,msg){
return shadow.remote.runtime.shared.reply(runtime,msg,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"op","op",-1882987955),new cljs.core.Keyword(null,"pong","pong",-172484958)], null));
});
shadow.remote.runtime.shared.request_supported_ops = (function shadow$remote$runtime$shared$request_supported_ops(p__14879,msg){
var map__14880 = p__14879;
var map__14880__$1 = cljs.core.__destructure_map(map__14880);
var runtime = map__14880__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14880__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
return shadow.remote.runtime.shared.reply(runtime,msg,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"op","op",-1882987955),new cljs.core.Keyword(null,"supported-ops","supported-ops",337914702),new cljs.core.Keyword(null,"ops","ops",1237330063),cljs.core.disj.cljs$core$IFn$_invoke$arity$variadic(cljs.core.set(cljs.core.keys(new cljs.core.Keyword(null,"ops","ops",1237330063).cljs$core$IFn$_invoke$arity$1(cljs.core.deref(state_ref)))),new cljs.core.Keyword(null,"welcome","welcome",-578152123),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.Keyword(null,"unknown-relay-op","unknown-relay-op",170832753),new cljs.core.Keyword(null,"unknown-op","unknown-op",1900385996),new cljs.core.Keyword(null,"request-supported-ops","request-supported-ops",-1034994502),new cljs.core.Keyword(null,"tool-disconnect","tool-disconnect",189103996)], 0))], null));
});
shadow.remote.runtime.shared.unknown_relay_op = (function shadow$remote$runtime$shared$unknown_relay_op(msg){
return console.warn("unknown-relay-op",msg);
});
shadow.remote.runtime.shared.unknown_op = (function shadow$remote$runtime$shared$unknown_op(msg){
return console.warn("unknown-op",msg);
});
shadow.remote.runtime.shared.add_extension_STAR_ = (function shadow$remote$runtime$shared$add_extension_STAR_(p__14892,key,p__14893){
var map__14894 = p__14892;
var map__14894__$1 = cljs.core.__destructure_map(map__14894);
var state = map__14894__$1;
var extensions = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14894__$1,new cljs.core.Keyword(null,"extensions","extensions",-1103629196));
var map__14895 = p__14893;
var map__14895__$1 = cljs.core.__destructure_map(map__14895);
var spec = map__14895__$1;
var ops = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14895__$1,new cljs.core.Keyword(null,"ops","ops",1237330063));
var transit_write_handlers = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14895__$1,new cljs.core.Keyword(null,"transit-write-handlers","transit-write-handlers",1886308716));
if(cljs.core.contains_QMARK_(extensions,key)){
throw cljs.core.ex_info.cljs$core$IFn$_invoke$arity$2("extension already registered",new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"key","key",-1516042587),key,new cljs.core.Keyword(null,"spec","spec",347520401),spec], null));
} else {
}

return cljs.core.reduce_kv((function (state__$1,op_kw,op_handler){
if(cljs.core.truth_(cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(state__$1,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"ops","ops",1237330063),op_kw], null)))){
throw cljs.core.ex_info.cljs$core$IFn$_invoke$arity$2("op already registered",new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"key","key",-1516042587),key,new cljs.core.Keyword(null,"op","op",-1882987955),op_kw], null));
} else {
}

return cljs.core.assoc_in(state__$1,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"ops","ops",1237330063),op_kw], null),op_handler);
}),cljs.core.assoc_in(state,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"extensions","extensions",-1103629196),key], null),spec),ops);
});
shadow.remote.runtime.shared.add_extension = (function shadow$remote$runtime$shared$add_extension(p__14914,key,spec){
var map__14915 = p__14914;
var map__14915__$1 = cljs.core.__destructure_map(map__14915);
var runtime = map__14915__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14915__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$4(state_ref,shadow.remote.runtime.shared.add_extension_STAR_,key,spec);

var temp__5808__auto___15090 = new cljs.core.Keyword(null,"on-welcome","on-welcome",1895317125).cljs$core$IFn$_invoke$arity$1(spec);
if((temp__5808__auto___15090 == null)){
} else {
var on_welcome_15091 = temp__5808__auto___15090;
if(cljs.core.truth_(new cljs.core.Keyword(null,"welcome","welcome",-578152123).cljs$core$IFn$_invoke$arity$1(cljs.core.deref(state_ref)))){
(on_welcome_15091.cljs$core$IFn$_invoke$arity$0 ? on_welcome_15091.cljs$core$IFn$_invoke$arity$0() : on_welcome_15091.call(null));
} else {
}
}

return runtime;
});
shadow.remote.runtime.shared.add_defaults = (function shadow$remote$runtime$shared$add_defaults(runtime){
return shadow.remote.runtime.shared.add_extension(runtime,new cljs.core.Keyword("shadow.remote.runtime.shared","defaults","shadow.remote.runtime.shared/defaults",-1821257543),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"ops","ops",1237330063),new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,"welcome","welcome",-578152123),(function (p1__14922_SHARP_){
return shadow.remote.runtime.shared.welcome(runtime,p1__14922_SHARP_);
}),new cljs.core.Keyword(null,"unknown-relay-op","unknown-relay-op",170832753),(function (p1__14924_SHARP_){
return shadow.remote.runtime.shared.unknown_relay_op(p1__14924_SHARP_);
}),new cljs.core.Keyword(null,"unknown-op","unknown-op",1900385996),(function (p1__14928_SHARP_){
return shadow.remote.runtime.shared.unknown_op(p1__14928_SHARP_);
}),new cljs.core.Keyword(null,"ping","ping",-1670114784),(function (p1__14929_SHARP_){
return shadow.remote.runtime.shared.ping(runtime,p1__14929_SHARP_);
}),new cljs.core.Keyword(null,"request-supported-ops","request-supported-ops",-1034994502),(function (p1__14930_SHARP_){
return shadow.remote.runtime.shared.request_supported_ops(runtime,p1__14930_SHARP_);
})], null)], null));
});
shadow.remote.runtime.shared.del_extension_STAR_ = (function shadow$remote$runtime$shared$del_extension_STAR_(state,key){
var ext = cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(state,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"extensions","extensions",-1103629196),key], null));
if(cljs.core.not(ext)){
return state;
} else {
return cljs.core.reduce_kv((function (state__$1,op_kw,op_handler){
return cljs.core.update_in.cljs$core$IFn$_invoke$arity$4(state__$1,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"ops","ops",1237330063)], null),cljs.core.dissoc,op_kw);
}),cljs.core.update.cljs$core$IFn$_invoke$arity$4(state,new cljs.core.Keyword(null,"extensions","extensions",-1103629196),cljs.core.dissoc,key),new cljs.core.Keyword(null,"ops","ops",1237330063).cljs$core$IFn$_invoke$arity$1(ext));
}
});
shadow.remote.runtime.shared.del_extension = (function shadow$remote$runtime$shared$del_extension(p__14948,key){
var map__14949 = p__14948;
var map__14949__$1 = cljs.core.__destructure_map(map__14949);
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14949__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
return cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$3(state_ref,shadow.remote.runtime.shared.del_extension_STAR_,key);
});
shadow.remote.runtime.shared.unhandled_call_result = (function shadow$remote$runtime$shared$unhandled_call_result(call_config,msg){
return console.warn("unhandled call result",msg,call_config);
});
shadow.remote.runtime.shared.unhandled_client_not_found = (function shadow$remote$runtime$shared$unhandled_client_not_found(p__14958,msg){
var map__14959 = p__14958;
var map__14959__$1 = cljs.core.__destructure_map(map__14959);
var runtime = map__14959__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14959__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
return shadow.remote.runtime.shared.trigger_BANG_.cljs$core$IFn$_invoke$arity$variadic(runtime,new cljs.core.Keyword(null,"on-client-not-found","on-client-not-found",-642452849),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([msg], 0));
});
shadow.remote.runtime.shared.reply_unknown_op = (function shadow$remote$runtime$shared$reply_unknown_op(runtime,msg){
return shadow.remote.runtime.shared.reply(runtime,msg,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"op","op",-1882987955),new cljs.core.Keyword(null,"unknown-op","unknown-op",1900385996),new cljs.core.Keyword(null,"msg","msg",-1386103444),msg], null));
});
shadow.remote.runtime.shared.process = (function shadow$remote$runtime$shared$process(p__14970,p__14971){
var map__14972 = p__14970;
var map__14972__$1 = cljs.core.__destructure_map(map__14972);
var runtime = map__14972__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14972__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
var map__14973 = p__14971;
var map__14973__$1 = cljs.core.__destructure_map(map__14973);
var msg = map__14973__$1;
var op = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14973__$1,new cljs.core.Keyword(null,"op","op",-1882987955));
var call_id = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__14973__$1,new cljs.core.Keyword(null,"call-id","call-id",1043012968));
var state = cljs.core.deref(state_ref);
var op_handler = cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(state,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"ops","ops",1237330063),op], null));
if(cljs.core.truth_(call_id)){
var cfg = cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(state,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"call-handlers","call-handlers",386605551),call_id], null));
var call_handler = cljs.core.get_in.cljs$core$IFn$_invoke$arity$2(cfg,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"handlers","handlers",79528781),op], null));
if(cljs.core.truth_(call_handler)){
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$variadic(state_ref,cljs.core.update,new cljs.core.Keyword(null,"call-handlers","call-handlers",386605551),cljs.core.dissoc,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([call_id], 0));

return (call_handler.cljs$core$IFn$_invoke$arity$1 ? call_handler.cljs$core$IFn$_invoke$arity$1(msg) : call_handler.call(null,msg));
} else {
if(cljs.core.truth_(op_handler)){
return (op_handler.cljs$core$IFn$_invoke$arity$1 ? op_handler.cljs$core$IFn$_invoke$arity$1(msg) : op_handler.call(null,msg));
} else {
return shadow.remote.runtime.shared.unhandled_call_result(cfg,msg);

}
}
} else {
if(cljs.core.truth_(op_handler)){
return (op_handler.cljs$core$IFn$_invoke$arity$1 ? op_handler.cljs$core$IFn$_invoke$arity$1(msg) : op_handler.call(null,msg));
} else {
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(new cljs.core.Keyword(null,"client-not-found","client-not-found",-1754042614),op)){
return shadow.remote.runtime.shared.unhandled_client_not_found(runtime,msg);
} else {
return shadow.remote.runtime.shared.reply_unknown_op(runtime,msg);

}
}
}
});
shadow.remote.runtime.shared.run_on_idle = (function shadow$remote$runtime$shared$run_on_idle(state_ref){
var seq__15027 = cljs.core.seq(cljs.core.vals(new cljs.core.Keyword(null,"extensions","extensions",-1103629196).cljs$core$IFn$_invoke$arity$1(cljs.core.deref(state_ref))));
var chunk__15029 = null;
var count__15030 = (0);
var i__15031 = (0);
while(true){
if((i__15031 < count__15030)){
var map__15041 = chunk__15029.cljs$core$IIndexed$_nth$arity$2(null,i__15031);
var map__15041__$1 = cljs.core.__destructure_map(map__15041);
var on_idle = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__15041__$1,new cljs.core.Keyword(null,"on-idle","on-idle",2044706602));
if(cljs.core.truth_(on_idle)){
(on_idle.cljs$core$IFn$_invoke$arity$0 ? on_idle.cljs$core$IFn$_invoke$arity$0() : on_idle.call(null));


var G__15131 = seq__15027;
var G__15132 = chunk__15029;
var G__15133 = count__15030;
var G__15134 = (i__15031 + (1));
seq__15027 = G__15131;
chunk__15029 = G__15132;
count__15030 = G__15133;
i__15031 = G__15134;
continue;
} else {
var G__15135 = seq__15027;
var G__15136 = chunk__15029;
var G__15137 = count__15030;
var G__15138 = (i__15031 + (1));
seq__15027 = G__15135;
chunk__15029 = G__15136;
count__15030 = G__15137;
i__15031 = G__15138;
continue;
}
} else {
var temp__5804__auto__ = cljs.core.seq(seq__15027);
if(temp__5804__auto__){
var seq__15027__$1 = temp__5804__auto__;
if(cljs.core.chunked_seq_QMARK_(seq__15027__$1)){
var c__5525__auto__ = cljs.core.chunk_first(seq__15027__$1);
var G__15140 = cljs.core.chunk_rest(seq__15027__$1);
var G__15141 = c__5525__auto__;
var G__15142 = cljs.core.count(c__5525__auto__);
var G__15143 = (0);
seq__15027 = G__15140;
chunk__15029 = G__15141;
count__15030 = G__15142;
i__15031 = G__15143;
continue;
} else {
var map__15042 = cljs.core.first(seq__15027__$1);
var map__15042__$1 = cljs.core.__destructure_map(map__15042);
var on_idle = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__15042__$1,new cljs.core.Keyword(null,"on-idle","on-idle",2044706602));
if(cljs.core.truth_(on_idle)){
(on_idle.cljs$core$IFn$_invoke$arity$0 ? on_idle.cljs$core$IFn$_invoke$arity$0() : on_idle.call(null));


var G__15149 = cljs.core.next(seq__15027__$1);
var G__15150 = null;
var G__15151 = (0);
var G__15152 = (0);
seq__15027 = G__15149;
chunk__15029 = G__15150;
count__15030 = G__15151;
i__15031 = G__15152;
continue;
} else {
var G__15154 = cljs.core.next(seq__15027__$1);
var G__15155 = null;
var G__15156 = (0);
var G__15157 = (0);
seq__15027 = G__15154;
chunk__15029 = G__15155;
count__15030 = G__15156;
i__15031 = G__15157;
continue;
}
}
} else {
return null;
}
}
break;
}
});

//# sourceMappingURL=shadow.remote.runtime.shared.js.map
