// Compiled by ClojureScript 1.7.170 {}
goog.provide('clojurescript.core');
goog.require('cljs.core');
goog.require('replumb.core');
goog.require('replumb.nodejs');
goog.require('cljs.js');
goog.require('cljs.nodejs');
goog.require('fipp.clojure');
goog.require('clojure.string');
goog.require('replumb.repl');
cljs.nodejs.enable_util_print_BANG_.call(null);
clojurescript.core.fs = cljs.nodejs.require.call(null,"fs");
/**
 * Accepts a filename to read and a callback. Upon success, invokes
 *   callback with the source. Otherwise invokes the callback with nil.
 */
clojurescript.core.node_read_file = (function clojurescript$core$node_read_file(filename,cb){
return clojurescript.core.fs.readFile(filename,"utf-8",(function (err,source){
return cb.call(null,(cljs.core.truth_(err)?null:source));
}));
});
/**
 * Accepts a filename to read. Upon success, returns the source.
 *   Otherwise returns nil.
 */
clojurescript.core.node_read_file_sync = (function clojurescript$core$node_read_file_sync(filename){
return clojurescript.core.fs.readFileSync(filename,"utf-8");
});
clojurescript.core.goog_path_root = "out/goog/";
clojurescript.core.closure_index = (function clojurescript$core$closure_index(){
var paths_to_provides = cljs.core.map.call(null,(function (p__10868){
var vec__10869 = p__10868;
var _ = cljs.core.nth.call(null,vec__10869,(0),null);
var path = cljs.core.nth.call(null,vec__10869,(1),null);
var provides = cljs.core.nth.call(null,vec__10869,(2),null);
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [path,cljs.core.map.call(null,cljs.core.second,cljs.core.re_seq.call(null,/'(.*?)'/,provides))], null);
}),cljs.core.re_seq.call(null,/\ngoog\.addDependency\('(.*)', \[(.*?)\].*/,clojurescript.core.node_read_file_sync.call(null,[cljs.core.str(clojurescript.core.goog_path_root),cljs.core.str("deps.js")].join(''))));
return cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,(function (){var iter__5440__auto__ = ((function (paths_to_provides){
return (function clojurescript$core$closure_index_$_iter__10870(s__10871){
return (new cljs.core.LazySeq(null,((function (paths_to_provides){
return (function (){
var s__10871__$1 = s__10871;
while(true){
var temp__4425__auto__ = cljs.core.seq.call(null,s__10871__$1);
if(temp__4425__auto__){
var xs__4977__auto__ = temp__4425__auto__;
var vec__10877 = cljs.core.first.call(null,xs__4977__auto__);
var path = cljs.core.nth.call(null,vec__10877,(0),null);
var provides = cljs.core.nth.call(null,vec__10877,(1),null);
var iterys__5436__auto__ = ((function (s__10871__$1,vec__10877,path,provides,xs__4977__auto__,temp__4425__auto__,paths_to_provides){
return (function clojurescript$core$closure_index_$_iter__10870_$_iter__10872(s__10873){
return (new cljs.core.LazySeq(null,((function (s__10871__$1,vec__10877,path,provides,xs__4977__auto__,temp__4425__auto__,paths_to_provides){
return (function (){
var s__10873__$1 = s__10873;
while(true){
var temp__4425__auto____$1 = cljs.core.seq.call(null,s__10873__$1);
if(temp__4425__auto____$1){
var s__10873__$2 = temp__4425__auto____$1;
if(cljs.core.chunked_seq_QMARK_.call(null,s__10873__$2)){
var c__5438__auto__ = cljs.core.chunk_first.call(null,s__10873__$2);
var size__5439__auto__ = cljs.core.count.call(null,c__5438__auto__);
var b__10875 = cljs.core.chunk_buffer.call(null,size__5439__auto__);
if((function (){var i__10874 = (0);
while(true){
if((i__10874 < size__5439__auto__)){
var provide = cljs.core._nth.call(null,c__5438__auto__,i__10874);
cljs.core.chunk_append.call(null,b__10875,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.symbol.call(null,provide),[cljs.core.str(clojurescript.core.goog_path_root),cljs.core.str(cljs.core.second.call(null,cljs.core.re_find.call(null,/(.*)\.js$/,path)))].join('')], null));

var G__10878 = (i__10874 + (1));
i__10874 = G__10878;
continue;
} else {
return true;
}
break;
}
})()){
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__10875),clojurescript$core$closure_index_$_iter__10870_$_iter__10872.call(null,cljs.core.chunk_rest.call(null,s__10873__$2)));
} else {
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__10875),null);
}
} else {
var provide = cljs.core.first.call(null,s__10873__$2);
return cljs.core.cons.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.symbol.call(null,provide),[cljs.core.str(clojurescript.core.goog_path_root),cljs.core.str(cljs.core.second.call(null,cljs.core.re_find.call(null,/(.*)\.js$/,path)))].join('')], null),clojurescript$core$closure_index_$_iter__10870_$_iter__10872.call(null,cljs.core.rest.call(null,s__10873__$2)));
}
} else {
return null;
}
break;
}
});})(s__10871__$1,vec__10877,path,provides,xs__4977__auto__,temp__4425__auto__,paths_to_provides))
,null,null));
});})(s__10871__$1,vec__10877,path,provides,xs__4977__auto__,temp__4425__auto__,paths_to_provides))
;
var fs__5437__auto__ = cljs.core.seq.call(null,iterys__5436__auto__.call(null,provides));
if(fs__5437__auto__){
return cljs.core.concat.call(null,fs__5437__auto__,clojurescript$core$closure_index_$_iter__10870.call(null,cljs.core.rest.call(null,s__10871__$1)));
} else {
var G__10879 = cljs.core.rest.call(null,s__10871__$1);
s__10871__$1 = G__10879;
continue;
}
} else {
return null;
}
break;
}
});})(paths_to_provides))
,null,null));
});})(paths_to_provides))
;
return iter__5440__auto__.call(null,paths_to_provides);
})());
});
clojurescript.core.closure_index_mem = cljs.core.memoize.call(null,clojurescript.core.closure_index);
clojurescript.core.load_goog = (function clojurescript$core$load_goog(name,cb){
var temp__4423__auto__ = cljs.core.get.call(null,clojurescript.core.closure_index_mem.call(null),name);
if(cljs.core.truth_(temp__4423__auto__)){
var goog_path = temp__4423__auto__;
var temp__4423__auto____$1 = clojurescript.core.node_read_file_sync.call(null,[cljs.core.str(goog_path),cljs.core.str(".js")].join(''));
if(cljs.core.truth_(temp__4423__auto____$1)){
var source = temp__4423__auto____$1;
return cb.call(null,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"source","source",-433931539),source,new cljs.core.Keyword(null,"lang","lang",-1819677104),new cljs.core.Keyword(null,"js","js",1768080579)], null));
} else {
return cb.call(null,null);
}
} else {
return cb.call(null,null);
}
});
/**
 * Converts a filename to a lang keyword by inspecting the file
 *   extension.
 */
clojurescript.core.filename__GT_lang = (function clojurescript$core$filename__GT_lang(filename){
if(clojure.string.ends_with_QMARK_.call(null,filename,".js")){
return new cljs.core.Keyword(null,"js","js",1768080579);
} else {
return new cljs.core.Keyword(null,"clj","clj",-660495428);
}
});
/**
 * Reads the first filename in a sequence of supplied filenames,
 *   using a supplied read-file-fn, calling back upon first successful
 *   read, otherwise calling back with nil.
 */
clojurescript.core.read_some = (function clojurescript$core$read_some(p__10880,read_file_fn,cb){
var vec__10882 = p__10880;
var filename = cljs.core.nth.call(null,vec__10882,(0),null);
var more_filenames = cljs.core.nthnext.call(null,vec__10882,(1));
if(cljs.core.truth_(filename)){
return read_file_fn.call(null,filename,((function (vec__10882,filename,more_filenames){
return (function (source){
if(cljs.core.truth_(source)){
return cb.call(null,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"lang","lang",-1819677104),clojurescript.core.filename__GT_lang.call(null,filename),new cljs.core.Keyword(null,"source","source",-433931539),source], null));
} else {
return clojurescript$core$read_some.call(null,more_filenames,read_file_fn,cb);
}
});})(vec__10882,filename,more_filenames))
);
} else {
return cb.call(null,null);
}
});
/**
 * Produces a sequence of filenames to try reading, in the
 *   order they should be tried.
 */
clojurescript.core.filenames_to_try = (function clojurescript$core$filenames_to_try(src_paths,macros,path){
var extensions = (cljs.core.truth_(macros)?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [".clj",".cljc"], null):new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [".cljs",".cljc",".js"], null));
var iter__5440__auto__ = ((function (extensions){
return (function clojurescript$core$filenames_to_try_$_iter__10889(s__10890){
return (new cljs.core.LazySeq(null,((function (extensions){
return (function (){
var s__10890__$1 = s__10890;
while(true){
var temp__4425__auto__ = cljs.core.seq.call(null,s__10890__$1);
if(temp__4425__auto__){
var xs__4977__auto__ = temp__4425__auto__;
var extension = cljs.core.first.call(null,xs__4977__auto__);
var iterys__5436__auto__ = ((function (s__10890__$1,extension,xs__4977__auto__,temp__4425__auto__,extensions){
return (function clojurescript$core$filenames_to_try_$_iter__10889_$_iter__10891(s__10892){
return (new cljs.core.LazySeq(null,((function (s__10890__$1,extension,xs__4977__auto__,temp__4425__auto__,extensions){
return (function (){
var s__10892__$1 = s__10892;
while(true){
var temp__4425__auto____$1 = cljs.core.seq.call(null,s__10892__$1);
if(temp__4425__auto____$1){
var s__10892__$2 = temp__4425__auto____$1;
if(cljs.core.chunked_seq_QMARK_.call(null,s__10892__$2)){
var c__5438__auto__ = cljs.core.chunk_first.call(null,s__10892__$2);
var size__5439__auto__ = cljs.core.count.call(null,c__5438__auto__);
var b__10894 = cljs.core.chunk_buffer.call(null,size__5439__auto__);
if((function (){var i__10893 = (0);
while(true){
if((i__10893 < size__5439__auto__)){
var src_path = cljs.core._nth.call(null,c__5438__auto__,i__10893);
cljs.core.chunk_append.call(null,b__10894,[cljs.core.str(src_path),cljs.core.str("/"),cljs.core.str(path),cljs.core.str(extension)].join(''));

var G__10895 = (i__10893 + (1));
i__10893 = G__10895;
continue;
} else {
return true;
}
break;
}
})()){
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__10894),clojurescript$core$filenames_to_try_$_iter__10889_$_iter__10891.call(null,cljs.core.chunk_rest.call(null,s__10892__$2)));
} else {
return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__10894),null);
}
} else {
var src_path = cljs.core.first.call(null,s__10892__$2);
return cljs.core.cons.call(null,[cljs.core.str(src_path),cljs.core.str("/"),cljs.core.str(path),cljs.core.str(extension)].join(''),clojurescript$core$filenames_to_try_$_iter__10889_$_iter__10891.call(null,cljs.core.rest.call(null,s__10892__$2)));
}
} else {
return null;
}
break;
}
});})(s__10890__$1,extension,xs__4977__auto__,temp__4425__auto__,extensions))
,null,null));
});})(s__10890__$1,extension,xs__4977__auto__,temp__4425__auto__,extensions))
;
var fs__5437__auto__ = cljs.core.seq.call(null,iterys__5436__auto__.call(null,src_paths));
if(fs__5437__auto__){
return cljs.core.concat.call(null,fs__5437__auto__,clojurescript$core$filenames_to_try_$_iter__10889.call(null,cljs.core.rest.call(null,s__10890__$1)));
} else {
var G__10896 = cljs.core.rest.call(null,s__10890__$1);
s__10890__$1 = G__10896;
continue;
}
} else {
return null;
}
break;
}
});})(extensions))
,null,null));
});})(extensions))
;
return iter__5440__auto__.call(null,extensions);
});
clojurescript.core.skip_load_QMARK_ = (function clojurescript$core$skip_load_QMARK_(name,macros){
return (cljs.core.truth_(macros)?new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Symbol(null,"cljs.pprint","cljs.pprint",-966900911,null),null], null), null):new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 12, [new cljs.core.Symbol(null,"clojure.string","clojure.string",-1415552165,null),null,new cljs.core.Symbol(null,"cljs.pprint","cljs.pprint",-966900911,null),null,new cljs.core.Symbol(null,"goog.string.StringBuffer","goog.string.StringBuffer",-1220229842,null),null,new cljs.core.Symbol(null,"cljs.core","cljs.core",770546058,null),null,new cljs.core.Symbol(null,"goog.array","goog.array",-671977860,null),null,new cljs.core.Symbol(null,"clojure.set","clojure.set",-630955632,null),null,new cljs.core.Symbol(null,"cljs.tools.reader.impl.utils","cljs.tools.reader.impl.utils",1797659699,null),null,new cljs.core.Symbol(null,"cljs.tagged-literals","cljs.tagged-literals",387033363,null),null,new cljs.core.Symbol(null,"goog.string","goog.string",-2055533048,null),null,new cljs.core.Symbol(null,"cljs.reader","cljs.reader",1327473948,null),null,new cljs.core.Symbol(null,"cljs.env","cljs.env",-1810013139,null),null,new cljs.core.Symbol(null,"goog.object","goog.object",678593132,null),null], null), null)).call(null,name);
});
clojurescript.core.loaded = cljs.core.atom.call(null,cljs.core.PersistentHashSet.EMPTY);
clojurescript.core.load_QMARK_ = (function clojurescript$core$load_QMARK_(name,macros){
var do_not_load = (function (){var or__4668__auto__ = cljs.core.deref.call(null,clojurescript.core.loaded).call(null,name);
if(cljs.core.truth_(or__4668__auto__)){
return or__4668__auto__;
} else {
return clojurescript.core.skip_load_QMARK_.call(null,name,macros);
}
})();
cljs.core.swap_BANG_.call(null,clojurescript.core.loaded,cljs.core.conj,name);

return cljs.core.not.call(null,do_not_load);
});
/**
 * Makes a load function that will read from a sequence of src-paths
 *   using a supplied read-file-fn. It returns a cljs.js-compatible
 *   *load-fn*.
 * 
 *   Read-file-fn is a 2-arity function (fn [filename source-cb] ...) where
 *   source-cb is itself a function (fn [source] ...) that needs to be called
 *   with the source of the library (as string).
 */
clojurescript.core.make_load_fn = (function clojurescript$core$make_load_fn(src_paths,read_file_fn){
return (function (p__10900,cb){
var map__10901 = p__10900;
var map__10901__$1 = ((((!((map__10901 == null)))?((((map__10901.cljs$lang$protocol_mask$partition0$ & (64))) || (map__10901.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__10901):map__10901);
var name = cljs.core.get.call(null,map__10901__$1,new cljs.core.Keyword(null,"name","name",1843675177));
var macros = cljs.core.get.call(null,map__10901__$1,new cljs.core.Keyword(null,"macros","macros",811339431));
var path = cljs.core.get.call(null,map__10901__$1,new cljs.core.Keyword(null,"path","path",-188191168));
if(cljs.core.truth_(clojurescript.core.load_QMARK_.call(null,name,macros))){
if(cljs.core.truth_(cljs.core.re_matches.call(null,/^goog\/.*/,path))){
return clojurescript.core.load_goog.call(null,name,cb);
} else {
return clojurescript.core.read_some.call(null,clojurescript.core.filenames_to_try.call(null,src_paths,macros,path),read_file_fn,cb);
}
} else {
return cb.call(null,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"source","source",-433931539),"",new cljs.core.Keyword(null,"lang","lang",-1819677104),new cljs.core.Keyword(null,"js","js",1768080579)], null));
}
});
});
clojurescript.core.handle_result = (function clojurescript$core$handle_result(p__10903){
var map__10906 = p__10903;
var map__10906__$1 = ((((!((map__10906 == null)))?((((map__10906.cljs$lang$protocol_mask$partition0$ & (64))) || (map__10906.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__10906):map__10906);
var error = cljs.core.get.call(null,map__10906__$1,new cljs.core.Keyword(null,"error","error",-978969032));
var value = cljs.core.get.call(null,map__10906__$1,new cljs.core.Keyword(null,"value","value",305978217));
if(cljs.core.not.call(null,error)){
return value;
} else {
var cause = error.cause;
var description = error.description;
var number = error.number;
var fileName = error.fileName;
var lineNumber = error.lineNumber;
var columnNumber = error.columnNumber;
var stack = error.stack;
var message = new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [(cljs.core.truth_(cause)?cause:null),(cljs.core.truth_(description)?description:null),(cljs.core.truth_((function (){var and__4656__auto__ = fileName;
if(cljs.core.truth_(and__4656__auto__)){
var and__4656__auto____$1 = lineNumber;
if(cljs.core.truth_(and__4656__auto____$1)){
return columnNumber;
} else {
return and__4656__auto____$1;
}
} else {
return and__4656__auto__;
}
})())?[cljs.core.str(fileName),cljs.core.str(":"),cljs.core.str(lineNumber),cljs.core.str(","),cljs.core.str(columnNumber)].join(''):null),(cljs.core.truth_(stack)?stack:null)], null);
return console.error(clojure.string.join.call(null,"\n",cljs.core.remove.call(null,cljs.core.nil_QMARK_,message)));
}
});
clojurescript.core.eval = (function clojurescript$core$eval(in_str){
var src_paths = new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [".","./node_modules"], null);
return replumb.core.read_eval_call.call(null,cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"no-pr-str-on-value","no-pr-str-on-value",1045962546),true,new cljs.core.Keyword(null,"init-fn!","init-fn!",-986163042),replumb.nodejs.init_fn_BANG_], null),replumb.core.options.call(null,new cljs.core.Keyword(null,"node","node",581201198),clojurescript.core.make_load_fn.call(null,src_paths,((function (src_paths){
return (function (filename,source_cb){
return source_cb.call(null,(cljs.core.truth_(clojurescript.core.fs.existsSync(filename))?clojurescript.core.node_read_file_sync.call(null,filename):null));
});})(src_paths))
))),clojurescript.core.handle_result,in_str);
});
goog.exportSymbol('clojurescript.core.eval', clojurescript.core.eval);
clojurescript.core.compile = (function clojurescript$core$compile(in_str){
return cljs.js.compile_str.call(null,replumb.repl.st,in_str,"",replumb.repl.base_eval_opts_BANG_.call(null),clojurescript.core.handle_result);
});
goog.exportSymbol('clojurescript.core.compile', clojurescript.core.compile);
cljs.core._STAR_main_cli_fn_STAR_ = (function (){
return null;
});
