// Compiled by ClojureScript 1.9.562 {}
goog.provide('hoplon.app_pages._index_DOT_html');
goog.require('cljs.core');
goog.require('weathergen.ipc');
goog.require('weathergen.ui');
goog.require('weathergen.ui.buttons');
goog.require('weathergen.ui.common');
goog.require('javelin.core');
goog.require('hoplon.jquery');
goog.require('hoplon.core');
hoplon.app_pages._index_DOT_html.electron = require("electron");
hoplon.app_pages._index_DOT_html.loading_QMARK_ = javelin.core.cell.call(null,false);
hoplon.app_pages._index_DOT_html.progress_messages = javelin.core.cell.call(null,cljs.core.PersistentVector.EMPTY);
hoplon.app_pages._index_DOT_html.load_error = javelin.core.cell.call(null,null);
cljs.core._add_method.call(null,weathergen.ipc.on_message,"progress-message",(function (_,event,msg){
return cljs.core.swap_BANG_.call(null,hoplon.app_pages._index_DOT_html.progress_messages,cljs.core.conj,msg);
}));
cljs.core._add_method.call(null,weathergen.ipc.on_message,"load-complete",(function (_,event){
return javelin.core.dosync_STAR_.call(null,(function (){
cljs.core.swap_BANG_.call(null,hoplon.app_pages._index_DOT_html.progress_messages,cljs.core.conj,"Load complete");

return cljs.core.reset_BANG_.call(null,hoplon.app_pages._index_DOT_html.loading_QMARK_,false);
}));
}));
cljs.core._add_method.call(null,weathergen.ipc.on_message,"load-failed",(function (_,___$1,err){
cljs.core.reset_BANG_.call(null,hoplon.app_pages._index_DOT_html.loading_QMARK_,false);

return cljs.core.reset_BANG_.call(null,hoplon.app_pages._index_DOT_html.load_error,err);
}));
hoplon.app_pages._index_DOT_html.load_mission = (function hoplon$app_pages$_index_DOT_html$load_mission(){
var temp__5278__auto__ = hoplon.app_pages._index_DOT_html.electron.remote.dialog.showOpenDialog(cljs.core.clj__GT_js.call(null,new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"title","title",636505583),"Select a campaign or tactical engagement file",new cljs.core.Keyword(null,"properties","properties",685819552),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, ["openFile"], null),new cljs.core.Keyword(null,"filters","filters",974726919),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"name","name",1843675177),"Campaign file",new cljs.core.Keyword(null,"extensions","extensions",-1103629196),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, ["cam"], null)], null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"name","name",1843675177),"Tactical engagement file",new cljs.core.Keyword(null,"extensions","extensions",-1103629196),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, ["tac"], null)], null)], null)], null)));
if(cljs.core.truth_(temp__5278__auto__)){
var vec__48668 = temp__5278__auto__;
var path = cljs.core.nth.call(null,vec__48668,(0),null);
javelin.core.dosync_STAR_.call(null,((function (vec__48668,path,temp__5278__auto__){
return (function (){
cljs.core.reset_BANG_.call(null,hoplon.app_pages._index_DOT_html.loading_QMARK_,true);

cljs.core.reset_BANG_.call(null,hoplon.app_pages._index_DOT_html.load_error,null);

return cljs.core.reset_BANG_.call(null,hoplon.app_pages._index_DOT_html.progress_messages,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, ["Setting up to load mission"], null));
});})(vec__48668,path,temp__5278__auto__))
);

return weathergen.ipc.send_to_main.call(null,"open-mission",path);
} else {
return null;
}
});
hoplon.app_pages._index_DOT_html.load_briefing = (function hoplon$app_pages$_index_DOT_html$load_briefing(){
var temp__5278__auto__ = hoplon.app_pages._index_DOT_html.electron.remote.dialog.showOpenDialog(({"title": "Select a campaign or tactical engagement file", "openFile": true, "filters": [({"name": "VMT Briefing", "extensions": ["vmtb"]})]}));
if(cljs.core.truth_(temp__5278__auto__)){
var vec__48674 = temp__5278__auto__;
var path = cljs.core.nth.call(null,vec__48674,(0),null);
javelin.core.dosync_STAR_.call(null,((function (vec__48674,path,temp__5278__auto__){
return (function (){
cljs.core.reset_BANG_.call(null,hoplon.app_pages._index_DOT_html.loading_QMARK_,true);

cljs.core.reset_BANG_.call(null,hoplon.app_pages._index_DOT_html.load_error,null);

return cljs.core.reset_BANG_.call(null,hoplon.app_pages._index_DOT_html.progress_messages,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, ["Setting up to load briefing"], null));
});})(vec__48674,path,temp__5278__auto__))
);

return weathergen.ipc.send_to_main.call(null,"open-briefing",path);
} else {
return null;
}
});
hoplon.core.html.call(null,weathergen.ui.head.call(null),hoplon.core.body.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"margin","margin",-995903681),"0"], null),hoplon.core.div.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"display","display",242065432),"flex",new cljs.core.Keyword(null,"flex-direction","flex-direction",364609438),"column",new cljs.core.Keyword(null,"height","height",1025178622),"100vh"], null),hoplon.core.div.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"padding","padding",1660304693),"8px 8px 0"], null),weathergen.ui.titlebar.call(null)),hoplon.core.div.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"font-size","font-size",-1847940346),"150%"], null),weathergen.ui.buttons.a_button.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"display","display",242065432),"inline-block",new cljs.core.Keyword(null,"margin","margin",-995903681),"5px 10px"], null),new cljs.core.Keyword(null,"disabled","disabled",-1529784218),hoplon.app_pages._index_DOT_html.loading_QMARK_,new cljs.core.Keyword(null,"click","click",1912301393),hoplon.app_pages._index_DOT_html.load_mission,"Load mission (.cam/.tac)"),weathergen.ui.buttons.a_button.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"display","display",242065432),"inline-block",new cljs.core.Keyword(null,"margin","margin",-995903681),"5px 10px"], null),new cljs.core.Keyword(null,"disabled","disabled",-1529784218),hoplon.app_pages._index_DOT_html.loading_QMARK_,new cljs.core.Keyword(null,"click","click",1912301393),hoplon.app_pages._index_DOT_html.load_briefing,"Load briefing (.vmtb)")),(function (){var elem = hoplon.core.div.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 7, [new cljs.core.Keyword(null,"overflow-y","overflow-y",-1436589285),"auto",new cljs.core.Keyword(null,"overflow-x","overflow-x",-26547754),"auto",new cljs.core.Keyword(null,"flex","flex",-1425124628),(1),new cljs.core.Keyword(null,"font-size","font-size",-1847940346),"150%",new cljs.core.Keyword(null,"border","border",1444987323),"solid 1px black",new cljs.core.Keyword(null,"margin","margin",-995903681),"0 10px 20px 10px",new cljs.core.Keyword(null,"padding","padding",1660304693),"4px"], null),hoplon.core.loop_tpl_STAR_.call(null,javelin.core.formula.call(null,(function (G__48677,G__48678){
return G__48677.call(null,G__48678);
})).call(null,cljs.core.butlast,hoplon.app_pages._index_DOT_html.progress_messages),(function (item__29615__auto__){
var vec__48679 = javelin.core.cell_map.call(null,cljs.core.identity,javelin.core.formula.call(null,(function (message){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [message], null);
})).call(null,item__29615__auto__));
var message = cljs.core.nth.call(null,vec__48679,(0),null);
return hoplon.core.div.call(null,hoplon.core.span.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"font-weight","font-weight",2085804583),"bold",new cljs.core.Keyword(null,"color","color",1011675173),"green",new cljs.core.Keyword(null,"width","width",-384071477),"24px",new cljs.core.Keyword(null,"display","display",242065432),"inline-block"], null),"\u2713"),message);
})),(function (){var last_message = javelin.core.formula.call(null,(function (G__48682,G__48683){
return G__48682.call(null,G__48683);
})).call(null,cljs.core.last,hoplon.app_pages._index_DOT_html.progress_messages);
return hoplon.core.div.call(null,(function (){var con__29625__auto__ = (new cljs.core.Delay(((function (last_message){
return (function (){
return hoplon.core.img.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"width","width",-384071477),"24px",new cljs.core.Keyword(null,"vertical-align","vertical-align",651007333),"middle",new cljs.core.Keyword(null,"margin-top","margin-top",392161226),"-5px"], null),new cljs.core.Keyword(null,"src","src",-1651076051),"images/spinner.gif");
});})(last_message))
,null));
var alt__29626__auto__ = (new cljs.core.Delay(((function (con__29625__auto__,last_message){
return (function (){
return hoplon.core.span.call(null,new cljs.core.Keyword(null,"css","css",1135045163),javelin.core.formula.call(null,((function (con__29625__auto__,last_message){
return (function (load_error){
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"font-weight","font-weight",2085804583),"bold",new cljs.core.Keyword(null,"color","color",1011675173),(cljs.core.truth_(load_error)?"red":"green"),new cljs.core.Keyword(null,"width","width",-384071477),"24px",new cljs.core.Keyword(null,"display","display",242065432),"inline-block"], null);
});})(con__29625__auto__,last_message))
).call(null,hoplon.app_pages._index_DOT_html.load_error),(function (){var G__48687 = (new cljs.core.Delay(((function (con__29625__auto__,last_message){
return (function (){
return "";
});})(con__29625__auto__,last_message))
,null));
var G__48688 = (new cljs.core.Delay(((function (G__48687,con__29625__auto__,last_message){
return (function (){
return "\u2717";
});})(G__48687,con__29625__auto__,last_message))
,null));
var G__48689 = (new cljs.core.Delay(((function (G__48687,G__48688,con__29625__auto__,last_message){
return (function (){
return "\u2713";
});})(G__48687,G__48688,con__29625__auto__,last_message))
,null));
var tpl__29643__auto__ = ((function (G__48687,G__48688,G__48689,con__29625__auto__,last_message){
return (function (G__48684,G__48685,G__48686){
return cljs.core.deref.call(null,(function (){var or__23148__auto__ = (cljs.core.truth_(G__48684)?G__48687:(cljs.core.truth_(G__48685)?G__48688:(cljs.core.truth_(G__48686)?G__48689:null)));
if(cljs.core.truth_(or__23148__auto__)){
return or__23148__auto__;
} else {
return cljs.core.atom.call(null);
}
})());
});})(G__48687,G__48688,G__48689,con__29625__auto__,last_message))
;
return javelin.core.formula.call(null,tpl__29643__auto__).call(null,javelin.core.formula.call(null,((function (G__48687,G__48688,G__48689,tpl__29643__auto__,con__29625__auto__,last_message){
return (function (G__48691,G__48690){
return G__48690.call(null,G__48691);
});})(G__48687,G__48688,G__48689,tpl__29643__auto__,con__29625__auto__,last_message))
).call(null,last_message,cljs.core.not),hoplon.app_pages._index_DOT_html.load_error,new cljs.core.Keyword(null,"else","else",-1508377146));
})());
});})(con__29625__auto__,last_message))
,null));
var tpl__29627__auto__ = ((function (con__29625__auto__,alt__29626__auto__,last_message){
return (function (p__29628__auto__){
return cljs.core.deref.call(null,(function (){var or__23148__auto__ = (cljs.core.truth_(p__29628__auto__)?con__29625__auto__:alt__29626__auto__);
if(cljs.core.truth_(or__23148__auto__)){
return or__23148__auto__;
} else {
return cljs.core.atom.call(null);
}
})());
});})(con__29625__auto__,alt__29626__auto__,last_message))
;
return javelin.core.formula.call(null,tpl__29627__auto__).call(null,hoplon.app_pages._index_DOT_html.loading_QMARK_);
})(),last_message,(function (){var con__29625__auto__ = (new cljs.core.Delay(((function (last_message){
return (function (){
var show_QMARK_ = javelin.core.cell.call(null,false);
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [hoplon.core.span.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"color","color",1011675173),"blue",new cljs.core.Keyword(null,"text-decoration","text-decoration",1836813207),"underline",new cljs.core.Keyword(null,"font-size","font-size",-1847940346),"70%",new cljs.core.Keyword(null,"margin-left","margin-left",2015598377),"5px"], null),new cljs.core.Keyword(null,"click","click",1912301393),((function (show_QMARK_,last_message){
return (function (){
return cljs.core.swap_BANG_.call(null,show_QMARK_,cljs.core.not);
});})(show_QMARK_,last_message))
,(function (){var con__29625__auto__ = (new cljs.core.Delay(((function (show_QMARK_,last_message){
return (function (){
return "Hide error details";
});})(show_QMARK_,last_message))
,null));
var alt__29626__auto__ = (new cljs.core.Delay(((function (con__29625__auto__,show_QMARK_,last_message){
return (function (){
return "Show error details";
});})(con__29625__auto__,show_QMARK_,last_message))
,null));
var tpl__29627__auto__ = ((function (con__29625__auto__,alt__29626__auto__,show_QMARK_,last_message){
return (function (p__29628__auto__){
return cljs.core.deref.call(null,(function (){var or__23148__auto__ = (cljs.core.truth_(p__29628__auto__)?con__29625__auto__:alt__29626__auto__);
if(cljs.core.truth_(or__23148__auto__)){
return or__23148__auto__;
} else {
return cljs.core.atom.call(null);
}
})());
});})(con__29625__auto__,alt__29626__auto__,show_QMARK_,last_message))
;
return javelin.core.formula.call(null,tpl__29627__auto__).call(null,show_QMARK_);
})()),hoplon.core.pre.call(null,new cljs.core.Keyword(null,"toggle","toggle",1291842030),show_QMARK_,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"padding-left","padding-left",-1180879053),"10px"], null),hoplon.app_pages._index_DOT_html.load_error)], null);
});})(last_message))
,null));
var alt__29626__auto__ = (new cljs.core.Delay(((function (con__29625__auto__,last_message){
return (function (){
return null;
});})(con__29625__auto__,last_message))
,null));
var tpl__29627__auto__ = ((function (con__29625__auto__,alt__29626__auto__,last_message){
return (function (p__29628__auto__){
return cljs.core.deref.call(null,(function (){var or__23148__auto__ = (cljs.core.truth_(p__29628__auto__)?con__29625__auto__:alt__29626__auto__);
if(cljs.core.truth_(or__23148__auto__)){
return or__23148__auto__;
} else {
return cljs.core.atom.call(null);
}
})());
});})(con__29625__auto__,alt__29626__auto__,last_message))
;
return javelin.core.formula.call(null,tpl__29627__auto__).call(null,hoplon.app_pages._index_DOT_html.load_error);
})());
})());
cljs.core.add_watch.call(null,hoplon.app_pages._index_DOT_html.progress_messages,new cljs.core.Keyword("hoplon.app-pages._index_DOT_html","scroll-notifications","hoplon.app-pages._index_DOT_html/scroll-notifications",-475071792),((function (elem){
return (function (_,___$1,___$2,___$3){
return setTimeout(((function (elem){
return (function (){
return elem.scrollTop = elem.scrollHeight;
});})(elem))
,(0));
});})(elem))
);

return elem;
})())));
