// Compiled by ClojureScript 1.9.562 {:target :nodejs}
goog.provide('weathergen.util');
goog.require('cljs.core');
/**
 * Convert a string to a long. Returns nil when it can't be parsed.
 */
weathergen.util.str__GT_long = (function weathergen$util$str__GT_long(s){
var n = (new Number(s)).valueOf();
if(cljs.core.int_QMARK_.call(null,n)){
return cljs.core.long$.call(null,n);
} else {
return null;
}
});
/**
 * Concatenates `colls` into a vector. Order of elements is preserved.
 */
weathergen.util.concatv = (function weathergen$util$concatv(var_args){
var args__24376__auto__ = [];
var len__24369__auto___28804 = arguments.length;
var i__24370__auto___28806 = (0);
while(true){
if((i__24370__auto___28806 < len__24369__auto___28804)){
args__24376__auto__.push((arguments[i__24370__auto___28806]));

var G__28807 = (i__24370__auto___28806 + (1));
i__24370__auto___28806 = G__28807;
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.util.concatv.cljs$core$IFn$_invoke$arity$variadic(argseq__24377__auto__);
});

weathergen.util.concatv.cljs$core$IFn$_invoke$arity$variadic = (function (colls){
return cljs.core.reduce.call(null,cljs.core.into,cljs.core.PersistentVector.EMPTY,colls);
});

weathergen.util.concatv.cljs$lang$maxFixedArity = (0);

weathergen.util.concatv.cljs$lang$applyTo = (function (seq28797){
return weathergen.util.concatv.cljs$core$IFn$_invoke$arity$variadic(cljs.core.seq.call(null,seq28797));
});

/**
 * Filters `coll` for an x where `(f x)` is equal to `val`
 */
weathergen.util.filter_EQ_ = (function weathergen$util$filter_EQ_(f,val,coll){
return cljs.core.filter.call(null,(function (p1__28811_SHARP_){
return cljs.core._EQ_.call(null,f.call(null,p1__28811_SHARP_),val);
}),coll);
});
/**
 * Returns the first element of a sequence, or nil if it's empty, or
 *   throws an exception if there is more than one element.
 */
weathergen.util.only = (function weathergen$util$only(coll){
if(cljs.core.empty_QMARK_.call(null,coll)){
return null;
} else {
if(cljs.core.empty_QMARK_.call(null,cljs.core.rest.call(null,coll))){
return cljs.core.first.call(null,coll);
} else {
throw cljs.core.ex_info.call(null,"Sequence had more than one item",new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"reason","reason",-2070751759),new cljs.core.Keyword(null,"not-singular","not-singular",1360522305),new cljs.core.Keyword(null,"coll","coll",1647737163),coll], null));

}
}
});
/**
 * Like take-while, but also includes the first item where `pred`
 *   returns true.
 */
weathergen.util.take_until = (function weathergen$util$take_until(pred,coll){
if(cljs.core.empty_QMARK_.call(null,coll)){
return coll;
} else {
if(cljs.core.truth_(pred.call(null,cljs.core.first.call(null,coll)))){
return cljs.core.take.call(null,(1),coll);
} else {
var vec__28823 = cljs.core.partition_by.call(null,pred,coll);
var head = cljs.core.nth.call(null,vec__28823,(0),null);
var next = cljs.core.nth.call(null,vec__28823,(1),null);
return cljs.core.concat.call(null,head,cljs.core.take.call(null,(1),next));

}
}
});
/**
 * If `x` is a member of `s`, remove it. Otherwise, add it.
 */
weathergen.util.toggle_set_membership = (function weathergen$util$toggle_set_membership(s,x){
var op = ((cljs.core.contains_QMARK_.call(null,s,x))?cljs.core.disj:cljs.core.conj);
return op.call(null,s,x);
});
/**
 * Returns true if all of the bits set in `mask` are also set in `x`.
 */
weathergen.util.has_flag_QMARK_ = (function weathergen$util$has_flag_QMARK_(x,mask){
return cljs.core._EQ_.call(null,(x & mask),mask);
});
