// Compiled by ClojureScript 1.10.520 {}
goog.provide('weathergen.ui.select');
goog.require('cljs.core');
goog.require('clojure.string');
goog.require('garden.core');
goog.require('garden.selectors');
goog.require('hoplon.core');
goog.require('hoplon.svg');
goog.require('javelin.core');
goog.require('taoensso.timbre');
goog.require('weathergen.help');
goog.require('weathergen.ui.buttons');
goog.require('weathergen.ui.common');
weathergen.ui.common.register_class_BANG_.call(null,new cljs.core.Keyword("weathergen.ui.select","hidden","weathergen.ui.select/hidden",-252585472),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"display","display",242065432),"none"], null)], null));
/**
 * Like select2, but artisinal and bespoke.
 * 
 * :data - A cell containing a seq of values.
 * :width - px width
 * :value - A cell. The currently selected value, or `nil` if no selection.
 * :key-fn - Function of choice value returning immutable unique ID.
 * :search-fn - Function from value to text it should match when searching.
 * :formatter - Function from cell of value to UI for that item.
 * :change - Function called with selected value when value changes.
 * :highlight - Function called with highlighted value when highlight changes.
 * :max-dropdown-height - (Optional) Max height of dropdown
 * @param {...*} var_args
 */
weathergen.ui.select.select3 = (function() { 
var weathergen$ui$select$select3__delegate = function (args__30233__auto__){
var vec__35663 = hoplon.core.parse_args.call(null,args__30233__auto__);
var attrs = cljs.core.nth.call(null,vec__35663,(0),null);
var _ = cljs.core.nth.call(null,vec__35663,(1),null);
var map__35666 = attrs;
var map__35666__$1 = (((((!((map__35666 == null))))?(((((map__35666.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__35666.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__35666):map__35666);
var max_dropdown_height = cljs.core.get.call(null,map__35666__$1,new cljs.core.Keyword(null,"max-dropdown-height","max-dropdown-height",1744906266));
var change = cljs.core.get.call(null,map__35666__$1,new cljs.core.Keyword(null,"change","change",-1163046502));
var data = cljs.core.get.call(null,map__35666__$1,new cljs.core.Keyword(null,"data","data",-232669377));
var placeholder = cljs.core.get.call(null,map__35666__$1,new cljs.core.Keyword(null,"placeholder","placeholder",-104873083));
var search_fn = cljs.core.get.call(null,map__35666__$1,new cljs.core.Keyword(null,"search-fn","search-fn",-646637945));
var highlight = cljs.core.get.call(null,map__35666__$1,new cljs.core.Keyword(null,"highlight","highlight",-800930873));
var formatter = cljs.core.get.call(null,map__35666__$1,new cljs.core.Keyword(null,"formatter","formatter",-483008823));
var value = cljs.core.get.call(null,map__35666__$1,new cljs.core.Keyword(null,"value","value",305978217));
var width = cljs.core.get.call(null,map__35666__$1,new cljs.core.Keyword(null,"width","width",-384071477));
var key_fn = cljs.core.get.call(null,map__35666__$1,new cljs.core.Keyword(null,"key-fn","key-fn",-636154479));
var attrs__$1 = cljs.core.dissoc.call(null,attrs,new cljs.core.Keyword(null,"data","data",-232669377),new cljs.core.Keyword(null,"width","width",-384071477),new cljs.core.Keyword(null,"value","value",305978217),new cljs.core.Keyword(null,"key-fn","key-fn",-636154479),new cljs.core.Keyword(null,"search-fn","search-fn",-646637945),new cljs.core.Keyword(null,"formatter","formatter",-483008823),new cljs.core.Keyword(null,"highlight","highlight",-800930873),new cljs.core.Keyword(null,"change","change",-1163046502),new cljs.core.Keyword(null,"max-dropdown-height","max-dropdown-height",1744906266),new cljs.core.Keyword(null,"placeholder","placeholder",-104873083));
if(cljs.core.truth_(search_fn)){
} else {
throw (new Error(["Assert failed: ","search-fn is required","\n","search-fn"].join('')));
}

if(cljs.core.truth_(key_fn)){
} else {
throw (new Error(["Assert failed: ","key-fn is required","\n","key-fn"].join('')));
}

if(cljs.core.truth_(formatter)){
} else {
throw (new Error(["Assert failed: ","formatter is required","\n","formatter"].join('')));
}

var highlighted = javelin.core.cell.call(null,null);
var search_text = javelin.core.cell.call(null,null);
var open_QMARK_ = javelin.core.cell.call(null,false);
var border_radius = (4);
var filtered_data = javelin.core.formula.call(null,((function (highlighted,search_text,open_QMARK_,border_radius,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (open_QMARK___$1,data__$1,search_text__$1){
if(cljs.core.not.call(null,open_QMARK___$1)){
return null;
} else {
if(clojure.string.blank_QMARK_.call(null,search_text__$1)){
return data__$1;
} else {
return cljs.core.filter.call(null,((function (highlighted,search_text,open_QMARK_,border_radius,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (p1__35659_SHARP_){
return clojure.string.index_of.call(null,clojure.string.lower_case.call(null,search_fn.call(null,p1__35659_SHARP_)),clojure.string.lower_case.call(null,search_text__$1));
});})(highlighted,search_text,open_QMARK_,border_radius,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
,data__$1);

}
}
});})(highlighted,search_text,open_QMARK_,border_radius,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
).call(null,open_QMARK_,data,search_text);
var matching_items = javelin.core.formula.call(null,((function (highlighted,search_text,open_QMARK_,border_radius,filtered_data,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (filtered_data__$1){
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"index-to-item","index-to-item",729994611),cljs.core.zipmap.call(null,cljs.core.range.call(null),filtered_data__$1),new cljs.core.Keyword(null,"key-to-index","key-to-index",-567854675),cljs.core.zipmap.call(null,cljs.core.map.call(null,key_fn,filtered_data__$1),cljs.core.range.call(null))], null);
});})(highlighted,search_text,open_QMARK_,border_radius,filtered_data,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
).call(null,filtered_data);
var ids = javelin.core.formula.call(null,((function (highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (data__$1){
return cljs.core.zipmap.call(null,cljs.core.map.call(null,key_fn,data__$1),cljs.core.repeatedly.call(null,((function (highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (){
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.gensym.call(null));
});})(highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
));
});})(highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
).call(null,data);
var highlighted_item = javelin.core.formula.call(null,((function (highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (matching_items__$1,highlighted__$1){
return cljs.core.get_in.call(null,matching_items__$1,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"index-to-item","index-to-item",729994611),highlighted__$1], null));
});})(highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
).call(null,matching_items,highlighted);
if(cljs.core.truth_(highlight)){
hoplon.core.do_watch.call(null,highlighted_item,((function (highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (___$1,n){
return highlight.call(null,n);
});})(highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
);
} else {
}

hoplon.core.do_watch.call(null,open_QMARK_,((function (highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (___$1,n){
if(cljs.core.truth_(n)){
return null;
} else {
return cljs.core.reset_BANG_.call(null,search_text,null);
}
});})(highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
);

hoplon.core.do_watch.call(null,filtered_data,((function (highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (___$1,n){
return cljs.core.reset_BANG_.call(null,highlighted,(cljs.core.truth_(cljs.core.deref.call(null,open_QMARK_))?(0):null));
});})(highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
);

var elem = hoplon.core.div.call(null,new cljs.core.Keyword(null,"debug","debug",-1608172596),"select3 outer");
document.addEventListener("click",((function (elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (e){
if(cljs.core.truth_((function (){var and__4120__auto__ = cljs.core.deref.call(null,open_QMARK_);
if(cljs.core.truth_(and__4120__auto__)){
return cljs.core.not.call(null,elem.contains(e.target));
} else {
return and__4120__auto__;
}
})())){
return cljs.core.reset_BANG_.call(null,open_QMARK_,false);
} else {
return null;
}
});})(elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
);

elem.call(null,attrs__$1,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"width","width",-384071477),width,new cljs.core.Keyword(null,"font-family","font-family",-667419874),"Open Sans Condensed",new cljs.core.Keyword(null,"position","position",-2011731912),"relative"], null),hoplon.core.div.call(null,new cljs.core.Keyword(null,"debug","debug",-1608172596),"top row",new cljs.core.Keyword(null,"click","click",1912301393),((function (elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (){
return cljs.core.swap_BANG_.call(null,open_QMARK_,cljs.core.not);
});})(elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"cursor","cursor",1011937484),"pointer"], null),hoplon.core.div.call(null,new cljs.core.Keyword(null,"css","css",1135045163),javelin.core.formula.call(null,((function (elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (open_QMARK___$1){
return cljs.core.PersistentHashMap.fromArrays([new cljs.core.Keyword(null,"border-style","border-style",-485574304),new cljs.core.Keyword(null,"border-top-right-radius","border-top-right-radius",1678770792),new cljs.core.Keyword(null,"background","background",-863952629),new cljs.core.Keyword(null,"border-bottom-left-radius","border-bottom-left-radius",-76446610),new cljs.core.Keyword(null,"border-top-left-radius","border-top-left-radius",1361811342),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,"border-bottom-right-radius","border-bottom-right-radius",414899772)],["solid",weathergen.ui.common.px.call(null,border_radius),"white",weathergen.ui.common.px.call(null,(cljs.core.truth_(open_QMARK___$1)?(0):border_radius)),weathergen.ui.common.px.call(null,border_radius),weathergen.ui.common.px.call(null,(1)),weathergen.ui.common.px.call(null,(3),(25),(3),(5)),"#aaa",weathergen.ui.common.px.call(null,(cljs.core.truth_(open_QMARK___$1)?(0):border_radius))]);
});})(elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
).call(null,open_QMARK_),javelin.core.formula.call(null,((function (elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (value__$1){
if(cljs.core.truth_(value__$1)){
return formatter.call(null,value__$1);
} else {
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,"color","color",1011675173),"#999"], null),placeholder);
}
});})(elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
).call(null,value)),(function (){var arrow_size = (6);
return hoplon.core.div.call(null,new cljs.core.Keyword(null,"debug","debug",-1608172596),"arrow container",new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"display","display",242065432),"inline-block",new cljs.core.Keyword(null,"position","position",-2011731912),"absolute",new cljs.core.Keyword(null,"right","right",-452581833),weathergen.ui.common.px.call(null,(7)),new cljs.core.Keyword(null,"top","top",-1856271961),weathergen.ui.common.px.call(null,(arrow_size / (2)))], null),hoplon.core.div.call(null,new cljs.core.Keyword(null,"css","css",1135045163),javelin.core.formula.call(null,((function (arrow_size,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (open_QMARK___$1){
return cljs.core.PersistentHashMap.fromArrays([new cljs.core.Keyword(null,"border-top-style","border-top-style",-668961567),new cljs.core.Keyword(null,"transform","transform",1381301764),new cljs.core.Keyword(null,"border-left-width","border-left-width",2037218085),new cljs.core.Keyword(null,"border-right-style","border-right-style",-1606013368),new cljs.core.Keyword(null,"border-left-color","border-left-color",-1166146583),new cljs.core.Keyword(null,"width","width",-384071477),new cljs.core.Keyword(null,"border-right-width","border-right-width",750273868),new cljs.core.Keyword(null,"border-right-color","border-right-color",2017953775),new cljs.core.Keyword(null,"border-left-style","border-left-style",65166675),new cljs.core.Keyword(null,"border-top-width","border-top-width",1612782932),new cljs.core.Keyword(null,"border-top-color","border-top-color",-804629899),new cljs.core.Keyword(null,"display","display",242065432),new cljs.core.Keyword(null,"height","height",1025178622)],["solid",["rotate(",cljs.core.str.cljs$core$IFn$_invoke$arity$1((cljs.core.truth_(open_QMARK___$1)?(180):(0))),"deg)"].join(''),weathergen.ui.common.px.call(null,(0.66 * arrow_size)),"solid","transparent",(0),weathergen.ui.common.px.call(null,(0.66 * arrow_size)),"transparent","solid",weathergen.ui.common.px.call(null,arrow_size),"#888","inline-block",(0)]);
});})(arrow_size,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
).call(null,open_QMARK_)));
})()),hoplon.core.div.call(null,new cljs.core.Keyword(null,"debug","debug",-1608172596),"spacer"),hoplon.core.div.call(null,new cljs.core.Keyword(null,"debug","debug",-1608172596),"dropdown area container",new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"position","position",-2011731912),"relative"], null),hoplon.core.div.call(null,new cljs.core.Keyword(null,"debug","debug",-1608172596),"dropdown area",new cljs.core.Keyword(null,"css","css",1135045163),javelin.core.formula.call(null,((function (elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (open_QMARK___$1){
return cljs.core.PersistentHashMap.fromArrays([new cljs.core.Keyword(null,"border-style","border-style",-485574304),new cljs.core.Keyword(null,"border-top-style","border-top-style",-668961567),new cljs.core.Keyword(null,"top","top",-1856271961),new cljs.core.Keyword(null,"background","background",-863952629),new cljs.core.Keyword(null,"border-bottom-left-radius","border-bottom-left-radius",-76446610),new cljs.core.Keyword(null,"border-width","border-width",-1512605390),new cljs.core.Keyword(null,"z-index","z-index",1892827090),new cljs.core.Keyword(null,"border-color","border-color",-2059162761),new cljs.core.Keyword(null,"display","display",242065432),new cljs.core.Keyword(null,"position","position",-2011731912),new cljs.core.Keyword(null,"border-bottom-right-radius","border-bottom-right-radius",414899772)],["solid","none",(0),"white",weathergen.ui.common.px.call(null,border_radius),weathergen.ui.common.px.call(null,(1)),(100),"#aaa",(cljs.core.truth_(open_QMARK___$1)?"block":"none"),"absolute",weathergen.ui.common.px.call(null,border_radius)]);
});})(elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
).call(null,open_QMARK_),hoplon.core.div.call(null,new cljs.core.Keyword(null,"debug","debug",-1608172596),"sets width",new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"width","width",-384071477),width,new cljs.core.Keyword(null,"margin-left","margin-left",2015598377),weathergen.ui.common.px.call(null,(-2))], null)),(function (){var gap = (5);
return hoplon.core.div.call(null,new cljs.core.Keyword(null,"debug","debug",-1608172596),"Search box",new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"padding","padding",1660304693),weathergen.ui.common.px.call(null,(0),gap,(2),((2) * gap))], null),(function (){var i = hoplon.core.input.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"width","width",-384071477),weathergen.ui.common.pct.call(null,(100)),new cljs.core.Keyword(null,"position","position",-2011731912),"relative",new cljs.core.Keyword(null,"right","right",-452581833),weathergen.ui.common.px.call(null,gap)], null),new cljs.core.Keyword(null,"value","value",305978217),search_text,new cljs.core.Keyword(null,"input","input",556931961),((function (gap,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (p1__35660_SHARP_){
return cljs.core.reset_BANG_.call(null,search_text,cljs.core.deref.call(null,p1__35660_SHARP_));
});})(gap,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
,new cljs.core.Keyword(null,"keydown","keydown",-629268186),((function (gap,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (e){
var pred__35668 = cljs.core._EQ_;
var expr__35669 = e.keyCode;
if(cljs.core.truth_(pred__35668.call(null,weathergen.ui.common.ESCAPE_KEY,expr__35669))){
return cljs.core.reset_BANG_.call(null,open_QMARK_,false);
} else {
if(cljs.core.truth_(pred__35668.call(null,weathergen.ui.common.ENTER_KEY,expr__35669))){
if(cljs.core.empty_QMARK_.call(null,cljs.core.deref.call(null,filtered_data))){
return null;
} else {
var new_val = cljs.core.get_in.call(null,cljs.core.deref.call(null,matching_items),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"index-to-item","index-to-item",729994611),cljs.core.deref.call(null,highlighted)], null));
return javelin.core.dosync_STAR_.call(null,((function (new_val,pred__35668,expr__35669,gap,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (){
cljs.core.reset_BANG_.call(null,open_QMARK_,false);

cljs.core.reset_BANG_.call(null,value,new_val);

if(cljs.core.truth_(change)){
return change.call(null,new_val);
} else {
return null;
}
});})(new_val,pred__35668,expr__35669,gap,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
);
}
} else {
if(cljs.core.truth_(pred__35668.call(null,weathergen.ui.common.DOWN_ARROW,expr__35669))){
return cljs.core.swap_BANG_.call(null,highlighted,((function (pred__35668,expr__35669,gap,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (p1__35661_SHARP_){
var x__4222__auto__ = (p1__35661_SHARP_ + (1));
var y__4223__auto__ = (cljs.core.count.call(null,cljs.core.deref.call(null,filtered_data)) - (1));
return ((x__4222__auto__ < y__4223__auto__) ? x__4222__auto__ : y__4223__auto__);
});})(pred__35668,expr__35669,gap,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
);
} else {
if(cljs.core.truth_(pred__35668.call(null,weathergen.ui.common.UP_ARROW,expr__35669))){
return cljs.core.swap_BANG_.call(null,highlighted,((function (pred__35668,expr__35669,gap,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (p1__35662_SHARP_){
var x__4219__auto__ = (0);
var y__4220__auto__ = (p1__35662_SHARP_ - (1));
return ((x__4219__auto__ > y__4220__auto__) ? x__4219__auto__ : y__4220__auto__);
});})(pred__35668,expr__35669,gap,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
);
} else {
return null;
}
}
}
}
});})(gap,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
);
hoplon.core.do_watch.call(null,open_QMARK_,((function (i,gap,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (___$1,n){
if(cljs.core.truth_(n)){
return setTimeout(((function (i,gap,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (){
return i.focus();
});})(i,gap,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
,(0));
} else {
return null;
}
});})(i,gap,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
);

return i;
})());
})(),(function (){var has_matches_QMARK_ = javelin.core.formula.call(null,((function (elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (G__35672,G__35671,G__35673){
return G__35671.call(null,G__35672.call(null,G__35673));
});})(elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
).call(null,cljs.core.empty_QMARK_,cljs.core.not,filtered_data);
return weathergen.ui.common.styled.call(null,new cljs.core.Keyword(null,"garden","garden",-1966516149),javelin.core.formula.call(null,((function (has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (highlighted__$1,matching_items__$1,ids__$1){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [garden.selectors.selector.call(null,["#",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.get.call(null,ids__$1,key_fn.call(null,cljs.core.get_in.call(null,matching_items__$1,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"index-to-item","index-to-item",729994611),highlighted__$1], null)))))].join('')),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"background","background",-863952629),"#5897fb",new cljs.core.Keyword(null,"color","color",1011675173),"white"], null)], null);
});})(has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
).call(null,highlighted,matching_items,ids),hoplon.core.div.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"padding-left","padding-left",-1180879053),weathergen.ui.common.px.call(null,(5)),new cljs.core.Keyword(null,"user-select","user-select",-346451650),"none"], null),new cljs.core.Keyword(null,"toggle","toggle",1291842030),javelin.core.formula.call(null,((function (has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (G__35674,G__35675){
return G__35674.call(null,G__35675);
});})(has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
).call(null,cljs.core.not,has_matches_QMARK_),"No results found"),(function (){var elem__$1 = hoplon.core.ul.call(null);
hoplon.core.do_watch.call(null,filtered_data,((function (elem__$1,has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (___$1,___$2){
return elem__$1.scrollTop = (0);
});})(elem__$1,has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
);

elem__$1.call(null,new cljs.core.Keyword(null,"toggle","toggle",1291842030),has_matches_QMARK_,new cljs.core.Keyword(null,"debug","debug",-1608172596),"item list area",new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 6, [new cljs.core.Keyword(null,"overflow-y","overflow-y",-1436589285),"scroll",new cljs.core.Keyword(null,"max-height","max-height",-612563804),(function (){var or__4131__auto__ = max_dropdown_height;
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return weathergen.ui.common.px.call(null,(150));
}
})(),new cljs.core.Keyword(null,"padding","padding",1660304693),(0),new cljs.core.Keyword(null,"margin","margin",-995903681),(0),new cljs.core.Keyword(null,"user-select","user-select",-346451650),"none",new cljs.core.Keyword(null,"list-style","list-style",-809622358),"none"], null),weathergen.ui.common.keyed_loop_tpl_STAR_.call(null,data,key_fn,((function (elem__$1,has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (item__15894__auto__){
var vec__35676 = javelin.core.cell_map.call(null,cljs.core.identity,javelin.core.formula.call(null,((function (elem__$1,has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (item){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [item], null);
});})(elem__$1,has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
).call(null,item__15894__auto__));
var item = cljs.core.nth.call(null,vec__35676,(0),null);
var elem__$2 = hoplon.core.li.call(null);
hoplon.core.do_watch.call(null,highlighted,((function (elem__$2,vec__35676,item,elem__$1,has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (___$1,n){
if(cljs.core._EQ_.call(null,cljs.core.deref.call(null,item),cljs.core.get_in.call(null,cljs.core.deref.call(null,matching_items),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"index-to-item","index-to-item",729994611),n], null)))){
return elem__$2.scrollIntoViewIfNeeded();
} else {
return null;
}
});})(elem__$2,vec__35676,item,elem__$1,has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
);

elem__$2.call(null,new cljs.core.Keyword(null,"id","id",-1388402092),javelin.core.formula.call(null,((function (elem__$2,vec__35676,item,elem__$1,has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (G__35681,G__35679,G__35680){
return G__35679.call(null,G__35680.call(null,G__35681));
});})(elem__$2,vec__35676,item,elem__$1,has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
).call(null,item,ids,key_fn),new cljs.core.Keyword(null,"mouseenter","mouseenter",-1792413560),((function (elem__$2,vec__35676,item,elem__$1,has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (){
return cljs.core.reset_BANG_.call(null,highlighted,cljs.core.get_in.call(null,cljs.core.deref.call(null,matching_items),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"key-to-index","key-to-index",-567854675),key_fn.call(null,cljs.core.deref.call(null,item))], null)));
});})(elem__$2,vec__35676,item,elem__$1,has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
,new cljs.core.Keyword(null,"class","class",-2030961996),javelin.core.formula.call(null,((function (elem__$2,vec__35676,item,elem__$1,has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (item__$1,matching_items__$1){
return cljs.core.PersistentArrayMap.createAsIfByAssoc([weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.select","hidden","weathergen.ui.select/hidden",-252585472)),(!(cljs.core.contains_QMARK_.call(null,new cljs.core.Keyword(null,"key-to-index","key-to-index",-567854675).cljs$core$IFn$_invoke$arity$1(matching_items__$1),key_fn.call(null,item__$1))))]);
});})(elem__$2,vec__35676,item,elem__$1,has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
).call(null,item,matching_items),hoplon.core.div.call(null,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"padding-left","padding-left",-1180879053),weathergen.ui.common.px.call(null,(5))], null),new cljs.core.Keyword(null,"click","click",1912301393),((function (elem__$2,vec__35676,item,elem__$1,has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (){
return javelin.core.dosync_STAR_.call(null,((function (elem__$2,vec__35676,item,elem__$1,has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_){
return (function (){
cljs.core.reset_BANG_.call(null,value,cljs.core.deref.call(null,item));

cljs.core.reset_BANG_.call(null,open_QMARK_,false);

if(cljs.core.truth_(change)){
return change.call(null,cljs.core.deref.call(null,item));
} else {
return null;
}
});})(elem__$2,vec__35676,item,elem__$1,has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
);
});})(elem__$2,vec__35676,item,elem__$1,has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
,formatter.call(null,item)));

return elem__$2;
});})(elem__$1,has_matches_QMARK_,elem,highlighted,search_text,open_QMARK_,border_radius,filtered_data,matching_items,ids,highlighted_item,map__35666,map__35666__$1,max_dropdown_height,change,data,placeholder,search_fn,highlight,formatter,value,width,key_fn,attrs__$1,vec__35663,attrs,_))
));

return elem__$1;
})());
})())));

return elem;
};
var weathergen$ui$select$select3 = function (var_args){
var args__30233__auto__ = null;
if (arguments.length > 0) {
var G__35682__i = 0, G__35682__a = new Array(arguments.length -  0);
while (G__35682__i < G__35682__a.length) {G__35682__a[G__35682__i] = arguments[G__35682__i + 0]; ++G__35682__i;}
  args__30233__auto__ = new cljs.core.IndexedSeq(G__35682__a,0,null);
} 
return weathergen$ui$select$select3__delegate.call(this,args__30233__auto__);};
weathergen$ui$select$select3.cljs$lang$maxFixedArity = 0;
weathergen$ui$select$select3.cljs$lang$applyTo = (function (arglist__35683){
var args__30233__auto__ = cljs.core.seq(arglist__35683);
return weathergen$ui$select$select3__delegate(args__30233__auto__);
});
weathergen$ui$select$select3.cljs$core$IFn$_invoke$arity$variadic = weathergen$ui$select$select3__delegate;
return weathergen$ui$select$select3;
})()
;
