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__34985){
var map__34987 = p__34985;
var map__34987__$1 = cljs.core.__destructure_map(map__34987);
var runtime = map__34987__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__34987__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
var or__5025__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__5025__auto__)){
return or__5025__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_35169 = 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_35169)){
shadow.remote.runtime.api.relay_msg(runtime,msg);
} else {
Promise.resolve((1)).then((function (){
var G__34988 = runtime;
var G__34989 = cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(msg,new cljs.core.Keyword(null,"from","from",1815293044),self_id_35169);
return (shadow.remote.runtime.shared.process.cljs$core$IFn$_invoke$arity$2 ? shadow.remote.runtime.shared.process.cljs$core$IFn$_invoke$arity$2(G__34988,G__34989) : shadow.remote.runtime.shared.process.call(null,G__34988,G__34989));
}));
}

return msg;
});
shadow.remote.runtime.shared.reply = (function shadow$remote$runtime$shared$reply(runtime,p__34990,res){
var map__34991 = p__34990;
var map__34991__$1 = cljs.core.__destructure_map(map__34991);
var call_id = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__34991__$1,new cljs.core.Keyword(null,"call-id","call-id",1043012968));
var from = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__34991__$1,new cljs.core.Keyword(null,"from","from",1815293044));
var res__$1 = (function (){var G__34992 = res;
var G__34992__$1 = (cljs.core.truth_(call_id)?cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(G__34992,new cljs.core.Keyword(null,"call-id","call-id",1043012968),call_id):G__34992);
if(cljs.core.truth_(from)){
return cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(G__34992__$1,new cljs.core.Keyword(null,"to","to",192099007),from);
} else {
return G__34992__$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__34994 = arguments.length;
switch (G__34994) {
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__34995,msg,handlers,timeout_after_ms){
var map__34996 = p__34995;
var map__34996__$1 = cljs.core.__destructure_map(map__34996);
var runtime = map__34996__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__34996__$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__5755__auto__ = [];
var len__5749__auto___35174 = arguments.length;
var i__5750__auto___35175 = (0);
while(true){
if((i__5750__auto___35175 < len__5749__auto___35174)){
args__5755__auto__.push((arguments[i__5750__auto___35175]));

var G__35179 = (i__5750__auto___35175 + (1));
i__5750__auto___35175 = G__35179;
continue;
} else {
}
break;
}

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

(shadow.remote.runtime.shared.trigger_BANG_.cljs$core$IFn$_invoke$arity$variadic = (function (p__35000,ev,args){
var map__35001 = p__35000;
var map__35001__$1 = cljs.core.__destructure_map(map__35001);
var runtime = map__35001__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__35001__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
var seq__35002 = 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__35005 = null;
var count__35006 = (0);
var i__35007 = (0);
while(true){
if((i__35007 < count__35006)){
var ext = chunk__35005.cljs$core$IIndexed$_nth$arity$2(null,i__35007);
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__35180 = seq__35002;
var G__35181 = chunk__35005;
var G__35182 = count__35006;
var G__35183 = (i__35007 + (1));
seq__35002 = G__35180;
chunk__35005 = G__35181;
count__35006 = G__35182;
i__35007 = G__35183;
continue;
} else {
var G__35184 = seq__35002;
var G__35185 = chunk__35005;
var G__35186 = count__35006;
var G__35187 = (i__35007 + (1));
seq__35002 = G__35184;
chunk__35005 = G__35185;
count__35006 = G__35186;
i__35007 = G__35187;
continue;
}
} else {
var temp__5804__auto__ = cljs.core.seq(seq__35002);
if(temp__5804__auto__){
var seq__35002__$1 = temp__5804__auto__;
if(cljs.core.chunked_seq_QMARK_(seq__35002__$1)){
var c__5548__auto__ = cljs.core.chunk_first(seq__35002__$1);
var G__35188 = cljs.core.chunk_rest(seq__35002__$1);
var G__35189 = c__5548__auto__;
var G__35190 = cljs.core.count(c__5548__auto__);
var G__35191 = (0);
seq__35002 = G__35188;
chunk__35005 = G__35189;
count__35006 = G__35190;
i__35007 = G__35191;
continue;
} else {
var ext = cljs.core.first(seq__35002__$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__35192 = cljs.core.next(seq__35002__$1);
var G__35193 = null;
var G__35194 = (0);
var G__35195 = (0);
seq__35002 = G__35192;
chunk__35005 = G__35193;
count__35006 = G__35194;
i__35007 = G__35195;
continue;
} else {
var G__35196 = cljs.core.next(seq__35002__$1);
var G__35197 = null;
var G__35198 = (0);
var G__35199 = (0);
seq__35002 = G__35196;
chunk__35005 = G__35197;
count__35006 = G__35198;
i__35007 = G__35199;
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 (seq34997){
var G__34998 = cljs.core.first(seq34997);
var seq34997__$1 = cljs.core.next(seq34997);
var G__34999 = cljs.core.first(seq34997__$1);
var seq34997__$2 = cljs.core.next(seq34997__$1);
var self__5734__auto__ = this;
return self__5734__auto__.cljs$core$IFn$_invoke$arity$variadic(G__34998,G__34999,seq34997__$2);
}));

shadow.remote.runtime.shared.welcome = (function shadow$remote$runtime$shared$welcome(p__35016,p__35017){
var map__35018 = p__35016;
var map__35018__$1 = cljs.core.__destructure_map(map__35018);
var runtime = map__35018__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__35018__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
var map__35019 = p__35017;
var map__35019__$1 = cljs.core.__destructure_map(map__35019);
var msg = map__35019__$1;
var client_id = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__35019__$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__35020 = cljs.core.deref(state_ref);
var map__35020__$1 = cljs.core.__destructure_map(map__35020);
var client_info = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__35020__$1,new cljs.core.Keyword(null,"client-info","client-info",1958982504));
var extensions = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__35020__$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__35022,msg){
var map__35023 = p__35022;
var map__35023__$1 = cljs.core.__destructure_map(map__35023);
var runtime = map__35023__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__35023__$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__35032,key,p__35033){
var map__35034 = p__35032;
var map__35034__$1 = cljs.core.__destructure_map(map__35034);
var state = map__35034__$1;
var extensions = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__35034__$1,new cljs.core.Keyword(null,"extensions","extensions",-1103629196));
var map__35035 = p__35033;
var map__35035__$1 = cljs.core.__destructure_map(map__35035);
var spec = map__35035__$1;
var ops = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__35035__$1,new cljs.core.Keyword(null,"ops","ops",1237330063));
var transit_write_handlers = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__35035__$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__35049,key,spec){
var map__35051 = p__35049;
var map__35051__$1 = cljs.core.__destructure_map(map__35051);
var runtime = map__35051__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__35051__$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___35205 = new cljs.core.Keyword(null,"on-welcome","on-welcome",1895317125).cljs$core$IFn$_invoke$arity$1(spec);
if((temp__5808__auto___35205 == null)){
} else {
var on_welcome_35206 = temp__5808__auto___35205;
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_35206.cljs$core$IFn$_invoke$arity$0 ? on_welcome_35206.cljs$core$IFn$_invoke$arity$0() : on_welcome_35206.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__35057_SHARP_){
return shadow.remote.runtime.shared.welcome(runtime,p1__35057_SHARP_);
}),new cljs.core.Keyword(null,"unknown-relay-op","unknown-relay-op",170832753),(function (p1__35058_SHARP_){
return shadow.remote.runtime.shared.unknown_relay_op(p1__35058_SHARP_);
}),new cljs.core.Keyword(null,"unknown-op","unknown-op",1900385996),(function (p1__35059_SHARP_){
return shadow.remote.runtime.shared.unknown_op(p1__35059_SHARP_);
}),new cljs.core.Keyword(null,"ping","ping",-1670114784),(function (p1__35060_SHARP_){
return shadow.remote.runtime.shared.ping(runtime,p1__35060_SHARP_);
}),new cljs.core.Keyword(null,"request-supported-ops","request-supported-ops",-1034994502),(function (p1__35061_SHARP_){
return shadow.remote.runtime.shared.request_supported_ops(runtime,p1__35061_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__35088,key){
var map__35090 = p__35088;
var map__35090__$1 = cljs.core.__destructure_map(map__35090);
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__35090__$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__35099,msg){
var map__35101 = p__35099;
var map__35101__$1 = cljs.core.__destructure_map(map__35101);
var runtime = map__35101__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__35101__$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__35112,p__35113){
var map__35120 = p__35112;
var map__35120__$1 = cljs.core.__destructure_map(map__35120);
var runtime = map__35120__$1;
var state_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__35120__$1,new cljs.core.Keyword(null,"state-ref","state-ref",2127874952));
var map__35121 = p__35113;
var map__35121__$1 = cljs.core.__destructure_map(map__35121);
var msg = map__35121__$1;
var op = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__35121__$1,new cljs.core.Keyword(null,"op","op",-1882987955));
var call_id = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__35121__$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__35141 = 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__35143 = null;
var count__35144 = (0);
var i__35145 = (0);
while(true){
if((i__35145 < count__35144)){
var map__35156 = chunk__35143.cljs$core$IIndexed$_nth$arity$2(null,i__35145);
var map__35156__$1 = cljs.core.__destructure_map(map__35156);
var on_idle = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__35156__$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__35212 = seq__35141;
var G__35213 = chunk__35143;
var G__35214 = count__35144;
var G__35215 = (i__35145 + (1));
seq__35141 = G__35212;
chunk__35143 = G__35213;
count__35144 = G__35214;
i__35145 = G__35215;
continue;
} else {
var G__35216 = seq__35141;
var G__35217 = chunk__35143;
var G__35218 = count__35144;
var G__35219 = (i__35145 + (1));
seq__35141 = G__35216;
chunk__35143 = G__35217;
count__35144 = G__35218;
i__35145 = G__35219;
continue;
}
} else {
var temp__5804__auto__ = cljs.core.seq(seq__35141);
if(temp__5804__auto__){
var seq__35141__$1 = temp__5804__auto__;
if(cljs.core.chunked_seq_QMARK_(seq__35141__$1)){
var c__5548__auto__ = cljs.core.chunk_first(seq__35141__$1);
var G__35220 = cljs.core.chunk_rest(seq__35141__$1);
var G__35221 = c__5548__auto__;
var G__35222 = cljs.core.count(c__5548__auto__);
var G__35223 = (0);
seq__35141 = G__35220;
chunk__35143 = G__35221;
count__35144 = G__35222;
i__35145 = G__35223;
continue;
} else {
var map__35160 = cljs.core.first(seq__35141__$1);
var map__35160__$1 = cljs.core.__destructure_map(map__35160);
var on_idle = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__35160__$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__35230 = cljs.core.next(seq__35141__$1);
var G__35231 = null;
var G__35232 = (0);
var G__35233 = (0);
seq__35141 = G__35230;
chunk__35143 = G__35231;
count__35144 = G__35232;
i__35145 = G__35233;
continue;
} else {
var G__35235 = cljs.core.next(seq__35141__$1);
var G__35236 = null;
var G__35237 = (0);
var G__35238 = (0);
seq__35141 = G__35235;
chunk__35143 = G__35236;
count__35144 = G__35237;
i__35145 = G__35238;
continue;
}
}
} else {
return null;
}
}
break;
}
});

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