// Compiled by ClojureScript 1.10.520 {}
goog.provide('weathergen.ui.buttons');
goog.require('cljs.core');
goog.require('hoplon.core');
goog.require('javelin.core');
goog.require('rum.core');
goog.require('weathergen.ui.common');
goog.require('taoensso.timbre');
weathergen.ui.buttons.image_button_style = (function weathergen$ui$buttons$image_button_style(pressed_QMARK_){
return new cljs.core.PersistentArrayMap(null, 7, [new cljs.core.Keyword(null,"border-style","border-style",-485574304),(cljs.core.truth_(pressed_QMARK_)?"inset":"outset"),new cljs.core.Keyword(null,"border-color","border-color",-2059162761),"#ddd",new cljs.core.Keyword(null,"border-radius","border-radius",419594011),"6px",new cljs.core.Keyword(null,"padding","padding",1660304693),"2px",new cljs.core.Keyword(null,"background","background",-863952629),(cljs.core.truth_(pressed_QMARK_)?"lightgrey":"white"),new cljs.core.Keyword(null,"border-width","border-width",-1512605390),"2px",new cljs.core.Keyword(null,"vertical-align","vertical-align",651007333),"middle"], null);
});
/**
 * A button displaying an image rather than text. Can take a
 *   `latched?` attribute, which, if a cell evaluating to true, locks the
 *   button in the pressed state.
 * @param {...*} var_args
 */
weathergen.ui.buttons.image_button = (function() { 
var weathergen$ui$buttons$image_button__delegate = function (args__30233__auto__){
var vec__34744 = hoplon.core.parse_args.call(null,args__30233__auto__);
var attrs = cljs.core.nth.call(null,vec__34744,(0),null);
var map__34747 = attrs;
var map__34747__$1 = (((((!((map__34747 == null))))?(((((map__34747.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__34747.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__34747):map__34747);
var css = cljs.core.get.call(null,map__34747__$1,new cljs.core.Keyword(null,"css","css",1135045163));
var latched_QMARK_ = cljs.core.get.call(null,map__34747__$1,new cljs.core.Keyword(null,"latched?","latched?",2124907793));
var attrs__$1 = cljs.core.dissoc.call(null,attrs,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.Keyword(null,"latched?","latched?",2124907793));
var down = javelin.core.cell.call(null,false);
return hoplon.core.img.call(null,new cljs.core.Keyword(null,"css","css",1135045163),javelin.core.formula.call(null,((function (down,map__34747,map__34747__$1,css,latched_QMARK_,attrs__$1,vec__34744,attrs){
return (function (latched_QMARK___$1,down__$1){
return cljs.core.merge.call(null,weathergen.ui.buttons.image_button_style.call(null,(function (){var or__4131__auto__ = latched_QMARK___$1;
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return down__$1;
}
})()),css);
});})(down,map__34747,map__34747__$1,css,latched_QMARK_,attrs__$1,vec__34744,attrs))
).call(null,latched_QMARK_,down),new cljs.core.Keyword(null,"mousedown","mousedown",1391242074),((function (down,map__34747,map__34747__$1,css,latched_QMARK_,attrs__$1,vec__34744,attrs){
return (function (e){
var up_34749 = ((function (down,map__34747,map__34747__$1,css,latched_QMARK_,attrs__$1,vec__34744,attrs){
return (function weathergen$ui$buttons$image_button_$_up_fn(e__$1){
document.removeEventListener("mouseup",weathergen$ui$buttons$image_button_$_up_fn);

return cljs.core.reset_BANG_.call(null,down,false);
});})(down,map__34747,map__34747__$1,css,latched_QMARK_,attrs__$1,vec__34744,attrs))
;
document.addEventListener("mouseup",up_34749);

return cljs.core.reset_BANG_.call(null,down,true);
});})(down,map__34747,map__34747__$1,css,latched_QMARK_,attrs__$1,vec__34744,attrs))
,new cljs.core.Keyword(null,"dragstart","dragstart",955864218),cljs.core.constantly.call(null,false),attrs__$1);
};
var weathergen$ui$buttons$image_button = function (var_args){
var args__30233__auto__ = null;
if (arguments.length > 0) {
var G__34750__i = 0, G__34750__a = new Array(arguments.length -  0);
while (G__34750__i < G__34750__a.length) {G__34750__a[G__34750__i] = arguments[G__34750__i + 0]; ++G__34750__i;}
  args__30233__auto__ = new cljs.core.IndexedSeq(G__34750__a,0,null);
} 
return weathergen$ui$buttons$image_button__delegate.call(this,args__30233__auto__);};
weathergen$ui$buttons$image_button.cljs$lang$maxFixedArity = 0;
weathergen$ui$buttons$image_button.cljs$lang$applyTo = (function (arglist__34751){
var args__30233__auto__ = cljs.core.seq(arglist__34751);
return weathergen$ui$buttons$image_button__delegate(args__30233__auto__);
});
weathergen$ui$buttons$image_button.cljs$core$IFn$_invoke$arity$variadic = weathergen$ui$buttons$image_button__delegate;
return weathergen$ui$buttons$image_button;
})()
;
weathergen.ui.buttons.RImageButton = rum.core.build_defcs.call(null,(function (state,attrs){
return sablono.interpreter.interpret.call(null,(function (){var map__34752 = attrs;
var map__34752__$1 = (((((!((map__34752 == null))))?(((((map__34752.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__34752.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__34752):map__34752);
var style = cljs.core.get.call(null,map__34752__$1,new cljs.core.Keyword(null,"style","style",-496642736));
var latched_QMARK_ = cljs.core.get.call(null,map__34752__$1,new cljs.core.Keyword(null,"latched?","latched?",2124907793));
var attrs__$1 = cljs.core.dissoc.call(null,attrs,new cljs.core.Keyword(null,"latched?","latched?",2124907793),new cljs.core.Keyword(null,"style","style",-496642736));
var down_QMARK_ = new cljs.core.Keyword("weathergen.ui.buttons","down?","weathergen.ui.buttons/down?",-1600343330).cljs$core$IFn$_invoke$arity$1(state);
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"img","img",1442687358),cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"style","style",-496642736),cljs.core.merge.call(null,weathergen.ui.buttons.image_button_style.call(null,(function (){var or__4131__auto__ = latched_QMARK_;
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return cljs.core.deref.call(null,down_QMARK_);
}
})()),style),new cljs.core.Keyword(null,"on-mouse-down","on-mouse-down",1147755470),((function (down_QMARK_,map__34752,map__34752__$1,style,latched_QMARK_,attrs__$1){
return (function (e){
var up_34754 = ((function (down_QMARK_,map__34752,map__34752__$1,style,latched_QMARK_,attrs__$1){
return (function weathergen$ui$buttons$up_fn(e__$1){
document.removeEventListener("mouseup",weathergen$ui$buttons$up_fn);

return cljs.core.reset_BANG_.call(null,down_QMARK_,false);
});})(down_QMARK_,map__34752,map__34752__$1,style,latched_QMARK_,attrs__$1))
;
document.addEventListener("mouseup",up_34754);

return cljs.core.reset_BANG_.call(null,down_QMARK_,true);
});})(down_QMARK_,map__34752,map__34752__$1,style,latched_QMARK_,attrs__$1))
,new cljs.core.Keyword(null,"on-drag-start","on-drag-start",-47712205),cljs.core.constantly.call(null,false)], null),attrs__$1)], null);
})());
}),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [rum.core.local.call(null,false,new cljs.core.Keyword("weathergen.ui.buttons","down?","weathergen.ui.buttons/down?",-1600343330))], null),"RImageButton");
/**
 * Like image-button, but React-based.
 */
weathergen.ui.buttons.rimage_button = (function weathergen$ui$buttons$rimage_button(attrs){
var map__34755 = attrs;
var map__34755__$1 = (((((!((map__34755 == null))))?(((((map__34755.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__34755.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__34755):map__34755);
var latched_QMARK_ = cljs.core.get.call(null,map__34755__$1,new cljs.core.Keyword(null,"latched?","latched?",2124907793));
var parent = hoplon.core.div.call(null);
hoplon.core.do_watch.call(null,latched_QMARK_,((function (parent,map__34755,map__34755__$1,latched_QMARK_){
return (function (_,latched_QMARK___$1){
return rum.core.mount.call(null,weathergen.ui.buttons.RImageButton.call(null,cljs.core.assoc.call(null,attrs,new cljs.core.Keyword(null,"latched?","latched?",2124907793),latched_QMARK___$1)),parent);
});})(parent,map__34755,map__34755__$1,latched_QMARK_))
);

return parent;
});
weathergen.ui.common.register_class_BANG_.call(null,new cljs.core.Keyword("weathergen.ui.buttons","div-button","weathergen.ui.buttons/div-button",-1385258890),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.PersistentHashMap.fromArrays([new cljs.core.Keyword(null,"border-style","border-style",-485574304),new cljs.core.Keyword(null,"color","color",1011675173),new cljs.core.Keyword(null,"text-align","text-align",1786091845),new cljs.core.Keyword(null,"font-size","font-size",-1847940346),new cljs.core.Keyword(null,"background","background",-863952629),new cljs.core.Keyword(null,"cursor","cursor",1011937484),new cljs.core.Keyword(null,"border-width","border-width",-1512605390),new cljs.core.Keyword(null,"padding","padding",1660304693),new cljs.core.Keyword(null,"border-color","border-color",-2059162761),new cljs.core.Keyword(null,"text-decoration","text-decoration",1836813207),new cljs.core.Keyword(null,"display","display",242065432),new cljs.core.Keyword(null,"border-radius","border-radius",419594011),new cljs.core.Keyword(null,"font-family","font-family",-667419874),new cljs.core.Keyword(null,"margin","margin",-995903681)],["solid","black","center","72%","linear-gradient(white, white 75%, #ededed 100%)","pointer","0.5px","3px","#d0d0d0","none","inline-block","4px","Lucida Grande, Lucida Sans Unicode, Tahoma, sans-serif","2px"]),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"&:active","&:active",-1687810105),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"background","background",-863952629),"linear-gradient(#c0c0c0, #f0f0f0)"], null)], null)], null));
weathergen.ui.common.register_class_BANG_.call(null,new cljs.core.Keyword("weathergen.ui.buttons","latched-div-button","weathergen.ui.buttons/latched-div-button",103418273),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"background","background",-863952629),"linear-gradient(#c0c0c0, #f0f0f0)"], null)], null));
weathergen.ui.common.register_class_BANG_.call(null,new cljs.core.Keyword("weathergen.ui.buttons","disabled-button","weathergen.ui.buttons/disabled-button",1352747181),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"pointer-events","pointer-events",-1053858853),"none",new cljs.core.Keyword(null,"color","color",1011675173),"grey",new cljs.core.Keyword(null,"cursor","cursor",1011937484),"default"], null)], null));
/**
 * Renders a plain button, but using an anchor tag to better enable
 *   styling. Can take a `latched?` attribute, which, if a cell
 *   evaluating to true, locks the button in the pressed state. Can take
 *   a `disabled?` attribute, which, if a cell evalating to true,
 *   disables the button.
 * @param {...*} var_args
 */
weathergen.ui.buttons.a_button = (function() { 
var weathergen$ui$buttons$a_button__delegate = function (args__30233__auto__){
var vec__34757 = hoplon.core.parse_args.call(null,args__30233__auto__);
var attrs = cljs.core.nth.call(null,vec__34757,(0),null);
var content = cljs.core.nth.call(null,vec__34757,(1),null);
var map__34760 = attrs;
var map__34760__$1 = (((((!((map__34760 == null))))?(((((map__34760.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__34760.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__34760):map__34760);
var disabled_QMARK_ = cljs.core.get.call(null,map__34760__$1,new cljs.core.Keyword(null,"disabled?","disabled?",-1523234181));
var latched_QMARK_ = cljs.core.get.call(null,map__34760__$1,new cljs.core.Keyword(null,"latched?","latched?",2124907793));
var attrs__$1 = cljs.core.dissoc.call(null,attrs,new cljs.core.Keyword(null,"latched?","latched?",2124907793),new cljs.core.Keyword(null,"disabled?","disabled?",-1523234181));
var down = javelin.core.cell.call(null,false);
return hoplon.core.a.call(null,cljs.core.merge.call(null,attrs__$1,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"class","class",-2030961996),javelin.core.formula.call(null,((function (down,map__34760,map__34760__$1,disabled_QMARK_,latched_QMARK_,attrs__$1,vec__34757,attrs,content){
return (function (latched_QMARK___$1,down__$1,disabled_QMARK___$1){
return cljs.core.PersistentArrayMap.createAsIfByAssoc([weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.buttons","div-button","weathergen.ui.buttons/div-button",-1385258890)),true,weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.buttons","latched-div-button","weathergen.ui.buttons/latched-div-button",103418273)),(function (){var or__4131__auto__ = latched_QMARK___$1;
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return down__$1;
}
})(),weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.buttons","disabled-button","weathergen.ui.buttons/disabled-button",1352747181)),disabled_QMARK___$1]);
});})(down,map__34760,map__34760__$1,disabled_QMARK_,latched_QMARK_,attrs__$1,vec__34757,attrs,content))
).call(null,latched_QMARK_,down,disabled_QMARK_)], null)),content);
};
var weathergen$ui$buttons$a_button = function (var_args){
var args__30233__auto__ = null;
if (arguments.length > 0) {
var G__34762__i = 0, G__34762__a = new Array(arguments.length -  0);
while (G__34762__i < G__34762__a.length) {G__34762__a[G__34762__i] = arguments[G__34762__i + 0]; ++G__34762__i;}
  args__30233__auto__ = new cljs.core.IndexedSeq(G__34762__a,0,null);
} 
return weathergen$ui$buttons$a_button__delegate.call(this,args__30233__auto__);};
weathergen$ui$buttons$a_button.cljs$lang$maxFixedArity = 0;
weathergen$ui$buttons$a_button.cljs$lang$applyTo = (function (arglist__34763){
var args__30233__auto__ = cljs.core.seq(arglist__34763);
return weathergen$ui$buttons$a_button__delegate(args__30233__auto__);
});
weathergen$ui$buttons$a_button.cljs$core$IFn$_invoke$arity$variadic = weathergen$ui$buttons$a_button__delegate;
return weathergen$ui$buttons$a_button;
})()
;
weathergen.ui.buttons.RAButton = rum.core.build_defcs.call(null,(function (state,attrs,content){
return sablono.interpreter.interpret.call(null,(function (){var map__34764 = attrs;
var map__34764__$1 = (((((!((map__34764 == null))))?(((((map__34764.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__34764.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__34764):map__34764);
var disabled_QMARK_ = cljs.core.get.call(null,map__34764__$1,new cljs.core.Keyword(null,"disabled?","disabled?",-1523234181));
var latched_QMARK_ = cljs.core.get.call(null,map__34764__$1,new cljs.core.Keyword(null,"latched?","latched?",2124907793));
var attrs__$1 = cljs.core.dissoc.call(null,attrs,new cljs.core.Keyword(null,"latched?","latched?",2124907793),new cljs.core.Keyword(null,"disabled?","disabled?",-1523234181));
var down_QMARK_ = new cljs.core.Keyword("weathergen.ui.buttons","down?","weathergen.ui.buttons/down?",-1600343330).cljs$core$IFn$_invoke$arity$1(state);
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"a","a",-2123407586),cljs.core.merge.call(null,attrs__$1,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"class","class",-2030961996),weathergen.ui.common.classes.call(null,cljs.core.PersistentArrayMap.createAsIfByAssoc([weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.buttons","div-button","weathergen.ui.buttons/div-button",-1385258890)),true,weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.buttons","latched-div-button","weathergen.ui.buttons/latched-div-button",103418273)),(function (){var or__4131__auto__ = latched_QMARK_;
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return down_QMARK_;
}
})(),weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.buttons","disabled-button","weathergen.ui.buttons/disabled-button",1352747181)),disabled_QMARK_]))], null)),content], null);
})());
}),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [rum.core.local.call(null,false,new cljs.core.Keyword("weathergen.ui.buttons","down?","weathergen.ui.buttons/down?",-1600343330))], null),"RAButton");
/**
 * Like a-button, but React-based.
 */
weathergen.ui.buttons.ra_button = (function weathergen$ui$buttons$ra_button(attrs,content){
var map__34766 = attrs;
var map__34766__$1 = (((((!((map__34766 == null))))?(((((map__34766.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__34766.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__34766):map__34766);
var latched_QMARK_ = cljs.core.get.call(null,map__34766__$1,new cljs.core.Keyword(null,"latched?","latched?",2124907793));
var disabled_QMARK_ = cljs.core.get.call(null,map__34766__$1,new cljs.core.Keyword(null,"disabled?","disabled?",-1523234181));
var parent = hoplon.core.div.call(null);
hoplon.core.do_watch.call(null,javelin.core.formula.call(null,((function (parent,map__34766,map__34766__$1,latched_QMARK_,disabled_QMARK_){
return (function (latched_QMARK___$1,disabled_QMARK___$1){
return null;
});})(parent,map__34766,map__34766__$1,latched_QMARK_,disabled_QMARK_))
).call(null,latched_QMARK_,disabled_QMARK_),((function (parent,map__34766,map__34766__$1,latched_QMARK_,disabled_QMARK_){
return (function (_,p__34768){
var vec__34769 = p__34768;
var latched_QMARK___$1 = cljs.core.nth.call(null,vec__34769,(0),null);
var disabled_QMARK___$1 = cljs.core.nth.call(null,vec__34769,(1),null);
return rum.core.mount.call(null,weathergen.ui.buttons.RAButton.call(null,cljs.core.assoc.call(null,attrs,new cljs.core.Keyword(null,"latched?","latched?",2124907793),latched_QMARK___$1,new cljs.core.Keyword(null,"disabled?","disabled?",-1523234181),disabled_QMARK___$1),content),parent);
});})(parent,map__34766,map__34766__$1,latched_QMARK_,disabled_QMARK_))
);

return parent;
});
