import "./cljs_env.js";
goog.provide('shadow.remote.runtime.tap_support');
shadow.remote.runtime.tap_support.tap_subscribe = (function shadow$remote$runtime$tap_support$tap_subscribe(p__53972,p__53973){
var map__53974 = p__53972;
var map__53974__$1 = cljs.core.__destructure_map(map__53974);
var svc = map__53974__$1;
var subs_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__53974__$1,new cljs.core.Keyword(null,"subs-ref","subs-ref",-1355989911));
var obj_support = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__53974__$1,new cljs.core.Keyword(null,"obj-support","obj-support",1522559229));
var runtime = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__53974__$1,new cljs.core.Keyword(null,"runtime","runtime",-1331573996));
var map__53975 = p__53973;
var map__53975__$1 = cljs.core.__destructure_map(map__53975);
var msg = map__53975__$1;
var from = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__53975__$1,new cljs.core.Keyword(null,"from","from",1815293044));
var summary = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__53975__$1,new cljs.core.Keyword(null,"summary","summary",380847952));
var history = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__53975__$1,new cljs.core.Keyword(null,"history","history",-247395220));
var num = cljs.core.get.cljs$core$IFn$_invoke$arity$3(map__53975__$1,new cljs.core.Keyword(null,"num","num",1985240673),(10));
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$4(subs_ref,cljs.core.assoc,from,msg);

if(cljs.core.truth_(history)){
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,"tap-subscribed","tap-subscribed",-1882247432),new cljs.core.Keyword(null,"history","history",-247395220),cljs.core.into.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentVector.EMPTY,cljs.core.map.cljs$core$IFn$_invoke$arity$2((function (oid){
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"oid","oid",-768692334),oid,new cljs.core.Keyword(null,"summary","summary",380847952),shadow.remote.runtime.obj_support.obj_describe_STAR_(obj_support,oid)], null);
}),shadow.remote.runtime.obj_support.get_tap_history(obj_support,num)))], null));
} else {
return null;
}
});
shadow.remote.runtime.tap_support.tap_unsubscribe = (function shadow$remote$runtime$tap_support$tap_unsubscribe(p__53976,p__53977){
var map__53978 = p__53976;
var map__53978__$1 = cljs.core.__destructure_map(map__53978);
var subs_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__53978__$1,new cljs.core.Keyword(null,"subs-ref","subs-ref",-1355989911));
var map__53979 = p__53977;
var map__53979__$1 = cljs.core.__destructure_map(map__53979);
var from = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__53979__$1,new cljs.core.Keyword(null,"from","from",1815293044));
return cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$3(subs_ref,cljs.core.dissoc,from);
});
shadow.remote.runtime.tap_support.request_tap_history = (function shadow$remote$runtime$tap_support$request_tap_history(p__53980,p__53981){
var map__53982 = p__53980;
var map__53982__$1 = cljs.core.__destructure_map(map__53982);
var obj_support = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__53982__$1,new cljs.core.Keyword(null,"obj-support","obj-support",1522559229));
var runtime = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__53982__$1,new cljs.core.Keyword(null,"runtime","runtime",-1331573996));
var map__53983 = p__53981;
var map__53983__$1 = cljs.core.__destructure_map(map__53983);
var msg = map__53983__$1;
var num = cljs.core.get.cljs$core$IFn$_invoke$arity$3(map__53983__$1,new cljs.core.Keyword(null,"num","num",1985240673),(10));
var tap_ids = shadow.remote.runtime.obj_support.get_tap_history(obj_support,num);
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,"tap-history","tap-history",-282803347),new cljs.core.Keyword(null,"oids","oids",-1580877688),tap_ids], null));
});
shadow.remote.runtime.tap_support.tool_disconnect = (function shadow$remote$runtime$tap_support$tool_disconnect(p__53984,tid){
var map__53985 = p__53984;
var map__53985__$1 = cljs.core.__destructure_map(map__53985);
var svc = map__53985__$1;
var subs_ref = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__53985__$1,new cljs.core.Keyword(null,"subs-ref","subs-ref",-1355989911));
return cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$3(subs_ref,cljs.core.dissoc,tid);
});
shadow.remote.runtime.tap_support.start = (function shadow$remote$runtime$tap_support$start(runtime,obj_support){
var subs_ref = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(cljs.core.PersistentArrayMap.EMPTY);
var tap_fn = (function shadow$remote$runtime$tap_support$start_$_runtime_tap(obj){
if((!((obj == null)))){
var oid = shadow.remote.runtime.obj_support.register(obj_support,obj,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"from","from",1815293044),new cljs.core.Keyword(null,"tap","tap",-1086702463)], null));
var seq__53990 = cljs.core.seq(cljs.core.deref(subs_ref));
var chunk__53991 = null;
var count__53992 = (0);
var i__53993 = (0);
while(true){
if((i__53993 < count__53992)){
var vec__54000 = chunk__53991.cljs$core$IIndexed$_nth$arity$2(null,i__53993);
var tid = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__54000,(0),null);
var tap_config = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__54000,(1),null);
shadow.remote.runtime.api.relay_msg(runtime,new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"op","op",-1882987955),new cljs.core.Keyword(null,"tap","tap",-1086702463),new cljs.core.Keyword(null,"to","to",192099007),tid,new cljs.core.Keyword(null,"oid","oid",-768692334),oid], null));


var G__54008 = seq__53990;
var G__54009 = chunk__53991;
var G__54010 = count__53992;
var G__54011 = (i__53993 + (1));
seq__53990 = G__54008;
chunk__53991 = G__54009;
count__53992 = G__54010;
i__53993 = G__54011;
continue;
} else {
var temp__5753__auto__ = cljs.core.seq(seq__53990);
if(temp__5753__auto__){
var seq__53990__$1 = temp__5753__auto__;
if(cljs.core.chunked_seq_QMARK_(seq__53990__$1)){
var c__4649__auto__ = cljs.core.chunk_first(seq__53990__$1);
var G__54012 = cljs.core.chunk_rest(seq__53990__$1);
var G__54013 = c__4649__auto__;
var G__54014 = cljs.core.count(c__4649__auto__);
var G__54015 = (0);
seq__53990 = G__54012;
chunk__53991 = G__54013;
count__53992 = G__54014;
i__53993 = G__54015;
continue;
} else {
var vec__54003 = cljs.core.first(seq__53990__$1);
var tid = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__54003,(0),null);
var tap_config = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__54003,(1),null);
shadow.remote.runtime.api.relay_msg(runtime,new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"op","op",-1882987955),new cljs.core.Keyword(null,"tap","tap",-1086702463),new cljs.core.Keyword(null,"to","to",192099007),tid,new cljs.core.Keyword(null,"oid","oid",-768692334),oid], null));


var G__54016 = cljs.core.next(seq__53990__$1);
var G__54017 = null;
var G__54018 = (0);
var G__54019 = (0);
seq__53990 = G__54016;
chunk__53991 = G__54017;
count__53992 = G__54018;
i__53993 = G__54019;
continue;
}
} else {
return null;
}
}
break;
}
} else {
return null;
}
});
var svc = new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"runtime","runtime",-1331573996),runtime,new cljs.core.Keyword(null,"obj-support","obj-support",1522559229),obj_support,new cljs.core.Keyword(null,"tap-fn","tap-fn",1573556461),tap_fn,new cljs.core.Keyword(null,"subs-ref","subs-ref",-1355989911),subs_ref], null);
shadow.remote.runtime.api.add_extension(runtime,new cljs.core.Keyword("shadow.remote.runtime.tap-support","ext","shadow.remote.runtime.tap-support/ext",1019069674),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"ops","ops",1237330063),new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"tap-subscribe","tap-subscribe",411179050),(function (p1__53986_SHARP_){
return shadow.remote.runtime.tap_support.tap_subscribe(svc,p1__53986_SHARP_);
}),new cljs.core.Keyword(null,"tap-unsubscribe","tap-unsubscribe",1183890755),(function (p1__53987_SHARP_){
return shadow.remote.runtime.tap_support.tap_unsubscribe(svc,p1__53987_SHARP_);
}),new cljs.core.Keyword(null,"request-tap-history","request-tap-history",-670837812),(function (p1__53988_SHARP_){
return shadow.remote.runtime.tap_support.request_tap_history(svc,p1__53988_SHARP_);
})], null),new cljs.core.Keyword(null,"on-tool-disconnect","on-tool-disconnect",693464366),(function (p1__53989_SHARP_){
return shadow.remote.runtime.tap_support.tool_disconnect(svc,p1__53989_SHARP_);
})], null));

cljs.core.add_tap(tap_fn);

return svc;
});
shadow.remote.runtime.tap_support.stop = (function shadow$remote$runtime$tap_support$stop(p__54006){
var map__54007 = p__54006;
var map__54007__$1 = cljs.core.__destructure_map(map__54007);
var svc = map__54007__$1;
var tap_fn = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__54007__$1,new cljs.core.Keyword(null,"tap-fn","tap-fn",1573556461));
var runtime = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__54007__$1,new cljs.core.Keyword(null,"runtime","runtime",-1331573996));
cljs.core.remove_tap(tap_fn);

return shadow.remote.runtime.api.del_extension(runtime,new cljs.core.Keyword("shadow.remote.runtime.tap-support","ext","shadow.remote.runtime.tap-support/ext",1019069674));
});

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