// Compiled by ClojureScript 1.9.562 {}
goog.provide('weathergen.ui.common');
goog.require('cljs.core');
goog.require('cljs.pprint');
goog.require('clojure.string');
goog.require('garden.core');
goog.require('garden.selectors');
goog.require('garden.stylesheet');
goog.require('goog.string');
goog.require('goog.string.format');
goog.require('hoplon.storage_atom');
goog.require('hoplon.svg');
goog.require('taoensso.timbre');
goog.require('weathergen.falcon.files.images');
goog.require('weathergen.falcon.files.mission');
goog.require('weathergen.filesystem');
goog.require('weathergen.math');
goog.require('weathergen.settings');
goog.require('javelin.core');
goog.require('hoplon.jquery');
goog.require('hoplon.core');
weathergen.ui.common.tinycolor = module.exports;
/**
 * Returns a pixel measurement string, e.g. '2px'. Allows multiple
 *   arguments, in which case it will return a margin-style string,
 *   e.g. `(px 1 2)` returns '1px 2px'.
 */
weathergen.ui.common.px = (function weathergen$ui$common$px(var_args){
var args__24376__auto__ = [];
var len__24369__auto___36034 = arguments.length;
var i__24370__auto___36035 = (0);
while(true){
if((i__24370__auto___36035 < len__24369__auto___36034)){
args__24376__auto__.push((arguments[i__24370__auto___36035]));

var G__36036 = (i__24370__auto___36035 + (1));
i__24370__auto___36035 = G__36036;
continue;
} else {
}
break;
}

var argseq__24377__auto__ = ((((0) < args__24376__auto__.length))?(new cljs.core.IndexedSeq(args__24376__auto__.slice((0)),(0),null)):null);
return weathergen.ui.common.px.cljs$core$IFn$_invoke$arity$variadic(argseq__24377__auto__);
});

weathergen.ui.common.px.cljs$core$IFn$_invoke$arity$variadic = (function (ns){
return clojure.string.join.call(null," ",cljs.core.map.call(null,(function (p1__36032_SHARP_){
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(p1__36032_SHARP_),cljs.core.str.cljs$core$IFn$_invoke$arity$1("px")].join('');
}),ns));
});

weathergen.ui.common.px.cljs$lang$maxFixedArity = (0);

weathergen.ui.common.px.cljs$lang$applyTo = (function (seq36033){
return weathergen.ui.common.px.cljs$core$IFn$_invoke$arity$variadic(cljs.core.seq.call(null,seq36033));
});

/**
 * Returns a percentage measurement string, e.g. '50%'
 */
weathergen.ui.common.pct = (function weathergen$ui$common$pct(n){
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(n),cljs.core.str.cljs$core$IFn$_invoke$arity$1("%")].join('');
});
weathergen.ui.common.colors = new cljs.core.PersistentArrayMap(null, 6, [new cljs.core.Keyword(null,"invalid","invalid",412869516),"#c70505",new cljs.core.Keyword(null,"invalid-background","invalid-background",-917496690),"#fcc",new cljs.core.Keyword(null,"error-message","error-message",1756021561),"#c70505",new cljs.core.Keyword(null,"edit","edit",-1641834166),"rgba(128,128,255,0.5)",new cljs.core.Keyword(null,"header-background","header-background",1686840154),"lightgray",new cljs.core.Keyword(null,"team","team",1355747699),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"dark-text","dark-text",814777253),new cljs.core.PersistentArrayMap(null, 8, [new cljs.core.Keyword(null,"white","white",-483998618),"gray",new cljs.core.Keyword(null,"green","green",-945526839),"green",new cljs.core.Keyword(null,"blue","blue",-622100620),"blue",new cljs.core.Keyword(null,"brown","brown",1414854429),"#923c25",new cljs.core.Keyword(null,"orange","orange",73816386),"darkorange",new cljs.core.Keyword(null,"yellow","yellow",-881035449),"#caae18",new cljs.core.Keyword(null,"red","red",-969428204),"red",new cljs.core.Keyword(null,"gray","gray",1013268388),"darkgray"], null),new cljs.core.Keyword(null,"light-text","light-text",-274885440),new cljs.core.PersistentArrayMap(null, 8, [new cljs.core.Keyword(null,"white","white",-483998618),"white",new cljs.core.Keyword(null,"green","green",-945526839),"lightgreen",new cljs.core.Keyword(null,"blue","blue",-622100620),"#8ddbf5",new cljs.core.Keyword(null,"brown","brown",1414854429),"#e27e43",new cljs.core.Keyword(null,"orange","orange",73816386),"orange",new cljs.core.Keyword(null,"yellow","yellow",-881035449),"yellow",new cljs.core.Keyword(null,"red","red",-969428204),"#f9adad",new cljs.core.Keyword(null,"gray","gray",1013268388),"lightgray"], null)], null)], null);
/**
 * Returns a color for a team.
 */
weathergen.ui.common.team_color = (function weathergen$ui$common$team_color(team,type){
return cljs.core.get_in.call(null,weathergen.ui.common.colors,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"team","team",1355747699),type,weathergen.falcon.files.mission.team_color.call(null,team)], null));
});
/**
 * Given a keyword, returns a string safe to use as a css class name.
 */
weathergen.ui.common.class_for = cljs.core.memoize.call(null,(function (kw){
return clojure.string.replace.call(null,cljs.core.subs.call(null,[cljs.core.str.cljs$core$IFn$_invoke$arity$1(kw)].join(''),(1)),/[^a-zA-Z0-9]/,"-");
}));
/**
 * Given a keyword, returns a garden class selector usable with class-for.
 */
weathergen.ui.common.class_selector_for = (function weathergen$ui$common$class_selector_for(kw){
return garden.selectors.selector.call(null,[cljs.core.str.cljs$core$IFn$_invoke$arity$1("."),cljs.core.str.cljs$core$IFn$_invoke$arity$1(weathergen.ui.common.class_for.call(null,kw))].join(''));
});
weathergen.ui.common.registered_styles = cljs.core.atom.call(null,cljs.core.PersistentHashSet.EMPTY);
/**
 * Adds styles to the head of the document. If already registered under `key`, does nothing.
 */
weathergen.ui.common.register_styles_BANG_ = (function weathergen$ui$common$register_styles_BANG_(key,garden__$1){
if(cljs.core.contains_QMARK_.call(null,cljs.core.deref.call(null,weathergen.ui.common.registered_styles),key)){
return null;
} else {
var head = (document.getElementsByTagName("head")[(0)]);
var styles = javelin.core.formula.call(null,((function (head){
return (function (G__36039,G__36040){
return G__36039.call(null,G__36040);
});})(head))
).call(null,garden.core.css,garden__$1);
cljs.core.swap_BANG_.call(null,weathergen.ui.common.registered_styles,cljs.core.conj,key);

return hoplon.core.when_dom.call(null,head,((function (head,styles){
return (function (){
return head.appendChild(hoplon.core.style.call(null,new cljs.core.Keyword(null,"type","type",1174270348),"text/css",new cljs.core.Keyword(null,"debug","debug",-1608172596),[cljs.core.str.cljs$core$IFn$_invoke$arity$1(key)].join(''),styles));
});})(head,styles))
);
}
});
/**
 * Adds a style to the head of a document for abstract class `key`.
 *   `key` should be a namespaced keyword that can then be used as the
 *   `:class` of an element via `class-for`. `garden` is the tail of a
 *   garden style statement, i.e. everything except the seelctor.
 * 
 *   Example:
 * 
 *   (register-class!
 *  ::foobar
 *  [{:background "blue"} [:&:hover {:background "red"}]])
 */
weathergen.ui.common.register_class_BANG_ = (function weathergen$ui$common$register_class_BANG_(key,garden__$1){
return weathergen.ui.common.register_styles_BANG_.call(null,key,cljs.core.into.call(null,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [weathergen.ui.common.class_selector_for.call(null,key)], null),garden__$1));
});
/**
 * Returns a color that contrasts well with the specified color.
 *   Optionally, the colors to use for dark and light can be specified.
 */
weathergen.ui.common.contrasting = (function weathergen$ui$common$contrasting(var_args){
var args36041 = [];
var len__24369__auto___36045 = arguments.length;
var i__24370__auto___36046 = (0);
while(true){
if((i__24370__auto___36046 < len__24369__auto___36045)){
args36041.push((arguments[i__24370__auto___36046]));

var G__36047 = (i__24370__auto___36046 + (1));
i__24370__auto___36046 = G__36047;
continue;
} else {
}
break;
}

var G__36043 = args36041.length;
switch (G__36043) {
case 1:
return weathergen.ui.common.contrasting.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));

break;
case 3:
return weathergen.ui.common.contrasting.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));

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

}
});

weathergen.ui.common.contrasting.cljs$core$IFn$_invoke$arity$1 = (function (color){
return weathergen.ui.common.contrasting.call(null,color,"black","white");
});

weathergen.ui.common.contrasting.cljs$core$IFn$_invoke$arity$3 = (function (color,dark,light){
return (function (){var G__36044 = weathergen.ui.common.tinycolor.mostReadable(color,[dark,light]);
return G__36044;
})().toHexString();
});

weathergen.ui.common.contrasting.cljs$lang$maxFixedArity = 3;

/**
 * Darkens a color by an amount from 0-100.
 */
weathergen.ui.common.darken = (function weathergen$ui$common$darken(color,amount){
return (function (){var G__36051 = (function (){var G__36052 = weathergen.ui.common.tinycolor.call(null,color);
return G__36052;
})().darken(amount);
return G__36051;
})().toHexString();
});
/**
 * Lightens a color by an amount from 0-100.
 */
weathergen.ui.common.lighten = (function weathergen$ui$common$lighten(color,amount){
return (function (){var G__36055 = (function (){var G__36056 = weathergen.ui.common.tinycolor.call(null,color);
return G__36056;
})().lighten(amount);
return G__36055;
})().toHexString();
});
/**
 * Rotates a color by an amount from 0 to 360 degrees.
 */
weathergen.ui.common.spin = (function weathergen$ui$common$spin(color,amount){
return (function (){var G__36059 = (function (){var G__36060 = weathergen.ui.common.tinycolor.call(null,color);
return G__36060;
})().spin(amount);
return G__36059;
})().toHexString();
});
/**
 * Converts a color to a hex string.
 */
weathergen.ui.common.to_hex_str = (function weathergen$ui$common$to_hex_str(color){
return (function (){var G__36062 = weathergen.ui.common.tinycolor.call(null,color);
return G__36062;
})().toHexString();
});
/**
 * Creates an element which is a scope for a set of CSS rules,
 *   provided via a `:garden` attribute, by adding an element with a
 *   unique ID and new <style> element to the <head> of the document.
 * @param {...*} var_args
 */
weathergen.ui.common.styled = (function() { 
var weathergen$ui$common$styled__delegate = function (args__29571__auto__){
var vec__36072 = hoplon.core.parse_args.call(null,args__29571__auto__);
var attrs = cljs.core.nth.call(null,vec__36072,(0),null);
var content = cljs.core.nth.call(null,vec__36072,(1),null);
var map__36075 = attrs;
var map__36075__$1 = ((((!((map__36075 == null)))?((((map__36075.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__36075.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__36075):map__36075);
var garden__$1 = cljs.core.get.call(null,map__36075__$1,new cljs.core.Keyword(null,"garden","garden",-1966516149));
var attrs__$1 = cljs.core.dissoc.call(null,attrs,new cljs.core.Keyword(null,"garden","garden",-1966516149));
var head = (document.getElementsByTagName("head")[(0)]);
var id = [cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.gensym.call(null))].join('');
var styles = javelin.core.formula.call(null,((function (map__36075,map__36075__$1,garden__$1,attrs__$1,head,id,vec__36072,attrs,content){
return (function (G__36077,G__36080,G__36078,G__36079){
return G__36077.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [G__36078.call(null,[cljs.core.str.cljs$core$IFn$_invoke$arity$1("#"),cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__36079)].join('')),G__36080], null));
});})(map__36075,map__36075__$1,garden__$1,attrs__$1,head,id,vec__36072,attrs,content))
).call(null,garden.core.css,garden__$1,cljs.core.keyword,id);
head.appendChild(hoplon.core.style.call(null,new cljs.core.Keyword(null,"type","type",1174270348),"text/css",styles));

return hoplon.core.div.call(null,cljs.core.merge.call(null,attrs__$1,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"id","id",-1388402092),id], null)),content);
};
var weathergen$ui$common$styled = function (var_args){
var args__29571__auto__ = null;
if (arguments.length > 0) {
var G__36081__i = 0, G__36081__a = new Array(arguments.length -  0);
while (G__36081__i < G__36081__a.length) {G__36081__a[G__36081__i] = arguments[G__36081__i + 0]; ++G__36081__i;}
  args__29571__auto__ = new cljs.core.IndexedSeq(G__36081__a,0,null);
} 
return weathergen$ui$common$styled__delegate.call(this,args__29571__auto__);};
weathergen$ui$common$styled.cljs$lang$maxFixedArity = 0;
weathergen$ui$common$styled.cljs$lang$applyTo = (function (arglist__36082){
var args__29571__auto__ = cljs.core.seq(arglist__36082);
return weathergen$ui$common$styled__delegate(args__29571__auto__);
});
weathergen$ui$common$styled.cljs$core$IFn$_invoke$arity$variadic = weathergen$ui$common$styled__delegate;
return weathergen$ui$common$styled;
})()
;
/**
 * @param {...*} var_args
 */
weathergen.ui.common.inl = (function() { 
var weathergen$ui$common$inl__delegate = function (args__29571__auto__){
var vec__36088 = hoplon.core.parse_args.call(null,args__29571__auto__);
var attrs = cljs.core.nth.call(null,vec__36088,(0),null);
var content = cljs.core.nth.call(null,vec__36088,(1),null);
var map__36091 = attrs;
var map__36091__$1 = ((((!((map__36091 == null)))?((((map__36091.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__36091.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__36091):map__36091);
var css = cljs.core.get.call(null,map__36091__$1,new cljs.core.Keyword(null,"css","css",1135045163));
return hoplon.core.div.call(null,cljs.core.update.call(null,attrs,new cljs.core.Keyword(null,"css","css",1135045163),((function (map__36091,map__36091__$1,css,vec__36088,attrs,content){
return (function (css_orig){
if(cljs.core.truth_(javelin.core.cell_QMARK_.call(null,css_orig))){
return javelin.core.formula.call(null,((function (map__36091,map__36091__$1,css,vec__36088,attrs,content){
return (function (css_orig__$1){
return cljs.core.assoc.call(null,css_orig__$1,new cljs.core.Keyword(null,"display","display",242065432),"inline-block");
});})(map__36091,map__36091__$1,css,vec__36088,attrs,content))
).call(null,css_orig);
} else {
return cljs.core.assoc.call(null,css_orig,new cljs.core.Keyword(null,"display","display",242065432),"inline-block");
}
});})(map__36091,map__36091__$1,css,vec__36088,attrs,content))
),content);
};
var weathergen$ui$common$inl = function (var_args){
var args__29571__auto__ = null;
if (arguments.length > 0) {
var G__36093__i = 0, G__36093__a = new Array(arguments.length -  0);
while (G__36093__i < G__36093__a.length) {G__36093__a[G__36093__i] = arguments[G__36093__i + 0]; ++G__36093__i;}
  args__29571__auto__ = new cljs.core.IndexedSeq(G__36093__a,0,null);
} 
return weathergen$ui$common$inl__delegate.call(this,args__29571__auto__);};
weathergen$ui$common$inl.cljs$lang$maxFixedArity = 0;
weathergen$ui$common$inl.cljs$lang$applyTo = (function (arglist__36094){
var args__29571__auto__ = cljs.core.seq(arglist__36094);
return weathergen$ui$common$inl__delegate(args__29571__auto__);
});
weathergen$ui$common$inl.cljs$core$IFn$_invoke$arity$variadic = weathergen$ui$common$inl__delegate;
return weathergen$ui$common$inl;
})()
;
/**
 * @param {...*} var_args
 */
weathergen.ui.common.triangle = (function() { 
var weathergen$ui$common$triangle__delegate = function (args__29571__auto__){
var vec__36105 = hoplon.core.parse_args.call(null,args__29571__auto__);
var attrs = cljs.core.nth.call(null,vec__36105,(0),null);
var _ = cljs.core.nth.call(null,vec__36105,(1),null);
var map__36108 = attrs;
var map__36108__$1 = ((((!((map__36108 == null)))?((((map__36108.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__36108.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__36108):map__36108);
var r = cljs.core.get.call(null,map__36108__$1,new cljs.core.Keyword(null,"r","r",-471384190));
var r_STAR_ = javelin.core.formula.call(null,((function (map__36108,map__36108__$1,r,vec__36105,attrs,_){
return (function (G__36110){
return G__36110;
});})(map__36108,map__36108__$1,r,vec__36105,attrs,_))
).call(null,r);
var attrs__$1 = cljs.core.dissoc.call(null,attrs,new cljs.core.Keyword(null,"r","r",-471384190));
var alpha = 0.8660254037844387;
var beta = 0.5;
var x = javelin.core.formula.call(null,((function (map__36108,map__36108__$1,r,r_STAR_,attrs__$1,alpha,beta,vec__36105,attrs,_){
return (function (G__36111,G__36112){
return (G__36111 * G__36112);
});})(map__36108,map__36108__$1,r,r_STAR_,attrs__$1,alpha,beta,vec__36105,attrs,_))
).call(null,r_STAR_,alpha);
var y = javelin.core.formula.call(null,((function (map__36108,map__36108__$1,r,r_STAR_,attrs__$1,alpha,beta,x,vec__36105,attrs,_){
return (function (G__36113,G__36114){
return (G__36113 * G__36114);
});})(map__36108,map__36108__$1,r,r_STAR_,attrs__$1,alpha,beta,x,vec__36105,attrs,_))
).call(null,r_STAR_,alpha);
return hoplon.svg.path.call(null,new cljs.core.Keyword(null,"d","d",1972142424),javelin.core.formula.call(null,((function (map__36108,map__36108__$1,r,r_STAR_,attrs__$1,alpha,beta,x,y,vec__36105,attrs,_){
return (function (x__$1,y__$1){
return goog.string.format("M%f,%f L%f,%f L%f,%f Z",(0),(- y__$1),x__$1,y__$1,(- x__$1),y__$1);
});})(map__36108,map__36108__$1,r,r_STAR_,attrs__$1,alpha,beta,x,y,vec__36105,attrs,_))
).call(null,x,y),attrs__$1);
};
var weathergen$ui$common$triangle = function (var_args){
var args__29571__auto__ = null;
if (arguments.length > 0) {
var G__36115__i = 0, G__36115__a = new Array(arguments.length -  0);
while (G__36115__i < G__36115__a.length) {G__36115__a[G__36115__i] = arguments[G__36115__i + 0]; ++G__36115__i;}
  args__29571__auto__ = new cljs.core.IndexedSeq(G__36115__a,0,null);
} 
return weathergen$ui$common$triangle__delegate.call(this,args__29571__auto__);};
weathergen$ui$common$triangle.cljs$lang$maxFixedArity = 0;
weathergen$ui$common$triangle.cljs$lang$applyTo = (function (arglist__36116){
var args__29571__auto__ = cljs.core.seq(arglist__36116);
return weathergen$ui$common$triangle__delegate(args__29571__auto__);
});
weathergen$ui$common$triangle.cljs$core$IFn$_invoke$arity$variadic = weathergen$ui$common$triangle__delegate;
return weathergen$ui$common$triangle;
})()
;
/**
 * Pretty-prints the value of cell c and displays it in a pre tag.
 */
weathergen.ui.common.pre_cell = (function weathergen$ui$common$pre_cell(title,c){
weathergen.ui.common.register_styles_BANG_.call(null,new cljs.core.Keyword("weathergen.ui.common","pre-cell","weathergen.ui.common/pre-cell",-1959908687),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,".pre-cell",".pre-cell",1928754490),new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"background","background",-863952629),"black",new cljs.core.Keyword(null,"color","color",1011675173),"green",new cljs.core.Keyword(null,"font-family","font-family",-667419874),"monospace"], null)], null)], null));

return hoplon.core.div.call(null,new cljs.core.Keyword(null,"class","class",-2030961996),"pre-cell",hoplon.core.h4.call(null,title),hoplon.core.pre.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"white-space","white-space",-707351930),"pre-wrap"], null),javelin.core.formula.call(null,(function (G__36119,G__36120){
return G__36119.call(null,G__36120,new cljs.core.Keyword(null,"stream","stream",1534941648),null,new cljs.core.Keyword(null,"pretty","pretty",-1916372486),true);
})).call(null,cljs.pprint.write,c)));
});
/**
 * @param {...*} var_args
 */
weathergen.ui.common.control_section = (function() { 
var weathergen$ui$common$control_section__delegate = function (args__29571__auto__){
var vec__36124 = hoplon.core.parse_args.call(null,args__29571__auto__);
var attributes = cljs.core.nth.call(null,vec__36124,(0),null);
var children = cljs.core.nth.call(null,vec__36124,(1),null);
var visible = javelin.core.cell.call(null,cljs.core.not.call(null,new cljs.core.Keyword(null,"collapsed?","collapsed?",-1661420674).cljs$core$IFn$_invoke$arity$1(attributes)));
var change_visibility = ((function (visible,vec__36124,attributes,children){
return (function (){
return cljs.core.swap_BANG_.call(null,visible,cljs.core.not);
});})(visible,vec__36124,attributes,children))
;
return hoplon.core.fieldset.call(null,new cljs.core.Keyword(null,"class","class",-2030961996),"controls",cljs.core.dissoc.call(null,attributes,new cljs.core.Keyword(null,"title","title",636505583),new cljs.core.Keyword(null,"collapsed?","collapsed?",-1661420674),new cljs.core.Keyword(null,"help-for","help-for",-1997101642)),hoplon.core.legend.call(null,hoplon.core.div.call(null,new cljs.core.Keyword(null,"click","click",1912301393),change_visibility,new cljs.core.Keyword(null,"class","class",-2030961996),javelin.core.formula.call(null,((function (visible,change_visibility,vec__36124,attributes,children){
return (function (visible__$1){
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"toggle","toggle",1291842030),true,new cljs.core.Keyword(null,"visible","visible",-1024216805),visible__$1], null);
});})(visible,change_visibility,vec__36124,attributes,children))
).call(null,visible),""),hoplon.core.span.call(null,new cljs.core.Keyword(null,"title","title",636505583).cljs$core$IFn$_invoke$arity$1(attributes))),hoplon.core.div.call(null,new cljs.core.Keyword(null,"class","class",-2030961996),"control-visibility-container",new cljs.core.Keyword(null,"toggle","toggle",1291842030),visible,new cljs.core.Keyword(null,"fade-toggle","fade-toggle",-1468421852),visible,hoplon.core.div.call(null,new cljs.core.Keyword(null,"class","class",-2030961996),"control-container",children)));
};
var weathergen$ui$common$control_section = function (var_args){
var args__29571__auto__ = null;
if (arguments.length > 0) {
var G__36127__i = 0, G__36127__a = new Array(arguments.length -  0);
while (G__36127__i < G__36127__a.length) {G__36127__a[G__36127__i] = arguments[G__36127__i + 0]; ++G__36127__i;}
  args__29571__auto__ = new cljs.core.IndexedSeq(G__36127__a,0,null);
} 
return weathergen$ui$common$control_section__delegate.call(this,args__29571__auto__);};
weathergen$ui$common$control_section.cljs$lang$maxFixedArity = 0;
weathergen$ui$common$control_section.cljs$lang$applyTo = (function (arglist__36128){
var args__29571__auto__ = cljs.core.seq(arglist__36128);
return weathergen$ui$common$control_section__delegate(args__29571__auto__);
});
weathergen$ui$common$control_section.cljs$core$IFn$_invoke$arity$variadic = weathergen$ui$common$control_section__delegate;
return weathergen$ui$common$control_section;
})()
;
/**
 * Formats a campaign time into a string. `opts` is a map of options:
 * 
 *   `:seconds?` - If true, format time including seconds.
 *   `:omit-day?` - If true, don't include the day in the result
 */
weathergen.ui.common.format_time = (function weathergen$ui$common$format_time(var_args){
var args36129 = [];
var len__24369__auto___36141 = arguments.length;
var i__24370__auto___36142 = (0);
while(true){
if((i__24370__auto___36142 < len__24369__auto___36141)){
args36129.push((arguments[i__24370__auto___36142]));

var G__36143 = (i__24370__auto___36142 + (1));
i__24370__auto___36142 = G__36143;
continue;
} else {
}
break;
}

var G__36131 = args36129.length;
switch (G__36131) {
case 1:
return weathergen.ui.common.format_time.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));

break;
case 2:
return weathergen.ui.common.format_time.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));

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

}
});

weathergen.ui.common.format_time.cljs$core$IFn$_invoke$arity$1 = (function (p__36132){
var map__36133 = p__36132;
var map__36133__$1 = ((((!((map__36133 == null)))?((((map__36133.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__36133.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__36133):map__36133);
var time = map__36133__$1;
var day = cljs.core.get.call(null,map__36133__$1,new cljs.core.Keyword(null,"day","day",-274800446));
var hour = cljs.core.get.call(null,map__36133__$1,new cljs.core.Keyword(null,"hour","hour",-555989214));
var minute = cljs.core.get.call(null,map__36133__$1,new cljs.core.Keyword(null,"minute","minute",-642875969));
var second = cljs.core.get.call(null,map__36133__$1,new cljs.core.Keyword(null,"second","second",-444702010));
return weathergen.ui.common.format_time.call(null,time,cljs.core.PersistentArrayMap.EMPTY);
});

weathergen.ui.common.format_time.cljs$core$IFn$_invoke$arity$2 = (function (p__36135,p__36136){
var map__36137 = p__36135;
var map__36137__$1 = ((((!((map__36137 == null)))?((((map__36137.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__36137.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__36137):map__36137);
var time = map__36137__$1;
var day = cljs.core.get.call(null,map__36137__$1,new cljs.core.Keyword(null,"day","day",-274800446));
var hour = cljs.core.get.call(null,map__36137__$1,new cljs.core.Keyword(null,"hour","hour",-555989214));
var minute = cljs.core.get.call(null,map__36137__$1,new cljs.core.Keyword(null,"minute","minute",-642875969));
var second = cljs.core.get.call(null,map__36137__$1,new cljs.core.Keyword(null,"second","second",-444702010));
var map__36138 = p__36136;
var map__36138__$1 = ((((!((map__36138 == null)))?((((map__36138.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__36138.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__36138):map__36138);
var opts = map__36138__$1;
var seconds_QMARK_ = cljs.core.get.call(null,map__36138__$1,new cljs.core.Keyword(null,"seconds?","seconds?",-1600404958));
var omit_day_QMARK_ = cljs.core.get.call(null,map__36138__$1,new cljs.core.Keyword(null,"omit-day?","omit-day?",1622751707));
if(cljs.core.truth_(time)){
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1((cljs.core.truth_(omit_day_QMARK_)?"":goog.string.format("%02d/",day))),cljs.core.str.cljs$core$IFn$_invoke$arity$1((cljs.core.truth_(seconds_QMARK_)?goog.string.format("%02d:%02d:%02d",hour,minute,second):goog.string.format("%02d:%02d",hour,minute)))].join('');
} else {
return null;
}
});

weathergen.ui.common.format_time.cljs$lang$maxFixedArity = 2;

/**
 * Formats a heading
 */
weathergen.ui.common.format_heading = (function weathergen$ui$common$format_heading(heading){
var G__36146 = heading;
if((G__36146 == null)){
return null;
} else {
return G__36146.toFixed((0));
}
});
/**
 * Formats a distance
 */
weathergen.ui.common.format_distance = (function weathergen$ui$common$format_distance(distance){
var G__36148 = distance;
if((G__36148 == null)){
return null;
} else {
return G__36148.toFixed((1));
}
});
/**
 * Formats a speed.
 */
weathergen.ui.common.format_speed = (function weathergen$ui$common$format_speed(speed){
var G__36150 = speed;
var G__36150__$1 = (((G__36150 == null))?null:weathergen.math.nearest.call(null,G__36150,(5)));
if((G__36150__$1 == null)){
return null;
} else {
return G__36150__$1.toFixed((0));
}
});
/**
 * Formats a Mach number.
 */
weathergen.ui.common.format_mach = (function weathergen$ui$common$format_mach(mach){
var G__36152 = mach;
if((G__36152 == null)){
return null;
} else {
return G__36152.toFixed((2));
}
});
/**
 * @param {...*} var_args
 */
weathergen.ui.common.color_picker = (function() { 
var weathergen$ui$common$color_picker__delegate = function (args__29571__auto__){
var vec__36160 = hoplon.core.parse_args.call(null,args__29571__auto__);
var attrs = cljs.core.nth.call(null,vec__36160,(0),null);
var _ = cljs.core.nth.call(null,vec__36160,(1),null);
var map__36163 = attrs;
var map__36163__$1 = ((((!((map__36163 == null)))?((((map__36163.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__36163.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__36163):map__36163);
var change = cljs.core.get.call(null,map__36163__$1,new cljs.core.Keyword(null,"change","change",-1163046502));
var hide = cljs.core.get.call(null,map__36163__$1,new cljs.core.Keyword(null,"hide","hide",-596913169));
var show = cljs.core.get.call(null,map__36163__$1,new cljs.core.Keyword(null,"show","show",-576705889));
var attrs_STAR_ = cljs.core.dissoc.call(null,attrs,new cljs.core.Keyword(null,"change","change",-1163046502),new cljs.core.Keyword(null,"hide","hide",-596913169),new cljs.core.Keyword(null,"show","show",-576705889));
var open_QMARK_ = cljs.core.atom.call(null,false);
var i = hoplon.core.input.call(null,attrs_STAR_,new cljs.core.Keyword(null,"class","class",-2030961996),"minicolors",new cljs.core.Keyword(null,"type","type",1174270348),"hidden",new cljs.core.Keyword(null,"change","change",-1163046502),((function (map__36163,map__36163__$1,change,hide,show,attrs_STAR_,open_QMARK_,vec__36160,attrs,_){
return (function (e){
if(cljs.core.truth_((function (){var and__23136__auto__ = change;
if(cljs.core.truth_(and__23136__auto__)){
return cljs.core.deref.call(null,open_QMARK_);
} else {
return and__23136__auto__;
}
})())){
return change.call(null,e);
} else {
return null;
}
});})(map__36163,map__36163__$1,change,hide,show,attrs_STAR_,open_QMARK_,vec__36160,attrs,_))
);
cljs.core.add_watch.call(null,new cljs.core.Keyword(null,"value","value",305978217).cljs$core$IFn$_invoke$arity$1(attrs),cljs.core.keyword.call(null,[cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.gensym.call(null))].join('')),((function (i,map__36163,map__36163__$1,change,hide,show,attrs_STAR_,open_QMARK_,vec__36160,attrs,_){
return (function (___$1,___$2,___$3,n){
if(cljs.core.truth_(n)){
return (function (){var G__36165 = jQuery(i);
return G__36165;
})().minicolors("value",weathergen.ui.common.to_hex_str.call(null,n));
} else {
return null;
}
});})(i,map__36163,map__36163__$1,change,hide,show,attrs_STAR_,open_QMARK_,vec__36160,attrs,_))
);

hoplon.core.when_dom.call(null,i,((function (i,map__36163,map__36163__$1,change,hide,show,attrs_STAR_,open_QMARK_,vec__36160,attrs,_){
return (function (){
return (function (){var G__36166 = jQuery(i);
return G__36166;
})().minicolors(({"theme": "weathergen", "show": ((function (i,map__36163,map__36163__$1,change,hide,show,attrs_STAR_,open_QMARK_,vec__36160,attrs,_){
return (function (){
cljs.core.reset_BANG_.call(null,open_QMARK_,true);

if(cljs.core.truth_(show)){
return show.call(null);
} else {
return null;
}
});})(i,map__36163,map__36163__$1,change,hide,show,attrs_STAR_,open_QMARK_,vec__36160,attrs,_))
, "hide": ((function (i,map__36163,map__36163__$1,change,hide,show,attrs_STAR_,open_QMARK_,vec__36160,attrs,_){
return (function (){
cljs.core.reset_BANG_.call(null,open_QMARK_,false);

if(cljs.core.truth_(hide)){
return hide.call(null);
} else {
return null;
}
});})(i,map__36163,map__36163__$1,change,hide,show,attrs_STAR_,open_QMARK_,vec__36160,attrs,_))
}));
});})(i,map__36163,map__36163__$1,change,hide,show,attrs_STAR_,open_QMARK_,vec__36160,attrs,_))
);

return i;
};
var weathergen$ui$common$color_picker = function (var_args){
var args__29571__auto__ = null;
if (arguments.length > 0) {
var G__36167__i = 0, G__36167__a = new Array(arguments.length -  0);
while (G__36167__i < G__36167__a.length) {G__36167__a[G__36167__i] = arguments[G__36167__i + 0]; ++G__36167__i;}
  args__29571__auto__ = new cljs.core.IndexedSeq(G__36167__a,0,null);
} 
return weathergen$ui$common$color_picker__delegate.call(this,args__29571__auto__);};
weathergen$ui$common$color_picker.cljs$lang$maxFixedArity = 0;
weathergen$ui$common$color_picker.cljs$lang$applyTo = (function (arglist__36168){
var args__29571__auto__ = cljs.core.seq(arglist__36168);
return weathergen$ui$common$color_picker__delegate(args__29571__auto__);
});
weathergen$ui$common$color_picker.cljs$core$IFn$_invoke$arity$variadic = weathergen$ui$common$color_picker__delegate;
return weathergen$ui$common$color_picker;
})()
;
/**
 * Returns UI for the display name of a side.
 * @param {...*} var_args
 */
weathergen.ui.common.side_label = (function() { 
var weathergen$ui$common$side_label__delegate = function (args__29571__auto__){
var vec__36193 = hoplon.core.parse_args.call(null,args__29571__auto__);
var attrs = cljs.core.nth.call(null,vec__36193,(0),null);
var _ = cljs.core.nth.call(null,vec__36193,(1),null);
var map__36196 = attrs;
var map__36196__$1 = ((((!((map__36196 == null)))?((((map__36196.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__36196.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__36196):map__36196);
var mission = cljs.core.get.call(null,map__36196__$1,new cljs.core.Keyword(null,"mission","mission",1740288522));
var side = cljs.core.get.call(null,map__36196__$1,new cljs.core.Keyword(null,"side","side",389652279));
var allies = javelin.core.formula.call(null,((function (map__36196,map__36196__$1,mission,side,vec__36193,attrs,_){
return (function (mission__$1,side__$1){
var side_teams = cljs.core.set.call(null,cljs.core.map.call(null,((function (map__36196,map__36196__$1,mission,side,vec__36193,attrs,_){
return (function (p1__36170_SHARP_){
return new cljs.core.Keyword(null,"who","who",-235935040).cljs$core$IFn$_invoke$arity$1(new cljs.core.Keyword(null,"team","team",1355747699).cljs$core$IFn$_invoke$arity$1(p1__36170_SHARP_));
});})(map__36196,map__36196__$1,mission,side,vec__36193,attrs,_))
,cljs.core.filter.call(null,((function (map__36196,map__36196__$1,mission,side,vec__36193,attrs,_){
return (function (p1__36169_SHARP_){
return cljs.core._EQ_.call(null,new cljs.core.Keyword(null,"c-team","c-team",1058111407).cljs$core$IFn$_invoke$arity$1(new cljs.core.Keyword(null,"team","team",1355747699).cljs$core$IFn$_invoke$arity$1(p1__36169_SHARP_)),side__$1);
});})(map__36196,map__36196__$1,mission,side,vec__36193,attrs,_))
,weathergen.falcon.files.mission.teams.call(null,mission__$1))));
return cljs.core.disj.call(null,side_teams,side__$1);
});})(map__36196,map__36196__$1,mission,side,vec__36193,attrs,_))
).call(null,mission,side);
return hoplon.core.div.call(null,cljs.core.dissoc.call(null,attrs,new cljs.core.Keyword(null,"mission","mission",1740288522),new cljs.core.Keyword(null,"side","side",389652279)),hoplon.core.loop_tpl_STAR_.call(null,javelin.core.formula.call(null,((function (map__36196,map__36196__$1,mission,side,allies,vec__36193,attrs,_){
return (function (mission__$1,side__$1,allies__$1){
return cljs.core.interpose.call(null,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"color","color",1011675173),"",new cljs.core.Keyword(null,"name","name",1843675177),"/"], null),(function (){var iter__24010__auto__ = ((function (map__36196,map__36196__$1,mission,side,allies,vec__36193,attrs,_){
return (function weathergen$ui$common$side_label_$_iter__36198(s__36199){
return (new cljs.core.LazySeq(null,((function (map__36196,map__36196__$1,mission,side,allies,vec__36193,attrs,_){
return (function (){
var s__36199__$1 = s__36199;
while(true){
var temp__5278__auto__ = cljs.core.seq.call(null,s__36199__$1);
if(temp__5278__auto__){
var s__36199__$2 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,s__36199__$2)){
var c__24008__auto__ = cljs.core.chunk_first.call(null,s__36199__$2);
var size__24009__auto__ = cljs.core.count.call(null,c__24008__auto__);
var b__36201 = cljs.core.chunk_buffer.call(null,size__24009__auto__);
if((function (){var i__36200 = (0);
while(true){
if((i__36200 < size__24009__auto__)){
var team = cljs.core._nth.call(null,c__24008__auto__,i__36200);
cljs.core.chunk_append.call(null,b__36201,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"color","color",1011675173),weathergen.ui.common.team_color.call(null,team,new cljs.core.Keyword(null,"dark-text","dark-text",814777253)),new cljs.core.Keyword(null,"name","name",1843675177),weathergen.falcon.files.mission.team_name.call(null,mission__$1,team)], null));

var G__36215 = (i__36200 + (1));
i__36200 = G__36215;
continue;
} else {
return true;
}
break;
}
})()){
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__36201),weathergen$ui$common$side_label_$_iter__36198.call(null,cljs.core.chunk_rest.call(null,s__36199__$2)));
} else {
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__36201),null);
}
} else {
var team = cljs.core.first.call(null,s__36199__$2);
return cljs.core.cons.call(null,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"color","color",1011675173),weathergen.ui.common.team_color.call(null,team,new cljs.core.Keyword(null,"dark-text","dark-text",814777253)),new cljs.core.Keyword(null,"name","name",1843675177),weathergen.falcon.files.mission.team_name.call(null,mission__$1,team)], null),weathergen$ui$common$side_label_$_iter__36198.call(null,cljs.core.rest.call(null,s__36199__$2)));
}
} else {
return null;
}
break;
}
});})(map__36196,map__36196__$1,mission,side,allies,vec__36193,attrs,_))
,null,null));
});})(map__36196,map__36196__$1,mission,side,allies,vec__36193,attrs,_))
;
return iter__24010__auto__.call(null,cljs.core.into.call(null,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [side__$1], null),allies__$1));
})());
});})(map__36196,map__36196__$1,mission,side,allies,vec__36193,attrs,_))
).call(null,mission,side,allies),((function (map__36196,map__36196__$1,mission,side,allies,vec__36193,attrs,_){
return (function (item__29615__auto__){
var vec__36202 = javelin.core.cell_map.call(null,cljs.core.identity,javelin.core.formula.call(null,((function (map__36196,map__36196__$1,mission,side,allies,vec__36193,attrs,_){
return (function (elem){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [elem], null);
});})(map__36196,map__36196__$1,mission,side,allies,vec__36193,attrs,_))
).call(null,item__29615__auto__));
var elem = cljs.core.nth.call(null,vec__36202,(0),null);
var vec__36207 = javelin.core.cell_map.call(null,cljs.core.identity,javelin.core.formula.call(null,((function (vec__36202,elem,map__36196,map__36196__$1,mission,side,allies,vec__36193,attrs,_){
return (function (p__36210){
var map__36211 = p__36210;
var map__36211__$1 = ((((!((map__36211 == null)))?((((map__36211.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__36211.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__36211):map__36211);
var color = cljs.core.get.call(null,map__36211__$1,new cljs.core.Keyword(null,"color","color",1011675173));
var name = cljs.core.get.call(null,map__36211__$1,new cljs.core.Keyword(null,"name","name",1843675177));
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [color,name], null);
});})(vec__36202,elem,map__36196,map__36196__$1,mission,side,allies,vec__36193,attrs,_))
).call(null,elem));
var color = cljs.core.nth.call(null,vec__36207,(0),null);
var name = cljs.core.nth.call(null,vec__36207,(1),null);
return hoplon.core.span.call(null,new cljs.core.Keyword(null,"css","css",1135045163),javelin.core.formula.call(null,((function (vec__36207,color,name,vec__36202,elem,map__36196,map__36196__$1,mission,side,allies,vec__36193,attrs,_){
return (function (G__36213){
return new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"color","color",1011675173),G__36213], null);
});})(vec__36207,color,name,vec__36202,elem,map__36196,map__36196__$1,mission,side,allies,vec__36193,attrs,_))
).call(null,color),javelin.core.formula.call(null,((function (vec__36207,color,name,vec__36202,elem,map__36196,map__36196__$1,mission,side,allies,vec__36193,attrs,_){
return (function (G__36214){
return G__36214;
});})(vec__36207,color,name,vec__36202,elem,map__36196,map__36196__$1,mission,side,allies,vec__36193,attrs,_))
).call(null,name));
});})(map__36196,map__36196__$1,mission,side,allies,vec__36193,attrs,_))
));
};
var weathergen$ui$common$side_label = function (var_args){
var args__29571__auto__ = null;
if (arguments.length > 0) {
var G__36216__i = 0, G__36216__a = new Array(arguments.length -  0);
while (G__36216__i < G__36216__a.length) {G__36216__a[G__36216__i] = arguments[G__36216__i + 0]; ++G__36216__i;}
  args__29571__auto__ = new cljs.core.IndexedSeq(G__36216__a,0,null);
} 
return weathergen$ui$common$side_label__delegate.call(this,args__29571__auto__);};
weathergen$ui$common$side_label.cljs$lang$maxFixedArity = 0;
weathergen$ui$common$side_label.cljs$lang$applyTo = (function (arglist__36217){
var args__29571__auto__ = cljs.core.seq(arglist__36217);
return weathergen$ui$common$side_label__delegate(args__29571__auto__);
});
weathergen$ui$common$side_label.cljs$core$IFn$_invoke$arity$variadic = weathergen$ui$common$side_label__delegate;
return weathergen$ui$common$side_label;
})()
;
/**
 * Returns a path to where we should cache an image.
 */
weathergen.ui.common.image_cache_path = (function weathergen$ui$common$image_cache_path(image_descriptor){
return weathergen.filesystem.path_combine.call(null,weathergen.settings.app_dir,"cache","images",[cljs.core.str.cljs$core$IFn$_invoke$arity$1(weathergen.falcon.files.images.cache_key.call(null,image_descriptor)),cljs.core.str.cljs$core$IFn$_invoke$arity$1(".png")].join(''));
});
/**
 * Asynchronously saves `blob` to `path`.
 */
weathergen.ui.common.save_blob_async = (function weathergen$ui$common$save_blob_async(blob,path){
var reader = (new FileReader());
reader.onload = ((function (reader){
return (function (){
return weathergen.filesystem.save_data.call(null,path,(new Buffer(reader.result)));
});})(reader))
;

return reader.readAsArrayBuffer(blob);
});
/**
 * Return a URL for the image identified by `image-descriptor`.
 */
weathergen.ui.common.get_image = (function weathergen$ui$common$get_image(mission,image_descriptor){
var path = weathergen.ui.common.image_cache_path.call(null,image_descriptor);
if(cljs.core.truth_(weathergen.filesystem.exists_QMARK_.call(null,path))){
return path;
} else {
var canvas = document.createElement("canvas");
var timer_name__15521__auto___36218 = [cljs.core.str.cljs$core$IFn$_invoke$arity$1("Loading image "),cljs.core.str.cljs$core$IFn$_invoke$arity$1(new cljs.core.Keyword(null,"image-id","image-id",-988480565).cljs$core$IFn$_invoke$arity$1(image_descriptor))].join('');
var ignore__15522__auto___36219 = console.time(timer_name__15521__auto___36218);
var result__15523__auto___36220 = weathergen.falcon.files.images.read_image.call(null,mission,image_descriptor,((function (timer_name__15521__auto___36218,ignore__15522__auto___36219,canvas,path){
return (function (width,height){
canvas.width = width;

canvas.height = height;

var context = canvas.getContext("2d");
var image_data = context.getImageData((0),(0),width,height);
var buf = (new ArrayBuffer(image_data.data.length));
var buf8 = (new Uint8ClampedArray(buf));
var data = (new Uint32Array(buf));
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"set-pixel!","set-pixel!",1287500897),((function (context,image_data,buf,buf8,data,timer_name__15521__auto___36218,ignore__15522__auto___36219,canvas,path){
return (function (x,y,argb){
return (data[(x + (y * width))] = argb);
});})(context,image_data,buf,buf8,data,timer_name__15521__auto___36218,ignore__15522__auto___36219,canvas,path))
,new cljs.core.Keyword(null,"finalize","finalize",-1152897571),((function (context,image_data,buf,buf8,data,timer_name__15521__auto___36218,ignore__15522__auto___36219,canvas,path){
return (function (){
image_data.data.set(buf8);

return context.putImageData(image_data,(0),(0));
});})(context,image_data,buf,buf8,data,timer_name__15521__auto___36218,ignore__15522__auto___36219,canvas,path))
], null);
});})(timer_name__15521__auto___36218,ignore__15522__auto___36219,canvas,path))
);
console.timeEnd(timer_name__15521__auto___36218);


canvas.toBlob(((function (canvas,path){
return (function (blob){
return weathergen.ui.common.save_blob_async.call(null,blob,path);
});})(canvas,path))
);

return canvas.toDataURL();
}
});
/**
 * Draws a grid of flags and checkboxes to pick teams.
 * @param {...*} var_args
 */
weathergen.ui.common.team_selector = (function() { 
var weathergen$ui$common$team_selector__delegate = function (args__29571__auto__){
var vec__36244 = hoplon.core.parse_args.call(null,args__29571__auto__);
var attrs = cljs.core.nth.call(null,vec__36244,(0),null);
var _ = cljs.core.nth.call(null,vec__36244,(1),null);
var map__36247 = attrs;
var map__36247__$1 = ((((!((map__36247 == null)))?((((map__36247.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__36247.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__36247):map__36247);
var selectable_teams = cljs.core.get.call(null,map__36247__$1,new cljs.core.Keyword(null,"selectable-teams","selectable-teams",1104557919));
var mission = cljs.core.get.call(null,map__36247__$1,new cljs.core.Keyword(null,"mission","mission",1740288522));
var selected_teams = cljs.core.get.call(null,map__36247__$1,new cljs.core.Keyword(null,"selected-teams","selected-teams",317107671));
var attrs__$1 = cljs.core.dissoc.call(null,attrs,new cljs.core.Keyword(null,"mission","mission",1740288522),new cljs.core.Keyword(null,"selected-teams","selected-teams",317107671),new cljs.core.Keyword(null,"selectable-teams","selectable-teams",1104557919));
return hoplon.core.div.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"margin-bottom","margin-bottom",388334941),"5px"], null),attrs__$1,hoplon.core.loop_tpl_STAR_.call(null,javelin.core.formula.call(null,((function (map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_){
return (function (G__36249,G__36250){
return G__36249.call(null,G__36250);
});})(map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_))
).call(null,weathergen.falcon.files.mission.teams,mission),((function (map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_){
return (function (item__29615__auto__){
var vec__36251 = javelin.core.cell_map.call(null,cljs.core.identity,javelin.core.formula.call(null,((function (map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_){
return (function (team){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [team], null);
});})(map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_))
).call(null,item__29615__auto__));
var team = cljs.core.nth.call(null,vec__36251,(0),null);
return weathergen.ui.common.inl.call(null,new cljs.core.Keyword(null,"css","css",1135045163),javelin.core.formula.call(null,((function (vec__36251,team,map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_){
return (function (team__$1){
return new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,"margin-right","margin-right",809689658),"3px",new cljs.core.Keyword(null,"padding","padding",1660304693),"3px",new cljs.core.Keyword(null,"border","border",1444987323),[cljs.core.str.cljs$core$IFn$_invoke$arity$1("2px solid "),cljs.core.str.cljs$core$IFn$_invoke$arity$1(weathergen.ui.common.team_color.call(null,team__$1,new cljs.core.Keyword(null,"dark-text","dark-text",814777253)))].join(''),new cljs.core.Keyword(null,"text-align","text-align",1786091845),"center",new cljs.core.Keyword(null,"vertical-align","vertical-align",651007333),"top"], null);
});})(vec__36251,team,map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_))
).call(null,team),hoplon.core.img.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"border","border",1444987323),"solid 1px black"], null),new cljs.core.Keyword(null,"src","src",-1651076051),javelin.core.formula.call(null,((function (vec__36251,team,map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_){
return (function (mission__$1,team__$1){
return weathergen.ui.common.get_image.call(null,mission__$1,weathergen.falcon.files.mission.team_flag.call(null,mission__$1,team__$1,new cljs.core.Keyword(null,"big-vert","big-vert",-1944398663)));
});})(vec__36251,team,map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_))
).call(null,mission,team)),hoplon.core.div.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"text-align","text-align",1786091845),"center"], null),hoplon.core.span.call(null,new cljs.core.Keyword(null,"css","css",1135045163),javelin.core.formula.call(null,((function (vec__36251,team,map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_){
return (function (G__36255,G__36254){
return new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"color","color",1011675173),G__36254.call(null,G__36255,new cljs.core.Keyword(null,"dark-text","dark-text",814777253))], null);
});})(vec__36251,team,map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_))
).call(null,team,weathergen.ui.common.team_color),javelin.core.formula.call(null,((function (vec__36251,team,map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_){
return (function (G__36256,G__36257,G__36258){
return G__36256.call(null,G__36257,new cljs.core.Keyword(null,"who","who",-235935040).cljs$core$IFn$_invoke$arity$1(new cljs.core.Keyword(null,"team","team",1355747699).cljs$core$IFn$_invoke$arity$1(G__36258)));
});})(vec__36251,team,map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_))
).call(null,weathergen.falcon.files.mission.team_name,mission,team))),hoplon.core.div.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"text-align","text-align",1786091845),"center",new cljs.core.Keyword(null,"height","height",1025178622),"33px"], null),(function (){var val = javelin.core.formula.call(null,((function (vec__36251,team,map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_){
return (function (G__36259,G__36261,G__36262,G__36260){
return G__36259.call(null,G__36260,G__36261.call(null,G__36262));
});})(vec__36251,team,map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_))
).call(null,cljs.core.contains_QMARK_,weathergen.falcon.files.mission.team_number,team,selected_teams);
var enabled_QMARK_ = javelin.core.formula.call(null,((function (val,vec__36251,team,map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_){
return (function (G__36263,G__36264,G__36265,G__36266){
return G__36263.call(null,G__36264,G__36265.call(null,G__36266));
});})(val,vec__36251,team,map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_))
).call(null,cljs.core.contains_QMARK_,selectable_teams,weathergen.falcon.files.mission.team_number,team);
return hoplon.core.input.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"margin","margin",-995903681),"auto"], null),new cljs.core.Keyword(null,"type","type",1174270348),"checkbox",new cljs.core.Keyword(null,"toggle","toggle",1291842030),enabled_QMARK_,new cljs.core.Keyword(null,"value","value",305978217),val,new cljs.core.Keyword(null,"change","change",-1163046502),((function (val,enabled_QMARK_,vec__36251,team,map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_){
return (function (){
return cljs.core.swap_BANG_.call(null,selected_teams,cljs.core.comp.call(null,cljs.core.set,(cljs.core.truth_(cljs.core.deref.call(null,val))?cljs.core.disj:cljs.core.conj)),weathergen.falcon.files.mission.team_number.call(null,cljs.core.deref.call(null,team)));
});})(val,enabled_QMARK_,vec__36251,team,map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_))
);
})()));
});})(map__36247,map__36247__$1,selectable_teams,mission,selected_teams,attrs__$1,vec__36244,attrs,_))
));
};
var weathergen$ui$common$team_selector = function (var_args){
var args__29571__auto__ = null;
if (arguments.length > 0) {
var G__36267__i = 0, G__36267__a = new Array(arguments.length -  0);
while (G__36267__i < G__36267__a.length) {G__36267__a[G__36267__i] = arguments[G__36267__i + 0]; ++G__36267__i;}
  args__29571__auto__ = new cljs.core.IndexedSeq(G__36267__a,0,null);
} 
return weathergen$ui$common$team_selector__delegate.call(this,args__29571__auto__);};
weathergen$ui$common$team_selector.cljs$lang$maxFixedArity = 0;
weathergen$ui$common$team_selector.cljs$lang$applyTo = (function (arglist__36268){
var args__29571__auto__ = cljs.core.seq(arglist__36268);
return weathergen$ui$common$team_selector__delegate(args__29571__auto__);
});
weathergen$ui$common$team_selector.cljs$core$IFn$_invoke$arity$variadic = weathergen$ui$common$team_selector__delegate;
return weathergen$ui$common$team_selector;
})()
;
/**
 * Draws a grid of flags and checkboxes to pick sides.
 * @param {...*} var_args
 */
weathergen.ui.common.side_selector = (function() { 
var weathergen$ui$common$side_selector__delegate = function (args__29571__auto__){
var vec__36289 = hoplon.core.parse_args.call(null,args__29571__auto__);
var attrs = cljs.core.nth.call(null,vec__36289,(0),null);
var _ = cljs.core.nth.call(null,vec__36289,(1),null);
var map__36292 = attrs;
var map__36292__$1 = ((((!((map__36292 == null)))?((((map__36292.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__36292.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__36292):map__36292);
var selected_sides = cljs.core.get.call(null,map__36292__$1,new cljs.core.Keyword(null,"selected-sides","selected-sides",-922979619));
var mission = cljs.core.get.call(null,map__36292__$1,new cljs.core.Keyword(null,"mission","mission",1740288522));
var attrs__$1 = cljs.core.dissoc.call(null,attrs,new cljs.core.Keyword(null,"mission","mission",1740288522),new cljs.core.Keyword(null,"selected-sides","selected-sides",-922979619));
return hoplon.core.div.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"margin-bottom","margin-bottom",388334941),"5px"], null),attrs__$1,hoplon.core.loop_tpl_STAR_.call(null,javelin.core.formula.call(null,((function (map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_){
return (function (G__36295,G__36294){
return G__36294.call(null,G__36295);
});})(map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_))
).call(null,mission,weathergen.falcon.files.mission.sides),((function (map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_){
return (function (item__29615__auto__){
var vec__36296 = javelin.core.cell_map.call(null,cljs.core.identity,javelin.core.formula.call(null,((function (map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_){
return (function (side){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [side], null);
});})(map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_))
).call(null,item__29615__auto__));
var side = cljs.core.nth.call(null,vec__36296,(0),null);
return weathergen.ui.common.inl.call(null,new cljs.core.Keyword(null,"css","css",1135045163),javelin.core.formula.call(null,((function (vec__36296,side,map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_){
return (function (side__$1){
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"margin-right","margin-right",809689658),"3px",new cljs.core.Keyword(null,"padding","padding",1660304693),"3px",new cljs.core.Keyword(null,"border","border",1444987323),[cljs.core.str.cljs$core$IFn$_invoke$arity$1("2px solid "),cljs.core.str.cljs$core$IFn$_invoke$arity$1(weathergen.ui.common.team_color.call(null,side__$1,new cljs.core.Keyword(null,"dark-text","dark-text",814777253)))].join(''),new cljs.core.Keyword(null,"text-align","text-align",1786091845),"center"], null);
});})(vec__36296,side,map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_))
).call(null,side),hoplon.core.loop_tpl_STAR_.call(null,javelin.core.formula.call(null,((function (vec__36296,side,map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_){
return (function (G__36300,G__36299,G__36301){
return G__36299.call(null,G__36300,G__36301);
});})(vec__36296,side,map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_))
).call(null,mission,weathergen.falcon.files.mission.teams_for_side,side),((function (vec__36296,side,map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_){
return (function (item__29615__auto____$1){
var vec__36302 = javelin.core.cell_map.call(null,cljs.core.identity,javelin.core.formula.call(null,((function (vec__36296,side,map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_){
return (function (team){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [team], null);
});})(vec__36296,side,map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_))
).call(null,item__29615__auto____$1));
var team = cljs.core.nth.call(null,vec__36302,(0),null);
return hoplon.core.img.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"border","border",1444987323),"solid 1px black",new cljs.core.Keyword(null,"padding-right","padding-right",-1250249681),"2px"], null),new cljs.core.Keyword(null,"src","src",-1651076051),javelin.core.formula.call(null,((function (vec__36302,team,vec__36296,side,map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_){
return (function (mission__$1,team__$1){
return weathergen.ui.common.get_image.call(null,mission__$1,weathergen.falcon.files.mission.team_flag.call(null,mission__$1,team__$1,new cljs.core.Keyword(null,"big-vert","big-vert",-1944398663)));
});})(vec__36302,team,vec__36296,side,map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_))
).call(null,mission,team));
});})(vec__36296,side,map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_))
),hoplon.core.div.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"text-align","text-align",1786091845),"center"], null),weathergen.ui.common.side_label.call(null,new cljs.core.Keyword(null,"mission","mission",1740288522),mission,new cljs.core.Keyword(null,"side","side",389652279),side)),hoplon.core.div.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"text-align","text-align",1786091845),"center"], null),(function (){var val = javelin.core.formula.call(null,((function (vec__36296,side,map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_){
return (function (G__36305,G__36306,G__36307,G__36308){
return G__36305.call(null,G__36306,G__36307.call(null,G__36308));
});})(vec__36296,side,map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_))
).call(null,cljs.core.contains_QMARK_,selected_sides,weathergen.falcon.files.mission.team_number,side);
return hoplon.core.input.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"margin","margin",-995903681),"auto"], null),new cljs.core.Keyword(null,"type","type",1174270348),"checkbox",new cljs.core.Keyword(null,"value","value",305978217),val,new cljs.core.Keyword(null,"change","change",-1163046502),((function (val,vec__36296,side,map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_){
return (function (){
return cljs.core.swap_BANG_.call(null,selected_sides,cljs.core.comp.call(null,cljs.core.set,(cljs.core.truth_(cljs.core.deref.call(null,val))?cljs.core.disj:cljs.core.conj)),weathergen.falcon.files.mission.team_number.call(null,cljs.core.deref.call(null,side)));
});})(val,vec__36296,side,map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_))
);
})()));
});})(map__36292,map__36292__$1,selected_sides,mission,attrs__$1,vec__36289,attrs,_))
));
};
var weathergen$ui$common$side_selector = function (var_args){
var args__29571__auto__ = null;
if (arguments.length > 0) {
var G__36309__i = 0, G__36309__a = new Array(arguments.length -  0);
while (G__36309__i < G__36309__a.length) {G__36309__a[G__36309__i] = arguments[G__36309__i + 0]; ++G__36309__i;}
  args__29571__auto__ = new cljs.core.IndexedSeq(G__36309__a,0,null);
} 
return weathergen$ui$common$side_selector__delegate.call(this,args__29571__auto__);};
weathergen$ui$common$side_selector.cljs$lang$maxFixedArity = 0;
weathergen$ui$common$side_selector.cljs$lang$applyTo = (function (arglist__36310){
var args__29571__auto__ = cljs.core.seq(arglist__36310);
return weathergen$ui$common$side_selector__delegate(args__29571__auto__);
});
weathergen$ui$common$side_selector.cljs$core$IFn$_invoke$arity$variadic = weathergen$ui$common$side_selector__delegate;
return weathergen$ui$common$side_selector;
})()
;
/**
 * Renders an HTML select. Attrs include :value, a cell or lens
 *   containing the current choice, which will be updated when the choice
 *   changes, and :choices, a vector of maps containing :value and :label
 *   keys.
 * @param {...*} var_args
 */
weathergen.ui.common.dropdown = (function() { 
var weathergen$ui$common$dropdown__delegate = function (args__29571__auto__){
var vec__36345 = hoplon.core.parse_args.call(null,args__29571__auto__);
var attrs = cljs.core.nth.call(null,vec__36345,(0),null);
var _ = cljs.core.nth.call(null,vec__36345,(1),null);
var map__36348 = attrs;
var map__36348__$1 = ((((!((map__36348 == null)))?((((map__36348.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__36348.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__36348):map__36348);
var value = cljs.core.get.call(null,map__36348__$1,new cljs.core.Keyword(null,"value","value",305978217));
var choices = cljs.core.get.call(null,map__36348__$1,new cljs.core.Keyword(null,"choices","choices",1385611597));
var attrs__$1 = cljs.core.dissoc.call(null,attrs,new cljs.core.Keyword(null,"value","value",305978217),new cljs.core.Keyword(null,"choices","choices",1385611597));
var indexed = cljs.core.map_indexed.call(null,((function (map__36348,map__36348__$1,value,choices,attrs__$1,vec__36345,attrs,_){
return (function (i,c){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [[cljs.core.str.cljs$core$IFn$_invoke$arity$1(i)].join(''),cljs.core.assoc.call(null,c,new cljs.core.Keyword("weathergen.ui.common","index","weathergen.ui.common/index",-813327910),[cljs.core.str.cljs$core$IFn$_invoke$arity$1(i)].join(''))], null);
});})(map__36348,map__36348__$1,value,choices,attrs__$1,vec__36345,attrs,_))
,choices);
var by_index = cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,indexed);
var s = hoplon.core.select.call(null);
s.call(null,cljs.core.assoc.call(null,attrs__$1,new cljs.core.Keyword(null,"value","value",305978217),javelin.core.formula.call(null,((function (s,indexed,by_index,map__36348,map__36348__$1,value,choices,attrs__$1,vec__36345,attrs,_){
return (function (value__$1){
return new cljs.core.Keyword("weathergen.ui.common","index","weathergen.ui.common/index",-813327910).cljs$core$IFn$_invoke$arity$1(cljs.core.first.call(null,cljs.core.filter.call(null,((function (s,indexed,by_index,map__36348,map__36348__$1,value,choices,attrs__$1,vec__36345,attrs,_){
return (function (p1__36311_SHARP_){
return cljs.core._EQ_.call(null,value__$1,new cljs.core.Keyword(null,"value","value",305978217).cljs$core$IFn$_invoke$arity$1(p1__36311_SHARP_));
});})(s,indexed,by_index,map__36348,map__36348__$1,value,choices,attrs__$1,vec__36345,attrs,_))
,cljs.core.vals.call(null,indexed))));
});})(s,indexed,by_index,map__36348,map__36348__$1,value,choices,attrs__$1,vec__36345,attrs,_))
).call(null,value),new cljs.core.Keyword(null,"change","change",-1163046502),((function (s,indexed,by_index,map__36348,map__36348__$1,value,choices,attrs__$1,vec__36345,attrs,_){
return (function (v){
return cljs.core.reset_BANG_.call(null,value,new cljs.core.Keyword(null,"value","value",305978217).cljs$core$IFn$_invoke$arity$1(by_index.call(null,cljs.core.deref.call(null,v))));
});})(s,indexed,by_index,map__36348,map__36348__$1,value,choices,attrs__$1,vec__36345,attrs,_))
),(function (){var iter__24010__auto__ = ((function (s,indexed,by_index,map__36348,map__36348__$1,value,choices,attrs__$1,vec__36345,attrs,_){
return (function weathergen$ui$common$dropdown_$_iter__36350(s__36351){
return (new cljs.core.LazySeq(null,((function (s,indexed,by_index,map__36348,map__36348__$1,value,choices,attrs__$1,vec__36345,attrs,_){
return (function (){
var s__36351__$1 = s__36351;
while(true){
var temp__5278__auto__ = cljs.core.seq.call(null,s__36351__$1);
if(temp__5278__auto__){
var s__36351__$2 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,s__36351__$2)){
var c__24008__auto__ = cljs.core.chunk_first.call(null,s__36351__$2);
var size__24009__auto__ = cljs.core.count.call(null,c__24008__auto__);
var b__36353 = cljs.core.chunk_buffer.call(null,size__24009__auto__);
if((function (){var i__36352 = (0);
while(true){
if((i__36352 < size__24009__auto__)){
var vec__36366 = cljs.core._nth.call(null,c__24008__auto__,i__36352);
var index = cljs.core.nth.call(null,vec__36366,(0),null);
var choice = cljs.core.nth.call(null,vec__36366,(1),null);
cljs.core.chunk_append.call(null,b__36353,hoplon.core.option.call(null,new cljs.core.Keyword(null,"value","value",305978217),index,new cljs.core.Keyword(null,"selected","selected",574897764),javelin.core.formula.call(null,((function (i__36352,vec__36366,index,choice,c__24008__auto__,size__24009__auto__,b__36353,s__36351__$2,temp__5278__auto__,s,indexed,by_index,map__36348,map__36348__$1,value,choices,attrs__$1,vec__36345,attrs,_){
return (function (G__36371,G__36369,G__36370){
return G__36369.call(null,G__36370,new cljs.core.Keyword(null,"value","value",305978217).cljs$core$IFn$_invoke$arity$1(G__36371));
});})(i__36352,vec__36366,index,choice,c__24008__auto__,size__24009__auto__,b__36353,s__36351__$2,temp__5278__auto__,s,indexed,by_index,map__36348,map__36348__$1,value,choices,attrs__$1,vec__36345,attrs,_))
).call(null,choice,cljs.core._EQ_,value),new cljs.core.Keyword(null,"label","label",1718410804).cljs$core$IFn$_invoke$arity$1(choice)));

var G__36378 = (i__36352 + (1));
i__36352 = G__36378;
continue;
} else {
return true;
}
break;
}
})()){
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__36353),weathergen$ui$common$dropdown_$_iter__36350.call(null,cljs.core.chunk_rest.call(null,s__36351__$2)));
} else {
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__36353),null);
}
} else {
var vec__36372 = cljs.core.first.call(null,s__36351__$2);
var index = cljs.core.nth.call(null,vec__36372,(0),null);
var choice = cljs.core.nth.call(null,vec__36372,(1),null);
return cljs.core.cons.call(null,hoplon.core.option.call(null,new cljs.core.Keyword(null,"value","value",305978217),index,new cljs.core.Keyword(null,"selected","selected",574897764),javelin.core.formula.call(null,((function (vec__36372,index,choice,s__36351__$2,temp__5278__auto__,s,indexed,by_index,map__36348,map__36348__$1,value,choices,attrs__$1,vec__36345,attrs,_){
return (function (G__36377,G__36375,G__36376){
return G__36375.call(null,G__36376,new cljs.core.Keyword(null,"value","value",305978217).cljs$core$IFn$_invoke$arity$1(G__36377));
});})(vec__36372,index,choice,s__36351__$2,temp__5278__auto__,s,indexed,by_index,map__36348,map__36348__$1,value,choices,attrs__$1,vec__36345,attrs,_))
).call(null,choice,cljs.core._EQ_,value),new cljs.core.Keyword(null,"label","label",1718410804).cljs$core$IFn$_invoke$arity$1(choice)),weathergen$ui$common$dropdown_$_iter__36350.call(null,cljs.core.rest.call(null,s__36351__$2)));
}
} else {
return null;
}
break;
}
});})(s,indexed,by_index,map__36348,map__36348__$1,value,choices,attrs__$1,vec__36345,attrs,_))
,null,null));
});})(s,indexed,by_index,map__36348,map__36348__$1,value,choices,attrs__$1,vec__36345,attrs,_))
;
return iter__24010__auto__.call(null,indexed);
})());

return s;
};
var weathergen$ui$common$dropdown = function (var_args){
var args__29571__auto__ = null;
if (arguments.length > 0) {
var G__36379__i = 0, G__36379__a = new Array(arguments.length -  0);
while (G__36379__i < G__36379__a.length) {G__36379__a[G__36379__i] = arguments[G__36379__i + 0]; ++G__36379__i;}
  args__29571__auto__ = new cljs.core.IndexedSeq(G__36379__a,0,null);
} 
return weathergen$ui$common$dropdown__delegate.call(this,args__29571__auto__);};
weathergen$ui$common$dropdown.cljs$lang$maxFixedArity = 0;
weathergen$ui$common$dropdown.cljs$lang$applyTo = (function (arglist__36380){
var args__29571__auto__ = cljs.core.seq(arglist__36380);
return weathergen$ui$common$dropdown__delegate(args__29571__auto__);
});
weathergen$ui$common$dropdown.cljs$core$IFn$_invoke$arity$variadic = weathergen$ui$common$dropdown__delegate;
return weathergen$ui$common$dropdown;
})()
;
/**
 * Returns a cell backed by local storage under `key` (a namespaced
 *   key), where, if the `default` contents change, a new cell will be
 *   allocated. This allows changing defaults in the code to overwrite
 *   any stored copies.
 */
weathergen.ui.common.versioned_local_storage = (function weathergen$ui$common$versioned_local_storage(key,default$){
return hoplon.storage_atom.local_storage.call(null,javelin.core.cell.call(null,default$),[cljs.core.str.cljs$core$IFn$_invoke$arity$1(key),cljs.core.str.cljs$core$IFn$_invoke$arity$1("-"),cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.hash.call(null,default$))].join(''));
});
/**
 * Returns an SVG scale string.
 */
weathergen.ui.common.svg_scale = (function weathergen$ui$common$svg_scale(var_args){
var args36381 = [];
var len__24369__auto___36384 = arguments.length;
var i__24370__auto___36385 = (0);
while(true){
if((i__24370__auto___36385 < len__24369__auto___36384)){
args36381.push((arguments[i__24370__auto___36385]));

var G__36386 = (i__24370__auto___36385 + (1));
i__24370__auto___36385 = G__36386;
continue;
} else {
}
break;
}

var G__36383 = args36381.length;
switch (G__36383) {
case 1:
return weathergen.ui.common.svg_scale.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));

break;
case 2:
return weathergen.ui.common.svg_scale.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));

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

}
});

weathergen.ui.common.svg_scale.cljs$core$IFn$_invoke$arity$1 = (function (s){
return goog.string.format("scale(%f)",s);
});

weathergen.ui.common.svg_scale.cljs$core$IFn$_invoke$arity$2 = (function (x,y){
return goog.string.format("scale(%f,%f)",x,y);
});

weathergen.ui.common.svg_scale.cljs$lang$maxFixedArity = 2;

/**
 * Returns an SVG translate string.
 */
weathergen.ui.common.svg_translate = (function weathergen$ui$common$svg_translate(x,y){
return goog.string.format("translate(%f,%f)",x,y);
});
/**
 * Returns an SVG rotate string.
 */
weathergen.ui.common.svg_rotate = (function weathergen$ui$common$svg_rotate(deg){
return goog.string.format("rotate(%f)",deg);
});
/**
 * Combines xforms into a single SVG transformation string
 */
weathergen.ui.common.svg_xform_combine = (function weathergen$ui$common$svg_xform_combine(var_args){
var args__24376__auto__ = [];
var len__24369__auto___36389 = arguments.length;
var i__24370__auto___36390 = (0);
while(true){
if((i__24370__auto___36390 < len__24369__auto___36389)){
args__24376__auto__.push((arguments[i__24370__auto___36390]));

var G__36391 = (i__24370__auto___36390 + (1));
i__24370__auto___36390 = G__36391;
continue;
} else {
}
break;
}

var argseq__24377__auto__ = ((((0) < args__24376__auto__.length))?(new cljs.core.IndexedSeq(args__24376__auto__.slice((0)),(0),null)):null);
return weathergen.ui.common.svg_xform_combine.cljs$core$IFn$_invoke$arity$variadic(argseq__24377__auto__);
});

weathergen.ui.common.svg_xform_combine.cljs$core$IFn$_invoke$arity$variadic = (function (xforms){
return clojure.string.join.call(null," ",xforms);
});

weathergen.ui.common.svg_xform_combine.cljs$lang$maxFixedArity = (0);

weathergen.ui.common.svg_xform_combine.cljs$lang$applyTo = (function (seq36388){
return weathergen.ui.common.svg_xform_combine.cljs$core$IFn$_invoke$arity$variadic(cljs.core.seq.call(null,seq36388));
});

var interval_value_36392 = 0.45;
var interval_36393 = [cljs.core.str.cljs$core$IFn$_invoke$arity$1(interval_value_36392),cljs.core.str.cljs$core$IFn$_invoke$arity$1("s")].join('');
weathergen.ui.common.register_styles_BANG_.call(null,new cljs.core.Keyword("weathergen.ui.common","animations","weathergen.ui.common/animations",338673555),new cljs.core.PersistentVector(null, 6, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [garden.stylesheet.at_keyframes.call(null,weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.common","pulse-animation","weathergen.ui.common/pulse-animation",-696492175)),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"from","from",1815293044),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"opacity","opacity",397153780),(1)], null)], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"to","to",192099007),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"opacity","opacity",397153780),(0)], null)], null))], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [weathergen.ui.common.class_selector_for.call(null,new cljs.core.Keyword("weathergen.ui.common","pulse","weathergen.ui.common/pulse",-535065247)),new cljs.core.PersistentArrayMap(null, 6, [new cljs.core.Keyword(null,"animation-duration","animation-duration",-1261077706),interval_36393,new cljs.core.Keyword(null,"animation-name","animation-name",-302195330),weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.common","pulse-animation","weathergen.ui.common/pulse-animation",-696492175)),new cljs.core.Keyword(null,"animation-iteration-count","animation-iteration-count",-1410888227),"infinite",new cljs.core.Keyword(null,"animation-timing-function","animation-timing-function",-1186881521),"ease-in-out",new cljs.core.Keyword(null,"animation-direction","animation-direction",-362912441),"alternate",new cljs.core.Keyword(null,"animation-delay","animation-delay",-488570176),interval_36393], null)], null),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [garden.stylesheet.at_keyframes.call(null,weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.common","collapse-animation","weathergen.ui.common/collapse-animation",-506320172)),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"from","from",1815293044),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"transform","transform",1381301764),weathergen.ui.common.svg_scale.call(null,(1)),new cljs.core.Keyword(null,"stroke-dashoffset","stroke-dashoffset",-782320340),(0)], null)], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"to","to",192099007),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"transform","transform",1381301764),weathergen.ui.common.svg_scale.call(null,0.02),new cljs.core.Keyword(null,"stroke-dashoffset","stroke-dashoffset",-782320340),(50)], null)], null))], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [weathergen.ui.common.class_selector_for.call(null,new cljs.core.Keyword("weathergen.ui.common","collapse","weathergen.ui.common/collapse",-901062267)),new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,"animation-duration","animation-duration",-1261077706),interval_36393,new cljs.core.Keyword(null,"animation-name","animation-name",-302195330),weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.common","collapse-animation","weathergen.ui.common/collapse-animation",-506320172)),new cljs.core.Keyword(null,"animation-iteration-count","animation-iteration-count",-1410888227),(1),new cljs.core.Keyword(null,"animation-timing-function","animation-timing-function",-1186881521),"ease-out",new cljs.core.Keyword(null,"animation-direction","animation-direction",-362912441),"normal"], null)], null),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [garden.stylesheet.at_keyframes.call(null,weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.common","delayed-fade-out-animation","weathergen.ui.common/delayed-fade-out-animation",-813416372)),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"from","from",1815293044),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"opacity","opacity",397153780),0.35], null)], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, ["80%",new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"opacity","opacity",397153780),0.35], null)], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"to","to",192099007),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"opacity","opacity",397153780),(0)], null)], null))], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [weathergen.ui.common.class_selector_for.call(null,new cljs.core.Keyword("weathergen.ui.common","delayed-fade-out","weathergen.ui.common/delayed-fade-out",1307931935)),new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,"animation-duration","animation-duration",-1261077706),[cljs.core.str.cljs$core$IFn$_invoke$arity$1((interval_value_36392 / 0.8)),cljs.core.str.cljs$core$IFn$_invoke$arity$1("s")].join(''),new cljs.core.Keyword(null,"animation-name","animation-name",-302195330),weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.common","delayed-fade-out-animation","weathergen.ui.common/delayed-fade-out-animation",-813416372)),new cljs.core.Keyword(null,"animation-iteration-count","animation-iteration-count",-1410888227),(1),new cljs.core.Keyword(null,"animation-timing-function","animation-timing-function",-1186881521),"ease-out",new cljs.core.Keyword(null,"animation-direction","animation-direction",-362912441),"normal"], null)], null)], null));
weathergen.ui.common.pulse_class = weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.common","pulse","weathergen.ui.common/pulse",-535065247));
weathergen.ui.common.collapse_class = weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.common","collapse","weathergen.ui.common/collapse",-901062267));
weathergen.ui.common.delayed_fade_out_class = weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.common","delayed-fade-out","weathergen.ui.common/delayed-fade-out",1307931935));
/**
 * Renders a heading - white text on a black background
 */
weathergen.ui.common.heading = (function weathergen$ui$common$heading(var_args){
var args36394 = [];
var len__24369__auto___36400 = arguments.length;
var i__24370__auto___36401 = (0);
while(true){
if((i__24370__auto___36401 < len__24369__auto___36400)){
args36394.push((arguments[i__24370__auto___36401]));

var G__36402 = (i__24370__auto___36401 + (1));
i__24370__auto___36401 = G__36402;
continue;
} else {
}
break;
}

var G__36396 = args36394.length;
switch (G__36396) {
case 1:
return weathergen.ui.common.heading.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));

break;
case 2:
return weathergen.ui.common.heading.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));

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

}
});

weathergen.ui.common.heading.cljs$core$IFn$_invoke$arity$1 = (function (content){
return weathergen.ui.common.heading.call(null,cljs.core.PersistentArrayMap.EMPTY,content);
});

weathergen.ui.common.heading.cljs$core$IFn$_invoke$arity$2 = (function (p__36397,content){
var map__36398 = p__36397;
var map__36398__$1 = ((((!((map__36398 == null)))?((((map__36398.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__36398.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__36398):map__36398);
var margin_top = cljs.core.get.call(null,map__36398__$1,new cljs.core.Keyword(null,"margin-top","margin-top",392161226));
return hoplon.core.div.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,"color","color",1011675173),"white",new cljs.core.Keyword(null,"background","background",-863952629),"black",new cljs.core.Keyword(null,"margin-top","margin-top",392161226),weathergen.ui.common.px.call(null,(function (){var or__23148__auto__ = margin_top;
if(cljs.core.truth_(or__23148__auto__)){
return or__23148__auto__;
} else {
return (15);
}
})()),new cljs.core.Keyword(null,"margin-bottom","margin-bottom",388334941),weathergen.ui.common.px.call(null,(5)),new cljs.core.Keyword(null,"padding","padding",1660304693),weathergen.ui.common.px.call(null,(2))], null),content);
});

weathergen.ui.common.heading.cljs$lang$maxFixedArity = 2;

/**
 * Returns a lens over a `get-in` style path `p` into cell `c`.
 */
weathergen.ui.common.path_lens = (function weathergen$ui$common$path_lens(c,p){
return javelin.core.lens.call(null,javelin.core.formula.call(null,(function (c__$1){
return cljs.core.get_in.call(null,c__$1,p);
})).call(null,c),(function (v){
return cljs.core.swap_BANG_.call(null,c,cljs.core.assoc_in,p,v);
}));
});
