// Compiled by ClojureScript 0.0-2138
goog.provide('lt.objs.clients');
goog.require('cljs.core');
goog.require('lt.util.js');
goog.require('clojure.string');
goog.require('clojure.string');
goog.require('lt.objs.notifos');
goog.require('lt.objs.notifos');
goog.require('lt.util.js');
goog.require('lt.object');
goog.require('lt.object');
lt.objs.clients.cs = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
lt.objs.clients.__GT_id = (function __GT_id(obj){return lt.object.__GT_id.call(null,obj);
});
lt.objs.clients.client_BANG_ = (function client_BANG_(type){var obj = lt.object.create.call(null,new cljs.core.Keyword("lt.objs.clients","client","lt.objs.clients/client",613325584));lt.object.add_tags.call(null,obj,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [type], null));
cljs.core.swap_BANG_.call(null,lt.objs.clients.cs,cljs.core.assoc,lt.objs.clients.__GT_id.call(null,obj),obj);
return obj;
});
lt.objs.clients.by_id = (function by_id(n){if(cljs.core.truth_(n))
{return cljs.core.deref.call(null,lt.objs.clients.cs).call(null,n);
} else
{return null;
}
});
lt.objs.clients.by_name = (function by_name(n){return cljs.core.first.call(null,cljs.core.filter.call(null,(function (p1__10825_SHARP_){return cljs.core._EQ_.call(null,n,new cljs.core.Keyword(null,"name","name",1017277949).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,p1__10825_SHARP_)));
}),cljs.core.vals.call(null,cljs.core.deref.call(null,lt.objs.clients.cs))));
});
lt.objs.clients.__GT_name = (function __GT_name(client){if(cljs.core.map_QMARK_.call(null,client))
{return new cljs.core.Keyword(null,"name","name",1017277949).cljs$core$IFn$_invoke$arity$1(client);
} else
{return client;
}
});
lt.objs.clients.merge_info = (function merge_info(client,info){var map__10827 = info;var map__10827__$1 = ((cljs.core.seq_QMARK_.call(null,map__10827))?cljs.core.apply.call(null,cljs.core.hash_map,map__10827):map__10827);var tags = cljs.core.get.call(null,map__10827__$1,new cljs.core.Keyword(null,"tags","tags",1017456523));var type = cljs.core.get.call(null,map__10827__$1,new cljs.core.Keyword(null,"type","type",1017479852));var commands = cljs.core.get.call(null,map__10827__$1,new cljs.core.Keyword(null,"commands","commands",4706336250));var info__$1 = cljs.core.dissoc.call(null,info,new cljs.core.Keyword(null,"tags","tags",1017456523));lt.object.merge_BANG_.call(null,client,cljs.core.merge.call(null,info__$1,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"commands","commands",4706336250),cljs.core.set.call(null,cljs.core.map.call(null,cljs.core.keyword,commands))], null)));
if(cljs.core.truth_(tags))
{return lt.object.add_tags.call(null,client,tags);
} else
{return null;
}
});
lt.objs.clients.handle_connection_BANG_ = (function handle_connection_BANG_(info){var temp__4090__auto__ = lt.objs.clients.by_id.call(null,new cljs.core.Keyword(null,"client-id","client-id",3404733903).cljs$core$IFn$_invoke$arity$1(info));if(cljs.core.truth_(temp__4090__auto__))
{var client = temp__4090__auto__;lt.objs.clients.merge_info.call(null,client,info);
lt.object.raise.call(null,client,new cljs.core.Keyword(null,"connect","connect",1965255772));
lt.object.raise.call(null,lt.objs.clients.clients,new cljs.core.Keyword(null,"connect","connect",1965255772),client);
return client;
} else
{var c = lt.objs.clients.client_BANG_.call(null,new cljs.core.Keyword(null,"tag","tag",1014018828).cljs$core$IFn$_invoke$arity$1(info));return handle_connection_BANG_.call(null,cljs.core.assoc.call(null,info,new cljs.core.Keyword(null,"client-id","client-id",3404733903),lt.objs.clients.__GT_id.call(null,c)));
}
});
lt.objs.clients.rem_BANG_ = (function rem_BANG_(client){var cname = new cljs.core.Keyword(null,"name","name",1017277949).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,client));cljs.core.swap_BANG_.call(null,lt.objs.clients.cs,cljs.core.dissoc,lt.objs.clients.__GT_id.call(null,client));
lt.object.raise.call(null,client,new cljs.core.Keyword(null,"disconnect","disconnect",1544309774));
lt.object.destroy_BANG_.call(null,client);
return lt.object.raise.call(null,lt.objs.clients.clients,new cljs.core.Keyword(null,"disconnect","disconnect",1544309774),cname);
});
lt.objs.clients.available_QMARK_ = (function available_QMARK_(client){return lt.objs.clients.by_id.call(null,lt.objs.clients.__GT_id.call(null,client));
});
lt.objs.clients.cb_gc_timeout = ((60 * 60) * 1000);
lt.objs.clients.callbacks = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
lt.objs.clients.cb_id = cljs.core.atom.call(null,-1);
lt.objs.clients.__GT_cb = (function __GT_cb(only_QMARK_,cb){if(cljs.core.truth_((function (){var and__3508__auto__ = only_QMARK_;if(cljs.core.truth_(and__3508__auto__))
{return cb;
} else
{return and__3508__auto__;
}
})()))
{return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [only_QMARK_,cb], null);
} else
{if(cljs.core.truth_(only_QMARK_))
{return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,only_QMARK_], null);
} else
{if(new cljs.core.Keyword(null,"else","else",1017020587))
{return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [only_QMARK_,cb], null);
} else
{return null;
}
}
}
});
lt.objs.clients.store_cb = (function store_cb(cb,id){return cljs.core.swap_BANG_.call(null,lt.objs.clients.callbacks,cljs.core.assoc,id,cb);
});
lt.objs.clients.rem_cb = (function rem_cb(cb){return cljs.core.swap_BANG_.call(null,lt.objs.clients.callbacks,(function (p1__10828_SHARP_){return cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.remove.call(null,(function (p__10832){var vec__10833 = p__10832;var k = cljs.core.nth.call(null,vec__10833,0,null);var vec__10834 = cljs.core.nth.call(null,vec__10833,1,null);var _ = cljs.core.nth.call(null,vec__10834,0,null);var v = cljs.core.nth.call(null,vec__10834,1,null);return cljs.core._EQ_.call(null,v,cb);
}),p1__10828_SHARP_));
}));
});
lt.objs.clients.callback_QMARK_ = (function callback_QMARK_(id){if(cljs.core.truth_(id))
{return cljs.core.deref.call(null,lt.objs.clients.callbacks).call(null,id);
} else
{return null;
}
});
lt.objs.clients.call = (function call(id,command,data){var vec__10836 = lt.objs.clients.callback_QMARK_.call(null,id);var only_QMARK_ = cljs.core.nth.call(null,vec__10836,0,null);var obj = cljs.core.nth.call(null,vec__10836,1,null);if(cljs.core.truth_(obj))
{if(cljs.core.fn_QMARK_.call(null,obj))
{obj.call(null,command,data);
} else
{lt.object.raise.call(null,obj,command,data);
}
if((cljs.core.not.call(null,only_QMARK_)) && (!(cljs.core.fn_QMARK_.call(null,obj))))
{return lt.object.raise.call(null,lt.objs.clients.clients,command,data);
} else
{return null;
}
} else
{return null;
}
});
lt.objs.clients.cb__GT_obj = (function cb__GT_obj(id){var vec__10838 = lt.objs.clients.callback_QMARK_.call(null,id);var only_QMARK_ = cljs.core.nth.call(null,vec__10838,0,null);var obj = cljs.core.nth.call(null,vec__10838,1,null);if(cljs.core.truth_(obj))
{if(cljs.core.fn_QMARK_.call(null,obj))
{return null;
} else
{return obj;
}
} else
{return null;
}
});
lt.objs.clients.__GT_message = (function __GT_message(command,data,only_QMARK_,cb){var cb__$1 = ((cljs.core.not.call(null,cb))?lt.objs.clients.clients:cb);var cb_id = ((cljs.core.fn_QMARK_.call(null,cb__$1))?cljs.core.gensym.call(null,"client-cb"):null);var vec__10840 = lt.objs.clients.__GT_cb.call(null,only_QMARK_,cb__$1);var only_QMARK___$1 = cljs.core.nth.call(null,vec__10840,0,null);var cb__$2 = cljs.core.nth.call(null,vec__10840,1,null);var pair = vec__10840;if(cljs.core.truth_(cb__$2))
{lt.objs.clients.store_cb.call(null,pair,cb_id);
} else
{}
return new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"cb","cb",1013907409),(function (){var or__3520__auto__ = cb_id;if(cljs.core.truth_(or__3520__auto__))
{return or__3520__auto__;
} else
{return lt.object.__GT_id.call(null,cb__$2);
}
})(),new cljs.core.Keyword(null,"command","command",1964298941),cljs.core.name.call(null,command),new cljs.core.Keyword(null,"data","data",1016980252),data], null);
});
lt.objs.clients.subpath_QMARK_ = (function subpath_QMARK_(root,sub){if(cljs.core.truth_(root))
{return cljs.core._EQ_.call(null,clojure.string.lower_case.call(null,sub).indexOf(clojure.string.lower_case.call(null,root)),0);
} else
{return null;
}
});
lt.objs.clients.discover_STAR_ = (function() {
var discover_STAR_ = null;
var discover_STAR___1 = (function (command){return discover_STAR_.call(null,command,null);
});
var discover_STAR___2 = (function (command,p__10842){var map__10846 = p__10842;var map__10846__$1 = ((cljs.core.seq_QMARK_.call(null,map__10846))?cljs.core.apply.call(null,cljs.core.hash_map,map__10846):map__10846);var path = cljs.core.get.call(null,map__10846__$1,new cljs.core.Keyword(null,"path","path",1017337751));var all = cljs.core.filter.call(null,(function (cur){var map__10847 = (((function (){var G__10848 = cur;if(G__10848)
{var bit__4164__auto__ = (G__10848.cljs$lang$protocol_mask$partition0$ & 32768);if((bit__4164__auto__) || (G__10848.cljs$core$IDeref$))
{return true;
} else
{if((!G__10848.cljs$lang$protocol_mask$partition0$))
{return cljs.core.native_satisfies_QMARK_.call(null,cljs.core.IDeref,G__10848);
} else
{return false;
}
}
} else
{return cljs.core.native_satisfies_QMARK_.call(null,cljs.core.IDeref,G__10848);
}
})())?cljs.core.deref.call(null,cur):cur);var map__10847__$1 = ((cljs.core.seq_QMARK_.call(null,map__10847))?cljs.core.apply.call(null,cljs.core.hash_map,map__10847):map__10847);var commands = cljs.core.get.call(null,map__10847__$1,new cljs.core.Keyword(null,"commands","commands",4706336250));var dir = cljs.core.get.call(null,map__10847__$1,new cljs.core.Keyword(null,"dir","dir",1014003711));var and__3508__auto__ = (cljs.core.truth_((function (){var and__3508__auto__ = path;if(cljs.core.truth_(and__3508__auto__))
{return dir;
} else
{return and__3508__auto__;
}
})())?lt.objs.clients.subpath_QMARK_.call(null,dir,path):true);if(cljs.core.truth_(and__3508__auto__))
{return cljs.core.get.call(null,commands,command);
} else
{return and__3508__auto__;
}
}),cljs.core.vals.call(null,cljs.core.deref.call(null,lt.objs.clients.cs)));var with_dir = cljs.core.filter.call(null,((function (all){
return (function (p1__10841_SHARP_){return cljs.core.deref.call(null,p1__10841_SHARP_).call(null,new cljs.core.Keyword(null,"dir","dir",1014003711));
});})(all))
,all);if(cljs.core.truth_((function (){var and__3508__auto__ = path;if(cljs.core.truth_(and__3508__auto__))
{return cljs.core.seq.call(null,with_dir);
} else
{return and__3508__auto__;
}
})()))
{return with_dir;
} else
{return all;
}
});
discover_STAR_ = function(command,p__10842){
switch(arguments.length){
case 1:
return discover_STAR___1.call(this,command);
case 2:
return discover_STAR___2.call(this,command,p__10842);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
discover_STAR_.cljs$core$IFn$_invoke$arity$1 = discover_STAR___1;
discover_STAR_.cljs$core$IFn$_invoke$arity$2 = discover_STAR___2;
return discover_STAR_;
})()
;
lt.objs.clients.discover = (function discover(command,info){var vec__10850 = lt.objs.clients.discover_STAR_.call(null,command,info);var found = cljs.core.nth.call(null,vec__10850,0,null);var others = cljs.core.nthnext.call(null,vec__10850,1);var all = vec__10850;if(cljs.core.not.call(null,found))
{return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"none","none",1017291434)], null);
} else
{if(cljs.core.truth_((function (){var and__3508__auto__ = found;if(cljs.core.truth_(and__3508__auto__))
{return cljs.core.not.call(null,cljs.core.seq.call(null,others));
} else
{return and__3508__auto__;
}
})()))
{return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"found","found",1111526132),found], null);
} else
{if(new cljs.core.Keyword(null,"else","else",1017020587))
{return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"select","select",4402849902),all], null);
} else
{return null;
}
}
}
});
/**
* @param {...*} var_args
*/
lt.objs.clients.send = (function() { 
var send__delegate = function (client,command,p__10851){var vec__10853 = p__10851;var data = cljs.core.nth.call(null,vec__10853,0,null);var only_QMARK_ = cljs.core.nth.call(null,vec__10853,1,null);var cb = cljs.core.nth.call(null,vec__10853,2,null);var message = lt.objs.clients.__GT_message.call(null,command,data,only_QMARK_,cb);return lt.object.raise.call(null,client,new cljs.core.Keyword(null,"try-send!","try-send!",4325864057),message);
};
var send = function (client,command,var_args){
var p__10851 = null;if (arguments.length > 2) {
  p__10851 = cljs.core.array_seq(Array.prototype.slice.call(arguments, 2),0);} 
return send__delegate.call(this,client,command,p__10851);};
send.cljs$lang$maxFixedArity = 2;
send.cljs$lang$applyTo = (function (arglist__10854){
var client = cljs.core.first(arglist__10854);
arglist__10854 = cljs.core.next(arglist__10854);
var command = cljs.core.first(arglist__10854);
var p__10851 = cljs.core.rest(arglist__10854);
return send__delegate(client,command,p__10851);
});
send.cljs$core$IFn$_invoke$arity$variadic = send__delegate;
return send;
})()
;
lt.objs.clients.close_BANG_ = (function close_BANG_(client){lt.objs.clients.send.call(null,client,new cljs.core.Keyword(null,"client.close","client.close",2801102215));
return lt.object.raise.call(null,client,new cljs.core.Keyword(null,"close!","close!",3951350939));
});
lt.objs.clients.cancel_all_BANG_ = (function cancel_all_BANG_(client){return lt.objs.clients.send.call(null,client,new cljs.core.Keyword(null,"client.cancel-all","client.cancel-all",3113005379));
});
lt.object.object_STAR_.call(null,new cljs.core.Keyword("lt.objs.clients","clients","lt.objs.clients/clients",2829334861),new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"connect","connect",1965255772),new cljs.core.Keyword(null,"disconnect","disconnect",1544309774),new cljs.core.Keyword(null,"message","message",1968829305)], null),new cljs.core.Keyword(null,"behaviors","behaviors",607554515),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword("lt.objs.clients","handle-message","lt.objs.clients/handle-message",943314615),new cljs.core.Keyword("lt.objs.clients","notify-connect","lt.objs.clients/notify-connect",1621214643)], null),new cljs.core.Keyword(null,"tags","tags",1017456523),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"clients","clients",1874491770),null], null), null),new cljs.core.Keyword(null,"init","init",1017141378),(function (){return null;
}));
lt.objs.clients.clients = lt.object.create.call(null,new cljs.core.Keyword("lt.objs.clients","clients","lt.objs.clients/clients",2829334861));
lt.objs.clients.__BEH__close_clients_on_closed = (function __BEH__close_clients_on_closed(app){var seq__10861 = cljs.core.seq.call(null,cljs.core.deref.call(null,lt.objs.clients.cs));var chunk__10862 = null;var count__10863 = 0;var i__10864 = 0;while(true){
if((i__10864 < count__10863))
{var vec__10865 = cljs.core._nth.call(null,chunk__10862,i__10864);var _ = cljs.core.nth.call(null,vec__10865,0,null);var c = cljs.core.nth.call(null,vec__10865,1,null);lt.objs.clients.close_BANG_.call(null,c);
{
var G__10867 = seq__10861;
var G__10868 = chunk__10862;
var G__10869 = count__10863;
var G__10870 = (i__10864 + 1);
seq__10861 = G__10867;
chunk__10862 = G__10868;
count__10863 = G__10869;
i__10864 = G__10870;
continue;
}
} else
{var temp__4092__auto__ = cljs.core.seq.call(null,seq__10861);if(temp__4092__auto__)
{var seq__10861__$1 = temp__4092__auto__;if(cljs.core.chunked_seq_QMARK_.call(null,seq__10861__$1))
{var c__4262__auto__ = cljs.core.chunk_first.call(null,seq__10861__$1);{
var G__10871 = cljs.core.chunk_rest.call(null,seq__10861__$1);
var G__10872 = c__4262__auto__;
var G__10873 = cljs.core.count.call(null,c__4262__auto__);
var G__10874 = 0;
seq__10861 = G__10871;
chunk__10862 = G__10872;
count__10863 = G__10873;
i__10864 = G__10874;
continue;
}
} else
{var vec__10866 = cljs.core.first.call(null,seq__10861__$1);var _ = cljs.core.nth.call(null,vec__10866,0,null);var c = cljs.core.nth.call(null,vec__10866,1,null);lt.objs.clients.close_BANG_.call(null,c);
{
var G__10875 = cljs.core.next.call(null,seq__10861__$1);
var G__10876 = null;
var G__10877 = 0;
var G__10878 = 0;
seq__10861 = G__10875;
chunk__10862 = G__10876;
count__10863 = G__10877;
i__10864 = G__10878;
continue;
}
}
} else
{return null;
}
}
break;
}
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.clients","close-clients-on-closed","lt.objs.clients/close-clients-on-closed",637496405),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.clients.__BEH__close_clients_on_closed,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"closing","closing",1880444967),null], null), null));
lt.objs.clients.__BEH__on_destroy_remove_cb = (function __BEH__on_destroy_remove_cb(this$){return lt.objs.clients.rem_cb.call(null,this$);
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.clients","on-destroy-remove-cb","lt.objs.clients/on-destroy-remove-cb",1411509012),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.clients.__BEH__on_destroy_remove_cb,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"destroy","destroy",2571277164),null], null), null));
lt.objs.clients.__BEH__raise_on_object = (function __BEH__raise_on_object(this$,p__10879){var vec__10881 = p__10879;var id = cljs.core.nth.call(null,vec__10881,0,null);var command = cljs.core.nth.call(null,vec__10881,1,null);var data = cljs.core.nth.call(null,vec__10881,2,null);return lt.object.raise.call(null,lt.object.by_id.call(null,id),cljs.core.keyword.call(null,command),data);
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.clients","raise-on-object","lt.objs.clients/raise-on-object",4358681993),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.clients.__BEH__raise_on_object,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"clients.raise-on-object","clients.raise-on-object",4257665496),null], null), null));
lt.objs.clients.__BEH__handle_message = (function __BEH__handle_message(obj,p__10882){var vec__10884 = p__10882;var cb_id = cljs.core.nth.call(null,vec__10884,0,null);var command = cljs.core.nth.call(null,vec__10884,1,null);var data = cljs.core.nth.call(null,vec__10884,2,null);var msg = vec__10884;if(cljs.core.truth_(lt.objs.clients.callback_QMARK_.call(null,cb_id)))
{return lt.objs.clients.call.call(null,cb_id,cljs.core.keyword.call(null,command),data);
} else
{if(cljs.core.truth_(lt.object.by_id.call(null,cb_id)))
{return lt.object.raise.call(null,lt.object.by_id.call(null,cb_id),cljs.core.keyword.call(null,command),data);
} else
{if(new cljs.core.Keyword(null,"else","else",1017020587))
{return lt.object.raise.call(null,lt.objs.clients.clients,cljs.core.keyword.call(null,command),data);
} else
{return null;
}
}
}
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.clients","handle-message","lt.objs.clients/handle-message",943314615),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.clients.__BEH__handle_message,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"message","message",1968829305),null], null), null));
lt.objs.clients.__BEH__notify_connect = (function __BEH__notify_connect(obj,client){return lt.objs.notifos.set_msg_BANG_.call(null,[cljs.core.str("Connected to "),cljs.core.str(new cljs.core.Keyword(null,"name","name",1017277949).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,client)))].join(''));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.clients","notify-connect","lt.objs.clients/notify-connect",1621214643),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.clients.__BEH__notify_connect,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"connect","connect",1965255772),null], null), null));
lt.objs.clients.placeholder = (function placeholder(){return lt.object.add_tags.call(null,lt.object.create.call(null,new cljs.core.Keyword("lt.objs.clients","client","lt.objs.clients/client",613325584)),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"client.placeholder","client.placeholder",3878144834)], null));
});
lt.objs.clients.placeholder_QMARK_ = (function placeholder_QMARK_(c){return lt.object.has_tag_QMARK_.call(null,c,new cljs.core.Keyword(null,"client.placeholder","client.placeholder",3878144834));
});
lt.objs.clients.swap_client_BANG_ = (function swap_client_BANG_(a,b){var seq__10889_10893 = cljs.core.seq.call(null,new cljs.core.Keyword(null,"queue","queue",1121848451).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,a)));var chunk__10890_10894 = null;var count__10891_10895 = 0;var i__10892_10896 = 0;while(true){
if((i__10892_10896 < count__10891_10895))
{var item_10897 = cljs.core._nth.call(null,chunk__10890_10894,i__10892_10896);lt.object.raise.call(null,b,new cljs.core.Keyword(null,"try-send!","try-send!",4325864057),item_10897);
{
var G__10898 = seq__10889_10893;
var G__10899 = chunk__10890_10894;
var G__10900 = count__10891_10895;
var G__10901 = (i__10892_10896 + 1);
seq__10889_10893 = G__10898;
chunk__10890_10894 = G__10899;
count__10891_10895 = G__10900;
i__10892_10896 = G__10901;
continue;
}
} else
{var temp__4092__auto___10902 = cljs.core.seq.call(null,seq__10889_10893);if(temp__4092__auto___10902)
{var seq__10889_10903__$1 = temp__4092__auto___10902;if(cljs.core.chunked_seq_QMARK_.call(null,seq__10889_10903__$1))
{var c__4262__auto___10904 = cljs.core.chunk_first.call(null,seq__10889_10903__$1);{
var G__10905 = cljs.core.chunk_rest.call(null,seq__10889_10903__$1);
var G__10906 = c__4262__auto___10904;
var G__10907 = cljs.core.count.call(null,c__4262__auto___10904);
var G__10908 = 0;
seq__10889_10893 = G__10905;
chunk__10890_10894 = G__10906;
count__10891_10895 = G__10907;
i__10892_10896 = G__10908;
continue;
}
} else
{var item_10909 = cljs.core.first.call(null,seq__10889_10903__$1);lt.object.raise.call(null,b,new cljs.core.Keyword(null,"try-send!","try-send!",4325864057),item_10909);
{
var G__10910 = cljs.core.next.call(null,seq__10889_10903__$1);
var G__10911 = null;
var G__10912 = 0;
var G__10913 = 0;
seq__10889_10893 = G__10910;
chunk__10890_10894 = G__10911;
count__10891_10895 = G__10912;
i__10892_10896 = G__10913;
continue;
}
}
} else
{}
}
break;
}
return lt.object.raise.call(null,a,new cljs.core.Keyword(null,"swapped","swapped",3497510414),b);
});
lt.object.object_STAR_.call(null,new cljs.core.Keyword("lt.objs.clients","client","lt.objs.clients/client",613325584),new cljs.core.Keyword(null,"queue","queue",1121848451),cljs.core.PersistentVector.EMPTY,new cljs.core.Keyword(null,"tags","tags",1017456523),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"client","client",3951159101),null], null), null));
lt.objs.clients.__BEH__try_send = (function __BEH__try_send(this$,msg){if(cljs.core.truth_(new cljs.core.Keyword(null,"connected","connected",4729661051).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,this$))))
{return lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"send!","send!",1123226891),msg);
} else
{return lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"queue!","queue!",4360174754),msg);
}
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.clients","try-send","lt.objs.clients/try-send",3878204287),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.clients.__BEH__try_send,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"try-send!","try-send!",4325864057),null], null), null));
lt.objs.clients.__BEH__queue_BANG_ = (function __BEH__queue_BANG_(this$,msg){return lt.object.update_BANG_.call(null,this$,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"queue","queue",1121848451)], null),cljs.core.conj,msg);
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.clients","queue!","lt.objs.clients/queue!",1558951525),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.clients.__BEH__queue_BANG_,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"queue!","queue!",4360174754),null], null), null));
lt.objs.clients.__BEH__on_connect_drain = (function __BEH__on_connect_drain(this$){lt.object.merge_BANG_.call(null,this$,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"connected","connected",4729661051),true], null));
var seq__10918_10922 = cljs.core.seq.call(null,new cljs.core.Keyword(null,"queue","queue",1121848451).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,this$)));var chunk__10919_10923 = null;var count__10920_10924 = 0;var i__10921_10925 = 0;while(true){
if((i__10921_10925 < count__10920_10924))
{var q_10926 = cljs.core._nth.call(null,chunk__10919_10923,i__10921_10925);lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"send!","send!",1123226891),q_10926);
cljs.core.doall.call(null,cljs.core.range.call(null,10000));
{
var G__10927 = seq__10918_10922;
var G__10928 = chunk__10919_10923;
var G__10929 = count__10920_10924;
var G__10930 = (i__10921_10925 + 1);
seq__10918_10922 = G__10927;
chunk__10919_10923 = G__10928;
count__10920_10924 = G__10929;
i__10921_10925 = G__10930;
continue;
}
} else
{var temp__4092__auto___10931 = cljs.core.seq.call(null,seq__10918_10922);if(temp__4092__auto___10931)
{var seq__10918_10932__$1 = temp__4092__auto___10931;if(cljs.core.chunked_seq_QMARK_.call(null,seq__10918_10932__$1))
{var c__4262__auto___10933 = cljs.core.chunk_first.call(null,seq__10918_10932__$1);{
var G__10934 = cljs.core.chunk_rest.call(null,seq__10918_10932__$1);
var G__10935 = c__4262__auto___10933;
var G__10936 = cljs.core.count.call(null,c__4262__auto___10933);
var G__10937 = 0;
seq__10918_10922 = G__10934;
chunk__10919_10923 = G__10935;
count__10920_10924 = G__10936;
i__10921_10925 = G__10937;
continue;
}
} else
{var q_10938 = cljs.core.first.call(null,seq__10918_10932__$1);lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"send!","send!",1123226891),q_10938);
cljs.core.doall.call(null,cljs.core.range.call(null,10000));
{
var G__10939 = cljs.core.next.call(null,seq__10918_10932__$1);
var G__10940 = null;
var G__10941 = 0;
var G__10942 = 0;
seq__10918_10922 = G__10939;
chunk__10919_10923 = G__10940;
count__10920_10924 = G__10941;
i__10921_10925 = G__10942;
continue;
}
}
} else
{}
}
break;
}
return lt.object.merge_BANG_.call(null,this$,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"queue","queue",1121848451),cljs.core.PersistentVector.EMPTY], null));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.clients","on-connect-drain","lt.objs.clients/on-connect-drain",776020788),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.clients.__BEH__on_connect_drain,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"connect","connect",1965255772),null], null), null));
lt.objs.clients.__BEH__remove_placeholder_on_swapped = (function __BEH__remove_placeholder_on_swapped(this$){return lt.object.destroy_BANG_.call(null,this$);
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.clients","remove-placeholder-on-swapped","lt.objs.clients/remove-placeholder-on-swapped",1591563750),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.clients.__BEH__remove_placeholder_on_swapped,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"swapped","swapped",3497510414),null], null), null));
