// Compiled by ClojureScript 1.10.520 {}
goog.provide('lsobot.acmi');
goog.require('cljs.core');
goog.require('clojure.string');
lsobot.acmi.log = cljs.core.constantly.call(null,null);
lsobot.acmi.id_digits = new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 22, ["A",null,"a",null,"B",null,"b",null,"C",null,"c",null,"D",null,"d",null,"E",null,"e",null,"F",null,"f",null,"0",null,"1",null,"2",null,"3",null,"4",null,"5",null,"6",null,"7",null,"8",null,"9",null], null), null);
lsobot.acmi.id = null;
lsobot.acmi.event = null;
lsobot.acmi.entity_info = null;
lsobot.acmi.frame = null;
lsobot.acmi.file = null;
lsobot.acmi.parse_float = (function lsobot$acmi$parse_float(s){
lsobot.acmi.log.call(null,"parsing",new cljs.core.Keyword(null,"s","s",1705939918),s);

if(cljs.core.empty_QMARK_.call(null,s)){
return null;
} else {
return (new Number(s));
}
});
lsobot.acmi.fields = cljs.core.PersistentHashMap.fromArrays(["T","Importance","AOA","Parent","Country","Type","LockedTarget","Mach","LandingGear","Length","DragChute","HDG","Tailhook","Coalition","Squawk","Pilot","Width","Flaps","Throttle","Parachute","Debug","IAS","Slot","AirBrakes","Label","Height","Afterburner","Registration","Name","Group","Color","TAS"],[new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"location","location",1815599388)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"float","float",-1732389368),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","important","lsobot.acmi/important",62673791)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"float","float",-1732389368),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","aoa","lsobot.acmi/aoa",2131897388)], null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","parent","lsobot.acmi/parent",394340088)], null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","country","lsobot.acmi/country",1053508738)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"taglist","taglist",328856316),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","object-type","lsobot.acmi/object-type",-1018781700)], null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","locked-target","lsobot.acmi/locked-target",-1988244278)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"float","float",-1732389368),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","mach","lsobot.acmi/mach",939857592)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"float","float",-1732389368),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","landing-gear","lsobot.acmi/landing-gear",1703479476)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"float","float",-1732389368),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","length","lsobot.acmi/length",-954780925)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"float","float",-1732389368),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","drag-chute","lsobot.acmi/drag-chute",1632847969)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"float","float",-1732389368),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","heading","lsobot.acmi/heading",1518406858)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"float","float",-1732389368),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","tailhook","lsobot.acmi/tailhook",-1331093852)], null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","coalition","lsobot.acmi/coalition",-2113528142)], null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","squawk","lsobot.acmi/squawk",-1133773698)], null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","pilot","lsobot.acmi/pilot",1075341034)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"float","float",-1732389368),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","width","lsobot.acmi/width",1019722774)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"float","float",-1732389368),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","flaps","lsobot.acmi/flaps",1377079743)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"float","float",-1732389368),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","throttle","lsobot.acmi/throttle",1164527755)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"float","float",-1732389368),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","parachute","lsobot.acmi/parachute",2122253126)], null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","debug","lsobot.acmi/debug",202225561)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"float","float",-1732389368),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","indicated-airspeed","lsobot.acmi/indicated-airspeed",-322597664)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"integer","integer",-604721710),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","slot","lsobot.acmi/slot",-894535496)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"float","float",-1732389368),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","airbrakes","lsobot.acmi/airbrakes",-1297796943)], null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","label","lsobot.acmi/label",-1032278787)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"float","float",-1732389368),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","height","lsobot.acmi/height",-1060386511)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"float","float",-1732389368),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","afterburner","lsobot.acmi/afterburner",1404556168)], null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","registration","lsobot.acmi/registration",-326743862)], null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","name","lsobot.acmi/name",298845436)], null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","group","lsobot.acmi/group",-821213843)], null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","color","lsobot.acmi/color",-369571990)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"parse-as","parse-as",122784579),new cljs.core.Keyword(null,"float","float",-1732389368),new cljs.core.Keyword(null,"key","key",-1516042587),new cljs.core.Keyword("lsobot.acmi","true-airspeed","lsobot.acmi/true-airspeed",-832535618)], null)]);
if((typeof lsobot !== 'undefined') && (typeof lsobot.acmi !== 'undefined') && (typeof lsobot.acmi.parse_field !== 'undefined')){
} else {
lsobot.acmi.parse_field = (function (){var method_table__4613__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var prefer_table__4614__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var method_cache__4615__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var cached_hierarchy__4616__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var hierarchy__4617__auto__ = cljs.core.get.call(null,cljs.core.PersistentArrayMap.EMPTY,new cljs.core.Keyword(null,"hierarchy","hierarchy",-1053470341),cljs.core.get_global_hierarchy.call(null));
return (new cljs.core.MultiFn(cljs.core.symbol.call(null,"lsobot.acmi","parse-field"),((function (method_table__4613__auto__,prefer_table__4614__auto__,method_cache__4615__auto__,cached_hierarchy__4616__auto__,hierarchy__4617__auto__){
return (function (p__34868){
var vec__34869 = p__34868;
var k = cljs.core.nth.call(null,vec__34869,(0),null);
var v = cljs.core.nth.call(null,vec__34869,(1),null);
return new cljs.core.Keyword(null,"parse-as","parse-as",122784579).cljs$core$IFn$_invoke$arity$1(lsobot.acmi.fields.call(null,k));
});})(method_table__4613__auto__,prefer_table__4614__auto__,method_cache__4615__auto__,cached_hierarchy__4616__auto__,hierarchy__4617__auto__))
,new cljs.core.Keyword(null,"default","default",-1987822328),hierarchy__4617__auto__,method_table__4613__auto__,prefer_table__4614__auto__,method_cache__4615__auto__,cached_hierarchy__4616__auto__));
})();
}
/**
 * Split string `s` on character `c`.
 */
lsobot.acmi.char_split = (function lsobot$acmi$char_split(s,c){
var G__34875 = s;
var vec__34876 = G__34875;
var seq__34877 = cljs.core.seq.call(null,vec__34876);
var first__34878 = cljs.core.first.call(null,seq__34877);
var seq__34877__$1 = cljs.core.next.call(null,seq__34877);
var current = first__34878;
var more = seq__34877__$1;
var segments = cljs.core.PersistentVector.EMPTY;
var acc = "";
var G__34875__$1 = G__34875;
var segments__$1 = segments;
var acc__$1 = acc;
while(true){
var vec__34882 = G__34875__$1;
var seq__34883 = cljs.core.seq.call(null,vec__34882);
var first__34884 = cljs.core.first.call(null,seq__34883);
var seq__34883__$1 = cljs.core.next.call(null,seq__34883);
var current__$1 = first__34884;
var more__$1 = seq__34883__$1;
var segments__$2 = segments__$1;
var acc__$2 = acc__$1;
if((current__$1 == null)){
return cljs.core.conj.call(null,segments__$2,acc__$2);
} else {
if(cljs.core._EQ_.call(null,current__$1,c)){
var G__34885 = more__$1;
var G__34886 = cljs.core.conj.call(null,segments__$2,acc__$2);
var G__34887 = "";
G__34875__$1 = G__34885;
segments__$1 = G__34886;
acc__$1 = G__34887;
continue;
} else {
var G__34888 = more__$1;
var G__34889 = segments__$2;
var G__34890 = [acc__$2,cljs.core.str.cljs$core$IFn$_invoke$arity$1(current__$1)].join('');
G__34875__$1 = G__34888;
segments__$1 = G__34889;
acc__$1 = G__34890;
continue;

}
}
break;
}
});
cljs.core._add_method.call(null,lsobot.acmi.parse_field,new cljs.core.Keyword(null,"location","location",1815599388),(function (p__34891){
var vec__34892 = p__34891;
var _ = cljs.core.nth.call(null,vec__34892,(0),null);
var v = cljs.core.nth.call(null,vec__34892,(1),null);
var parts = cljs.core.map.call(null,lsobot.acmi.parse_float,lsobot.acmi.char_split.call(null,v,"|"));
if((cljs.core.count.call(null,parts) < (6))){
var vec__34895 = parts;
var long$ = cljs.core.nth.call(null,vec__34895,(0),null);
var lat = cljs.core.nth.call(null,vec__34895,(1),null);
var alt = cljs.core.nth.call(null,vec__34895,(2),null);
var u = cljs.core.nth.call(null,vec__34895,(3),null);
var v__$1 = cljs.core.nth.call(null,vec__34895,(4),null);
var G__34898 = cljs.core.PersistentArrayMap.EMPTY;
var G__34898__$1 = (cljs.core.truth_(long$)?cljs.core.assoc.call(null,G__34898,new cljs.core.Keyword("lsobot.acmi","long","lsobot.acmi/long",681286936),long$):G__34898);
var G__34898__$2 = (cljs.core.truth_(lat)?cljs.core.assoc.call(null,G__34898__$1,new cljs.core.Keyword("lsobot.acmi","lat","lsobot.acmi/lat",-2110849924),lat):G__34898__$1);
var G__34898__$3 = (cljs.core.truth_(alt)?cljs.core.assoc.call(null,G__34898__$2,new cljs.core.Keyword("lsobot.acmi","alt","lsobot.acmi/alt",1403266519),alt):G__34898__$2);
var G__34898__$4 = (cljs.core.truth_(u)?cljs.core.assoc.call(null,G__34898__$3,new cljs.core.Keyword("lsobot.acmi","u","lsobot.acmi/u",-2031949174),u):G__34898__$3);
if(cljs.core.truth_(v__$1)){
return cljs.core.assoc.call(null,G__34898__$4,new cljs.core.Keyword("lsobot.acmi","v","lsobot.acmi/v",855883566),v__$1);
} else {
return G__34898__$4;
}
} else {
var vec__34899 = parts;
var long$ = cljs.core.nth.call(null,vec__34899,(0),null);
var lat = cljs.core.nth.call(null,vec__34899,(1),null);
var alt = cljs.core.nth.call(null,vec__34899,(2),null);
var roll = cljs.core.nth.call(null,vec__34899,(3),null);
var pitch = cljs.core.nth.call(null,vec__34899,(4),null);
var yaw = cljs.core.nth.call(null,vec__34899,(5),null);
var u = cljs.core.nth.call(null,vec__34899,(6),null);
var v__$1 = cljs.core.nth.call(null,vec__34899,(7),null);
var heading = cljs.core.nth.call(null,vec__34899,(8),null);
var G__34902 = cljs.core.PersistentArrayMap.EMPTY;
var G__34902__$1 = (cljs.core.truth_(long$)?cljs.core.assoc.call(null,G__34902,new cljs.core.Keyword("lsobot.acmi","long","lsobot.acmi/long",681286936),long$):G__34902);
var G__34902__$2 = (cljs.core.truth_(lat)?cljs.core.assoc.call(null,G__34902__$1,new cljs.core.Keyword("lsobot.acmi","lat","lsobot.acmi/lat",-2110849924),lat):G__34902__$1);
var G__34902__$3 = (cljs.core.truth_(alt)?cljs.core.assoc.call(null,G__34902__$2,new cljs.core.Keyword("lsobot.acmi","alt","lsobot.acmi/alt",1403266519),alt):G__34902__$2);
var G__34902__$4 = (cljs.core.truth_(roll)?cljs.core.assoc.call(null,G__34902__$3,new cljs.core.Keyword("lsobot.acmi","roll","lsobot.acmi/roll",1955569772),roll):G__34902__$3);
var G__34902__$5 = (cljs.core.truth_(pitch)?cljs.core.assoc.call(null,G__34902__$4,new cljs.core.Keyword("lsobot.acmi","pitch","lsobot.acmi/pitch",-1941837447),pitch):G__34902__$4);
var G__34902__$6 = (cljs.core.truth_(yaw)?cljs.core.assoc.call(null,G__34902__$5,new cljs.core.Keyword("lsobot.acmi","yaw","lsobot.acmi/yaw",-1018224710),yaw):G__34902__$5);
var G__34902__$7 = (cljs.core.truth_(u)?cljs.core.assoc.call(null,G__34902__$6,new cljs.core.Keyword("lsobot.acmi","u","lsobot.acmi/u",-2031949174),u):G__34902__$6);
var G__34902__$8 = (cljs.core.truth_(v__$1)?cljs.core.assoc.call(null,G__34902__$7,new cljs.core.Keyword("lsobot.acmi","v","lsobot.acmi/v",855883566),v__$1):G__34902__$7);
if(cljs.core.truth_(heading)){
return cljs.core.assoc.call(null,G__34902__$8,new cljs.core.Keyword("lsobot.acmi","heading","lsobot.acmi/heading",1518406858),heading);
} else {
return G__34902__$8;
}
}
}));
cljs.core._add_method.call(null,lsobot.acmi.parse_field,new cljs.core.Keyword(null,"taglist","taglist",328856316),(function (p__34903){
var vec__34904 = p__34903;
var k = cljs.core.nth.call(null,vec__34904,(0),null);
var v = cljs.core.nth.call(null,vec__34904,(1),null);
return cljs.core.PersistentArrayMap.createAsIfByAssoc([new cljs.core.Keyword(null,"key","key",-1516042587).cljs$core$IFn$_invoke$arity$1(lsobot.acmi.fields.call(null,k)),cljs.core.set.call(null,clojure.string.split.call(null,v,/\+/))]);
}));
cljs.core._add_method.call(null,lsobot.acmi.parse_field,new cljs.core.Keyword(null,"default","default",-1987822328),(function (p__34907){
var vec__34908 = p__34907;
var k = cljs.core.nth.call(null,vec__34908,(0),null);
var v = cljs.core.nth.call(null,vec__34908,(1),null);
return cljs.core.PersistentArrayMap.createAsIfByAssoc([(function (){var or__4131__auto__ = new cljs.core.Keyword(null,"key","key",-1516042587).cljs$core$IFn$_invoke$arity$1(lsobot.acmi.fields.call(null,k));
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return k;
}
})(),v]);
}));
cljs.core._add_method.call(null,lsobot.acmi.parse_field,new cljs.core.Keyword(null,"float","float",-1732389368),(function (p__34911){
var vec__34912 = p__34911;
var k = cljs.core.nth.call(null,vec__34912,(0),null);
var v = cljs.core.nth.call(null,vec__34912,(1),null);
return cljs.core.PersistentArrayMap.createAsIfByAssoc([new cljs.core.Keyword(null,"key","key",-1516042587).cljs$core$IFn$_invoke$arity$1(lsobot.acmi.fields.call(null,k)),lsobot.acmi.parse_float.call(null,v)]);
}));
lsobot.acmi.event_types = new cljs.core.PersistentArrayMap(null, 7, ["Message",new cljs.core.Keyword("lsobot.acmi","message","lsobot.acmi/message",-1139270737),"Bookmark",new cljs.core.Keyword("lsobot.acmi","bookmark","lsobot.acmi/bookmark",1806895191),"Debug",new cljs.core.Keyword("lsobot.acmi","debug","lsobot.acmi/debug",202225561),"LeftArea",new cljs.core.Keyword("lsobot.acmi","left-area","lsobot.acmi/left-area",-157896482),"Destroyed",new cljs.core.Keyword("lsobot.acmi","destroyed","lsobot.acmi/destroyed",986700172),"TakenOff",new cljs.core.Keyword("lsobot.acmi","takeoff","lsobot.acmi/takeoff",-685418964),"Landed",new cljs.core.Keyword("lsobot.acmi","landed","lsobot.acmi/landed",758138957)], null);
lsobot.acmi.parse_event = (function lsobot$acmi$parse_event(event_data){
var vec__34915 = clojure.string.split.call(null,event_data,/\|/);
var seq__34916 = cljs.core.seq.call(null,vec__34915);
var first__34917 = cljs.core.first.call(null,seq__34916);
var seq__34916__$1 = cljs.core.next.call(null,seq__34916);
var event_type = first__34917;
var more = seq__34916__$1;
var ids = ((((1) < cljs.core.count.call(null,more)))?cljs.core.butlast.call(null,more):null);
var text = cljs.core.last.call(null,more);
return new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword("lsobot.acmi","event-type","lsobot.acmi/event-type",1735575154),lsobot.acmi.event_types.call(null,event_type),new cljs.core.Keyword("lsobot.acmi","ids","lsobot.acmi/ids",675797055),ids,new cljs.core.Keyword("lsobot.acmi","text","lsobot.acmi/text",1096477988),text], null);
});
lsobot.acmi.parse_entity_line = (function lsobot$acmi$parse_entity_line(line){
var vec__34919 = clojure.string.split.call(null,line,/,/);
var seq__34920 = cljs.core.seq.call(null,vec__34919);
var first__34921 = cljs.core.first.call(null,seq__34920);
var seq__34920__$1 = cljs.core.next.call(null,seq__34920);
var id = first__34921;
var fields = seq__34920__$1;
var raw = cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.map.call(null,((function (vec__34919,seq__34920,first__34921,seq__34920__$1,id,fields){
return (function (p1__34918_SHARP_){
return clojure.string.split.call(null,p1__34918_SHARP_,/=/);
});})(vec__34919,seq__34920,first__34921,seq__34920__$1,id,fields))
,fields));
if(cljs.core.contains_QMARK_.call(null,raw,"Event")){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"event","event",301435442),lsobot.acmi.parse_event.call(null,cljs.core.get.call(null,raw,"Event"))], null);
} else {
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"entity-info","entity-info",1277638547),cljs.core.PersistentArrayMap.createAsIfByAssoc([id,cljs.core.assoc.call(null,cljs.core.reduce.call(null,cljs.core.merge,cljs.core.PersistentArrayMap.EMPTY,cljs.core.map.call(null,lsobot.acmi.parse_field,raw)),new cljs.core.Keyword("lsobot.acmi","removed?","lsobot.acmi/removed?",2003784097),false)])], null);
}
});
/**
 * Returns [line-type line-info] given a line from an ACMI file
 */
lsobot.acmi.parse_line = (function lsobot$acmi$parse_line(line){
if(cljs.core.truth_(line.startsWith("//"))){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"comment","comment",532206069)], null);
} else {
if(cljs.core.truth_(line.startsWith("#"))){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"timestamp","timestamp",579478971),(new Number(cljs.core.subs.call(null,line,(1))))], null);
} else {
if(cljs.core.truth_(line.startsWith("-"))){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"deletion","deletion",297724078),cljs.core.subs.call(null,line,(1))], null);
} else {
return lsobot.acmi.parse_entity_line.call(null,line);

}
}
}
});
lsobot.acmi.read_acmi = (function lsobot$acmi$read_acmi(var_args){
var G__34923 = arguments.length;
switch (G__34923) {
case 1:
return lsobot.acmi.read_acmi.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));

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

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

}
});

lsobot.acmi.read_acmi.cljs$core$IFn$_invoke$arity$1 = (function (contents){
return lsobot.acmi.read_acmi.call(null,contents,cljs.core.constantly.call(null,true));
});

lsobot.acmi.read_acmi.cljs$core$IFn$_invoke$arity$2 = (function (contents,entity_pred){
var lines = cljs.core.drop.call(null,(2),clojure.string.split.call(null,contents,"\n"));
lsobot.acmi.log.call(null,new cljs.core.Keyword(null,"lines","lines",-700165781),cljs.core.count.call(null,lines));

var G__34927 = lines;
var vec__34928 = G__34927;
var seq__34929 = cljs.core.seq.call(null,vec__34928);
var first__34930 = cljs.core.first.call(null,seq__34929);
var seq__34929__$1 = cljs.core.next.call(null,seq__34929);
var line = first__34930;
var more_lines = seq__34929__$1;
var entities = cljs.core.PersistentArrayMap.EMPTY;
var events = cljs.core.PersistentVector.EMPTY;
var t = 0.0;
var frames = cljs.core.PersistentVector.EMPTY;
var G__34927__$1 = G__34927;
var entities__$1 = entities;
var events__$1 = events;
var t__$1 = t;
var frames__$1 = frames;
while(true){
var vec__34938 = G__34927__$1;
var seq__34939 = cljs.core.seq.call(null,vec__34938);
var first__34940 = cljs.core.first.call(null,seq__34939);
var seq__34939__$1 = cljs.core.next.call(null,seq__34939);
var line__$1 = first__34940;
var more_lines__$1 = seq__34939__$1;
var entities__$2 = entities__$1;
var events__$2 = events__$1;
var t__$2 = t__$1;
var frames__$2 = frames__$1;
lsobot.acmi.log.call(null,new cljs.core.Keyword(null,"t","t",-1397832519),t__$2,new cljs.core.Keyword(null,"frames","frames",1765687497),cljs.core.count.call(null,frames__$2));

if(cljs.core.not.call(null,line__$1)){
return new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword("lsobot.acmi","frames","lsobot.acmi/frames",1165126782),cljs.core.conj.call(null,frames__$2,new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword("lsobot.acmi","t","lsobot.acmi/t",1347958254),t__$2,new cljs.core.Keyword("lsobot.acmi","events","lsobot.acmi/events",781376958),events__$2,new cljs.core.Keyword("lsobot.acmi","entities","lsobot.acmi/entities",1464472374),entities__$2], null))], null);
} else {
var vec__34941 = lsobot.acmi.parse_line.call(null,line__$1);
var type = cljs.core.nth.call(null,vec__34941,(0),null);
var line_info = cljs.core.nth.call(null,vec__34941,(1),null);
lsobot.acmi.log.call(null,new cljs.core.Keyword(null,"line","line",212345235),line__$1,new cljs.core.Keyword(null,"line-info","line-info",998942046),cljs.core.pr_str.call(null,line_info));

var G__34944 = type;
var G__34944__$1 = (((G__34944 instanceof cljs.core.Keyword))?G__34944.fqn:null);
switch (G__34944__$1) {
case "comment":
var G__34947 = more_lines__$1;
var G__34948 = entities__$2;
var G__34949 = cljs.core.PersistentVector.EMPTY;
var G__34950 = t__$2;
var G__34951 = frames__$2;
G__34927__$1 = G__34947;
entities__$1 = G__34948;
events__$1 = G__34949;
t__$1 = G__34950;
frames__$1 = G__34951;
continue;

break;
case "timestamp":
var G__34952 = more_lines__$1;
var G__34953 = entities__$2;
var G__34954 = cljs.core.PersistentVector.EMPTY;
var G__34955 = line_info;
var G__34956 = cljs.core.conj.call(null,frames__$2,new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword("lsobot.acmi","t","lsobot.acmi/t",1347958254),t__$2,new cljs.core.Keyword("lsobot.acmi","events","lsobot.acmi/events",781376958),events__$2,new cljs.core.Keyword("lsobot.acmi","entities","lsobot.acmi/entities",1464472374),entities__$2], null));
G__34927__$1 = G__34952;
entities__$1 = G__34953;
events__$1 = G__34954;
t__$1 = G__34955;
frames__$1 = G__34956;
continue;

break;
case "entity-info":
var G__34957 = more_lines__$1;
var G__34958 = (function (){var id = cljs.core.first.call(null,cljs.core.keys.call(null,line_info));
var props = cljs.core.first.call(null,cljs.core.vals.call(null,line_info));
if(cljs.core.truth_((function (){var or__4131__auto__ = entity_pred.call(null,props);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return entity_pred.call(null,cljs.core.get.call(null,entities__$2,id));
}
})())){
return cljs.core.merge_with.call(null,cljs.core.merge,entities__$2,line_info);
} else {
return entities__$2;
}
})();
var G__34959 = events__$2;
var G__34960 = t__$2;
var G__34961 = frames__$2;
G__34927__$1 = G__34957;
entities__$1 = G__34958;
events__$1 = G__34959;
t__$1 = G__34960;
frames__$1 = G__34961;
continue;

break;
case "event":
var G__34962 = more_lines__$1;
var G__34963 = entities__$2;
var G__34964 = cljs.core.conj.call(null,events__$2,line_info);
var G__34965 = t__$2;
var G__34966 = frames__$2;
G__34927__$1 = G__34962;
entities__$1 = G__34963;
events__$1 = G__34964;
t__$1 = G__34965;
frames__$1 = G__34966;
continue;

break;
case "deletion":
var G__34967 = more_lines__$1;
var G__34968 = (function (){var id = line_info;
if(cljs.core.contains_QMARK_.call(null,entities__$2,id)){
return cljs.core.assoc_in.call(null,entities__$2,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [line_info,new cljs.core.Keyword("lsobot.acmi","removed?","lsobot.acmi/removed?",2003784097)], null),true);
} else {
return entities__$2;
}
})();
var G__34969 = events__$2;
var G__34970 = t__$2;
var G__34971 = frames__$2;
G__34927__$1 = G__34967;
entities__$1 = G__34968;
events__$1 = G__34969;
t__$1 = G__34970;
frames__$1 = G__34971;
continue;

break;
default:
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__34944__$1)].join('')));

}
}
break;
}
});

lsobot.acmi.read_acmi.cljs$lang$maxFixedArity = 2;

/**
 * Returns index of the closest frame at or after the specified time.
 */
lsobot.acmi.frame_index_at = (function lsobot$acmi$frame_index_at(file,t){
var frames = new cljs.core.Keyword("lsobot.acmi","frames","lsobot.acmi/frames",1165126782).cljs$core$IFn$_invoke$arity$1(file);
var low = (0);
var high = (cljs.core.count.call(null,frames) - (1));
while(true){
var idx = (((low + high) / (2)) | (0));
var t0 = new cljs.core.Keyword("lsobot.acmi","t","lsobot.acmi/t",1347958254).cljs$core$IFn$_invoke$arity$1(cljs.core.nth.call(null,frames,idx));
if(cljs.core._EQ_.call(null,t0,t)){
return idx;
} else {
if(cljs.core._EQ_.call(null,low,(high - (1)))){
return (idx + (1));
} else {
if((t0 < t)){
var G__34972 = idx;
var G__34973 = high;
low = G__34972;
high = G__34973;
continue;
} else {
var G__34974 = low;
var G__34975 = idx;
low = G__34974;
high = G__34975;
continue;

}
}
}
break;
}
});
/**
 * Returns the closest frame at or after the specified time.
 */
lsobot.acmi.frame_at = (function lsobot$acmi$frame_at(file,t){
return cljs.core.nth.call(null,new cljs.core.Keyword("lsobot.acmi","frames","lsobot.acmi/frames",1165126782).cljs$core$IFn$_invoke$arity$1(file),lsobot.acmi.frame_index_at.call(null,file,t));
});
/**
 * Returns the entities of a frame
 */
lsobot.acmi.entities = (function lsobot$acmi$entities(frame){
return new cljs.core.Keyword("lsobot.acmi","entities","lsobot.acmi/entities",1464472374).cljs$core$IFn$_invoke$arity$1(frame);
});
/**
 * Returns an entity from a frame
 */
lsobot.acmi.entity = (function lsobot$acmi$entity(frame,id){
return cljs.core.get.call(null,lsobot.acmi.entities.call(null,frame),id);
});
/**
 * Return entity `id` from closest frame at or after specified time.
 */
lsobot.acmi.entity_at = (function lsobot$acmi$entity_at(file,id,t){
var frame = lsobot.acmi.frame_at.call(null,file,t);
return cljs.core.get.call(null,new cljs.core.Keyword("lsobot.acmi","entities","lsobot.acmi/entities",1464472374).cljs$core$IFn$_invoke$arity$1(frame),id);
});
