// Compiled by ClojureScript 0.0-2138
goog.provide('lt.objs.sidebar.navigate');
goog.require('cljs.core');
goog.require('crate.binding');
goog.require('lt.objs.thread');
goog.require('lt.objs.sidebar.command');
goog.require('lt.objs.files');
goog.require('lt.objs.opener');
goog.require('lt.util.dom');
goog.require('lt.objs.sidebar');
goog.require('lt.objs.context');
goog.require('crate.core');
goog.require('lt.objs.workspace');
goog.require('lt.objs.context');
goog.require('lt.objs.notifos');
goog.require('lt.objs.notifos');
goog.require('lt.objs.workspace');
goog.require('lt.util.dom');
goog.require('lt.objs.sidebar');
goog.require('lt.objs.files');
goog.require('lt.objs.opener');
goog.require('lt.util.load');
goog.require('crate.binding');
goog.require('lt.objs.keyboard');
goog.require('lt.object');
goog.require('lt.object');
goog.require('lt.util.load');
goog.require('crate.core');
goog.require('lt.objs.sidebar.command');
goog.require('lt.objs.keyboard');
lt.objs.sidebar.navigate.file_filters = (function file_filters(f){return cljs.core.re_seq.call(null,lt.objs.files.ignore_pattern,f);
});
lt.objs.sidebar.navigate.populate_bg = lt.objs.thread.thread_STAR_.call(null,(function tfun12709(){var orig__3398__auto__ = argsArray(arguments);var msg__3399__auto__ = orig__3398__auto__.shift();var args__3400__auto__ = orig__3398__auto__.map(cljs.reader.read_string);var raise = ((function (orig__3398__auto__,msg__3399__auto__,args__3400__auto__){
return (function (obj__3401__auto__,k__3402__auto__,v__3403__auto__){return _send(obj__3401__auto__,k__3402__auto__,cljs.core.pr_str.call(null,v__3403__auto__),"clj");
});})(orig__3398__auto__,msg__3399__auto__,args__3400__auto__))
;args__3400__auto__.unshift(msg__3399__auto__.obj);
return (function (obj_id,p__12718){var map__12719 = p__12718;var map__12719__$1 = ((cljs.core.seq_QMARK_.call(null,map__12719))?cljs.core.apply.call(null,cljs.core.hash_map,map__12719):map__12719);var ws = cljs.core.get.call(null,map__12719__$1,new cljs.core.Keyword(null,"ws","ws",1013908046));var pattern = cljs.core.get.call(null,map__12719__$1,new cljs.core.Keyword(null,"pattern","pattern",4517781250));var lim = cljs.core.get.call(null,map__12719__$1,new cljs.core.Keyword(null,"lim","lim",1014011394));var fs = require("fs");var fpath = require("path");var walkdir = require([cljs.core.str(ltpath),cljs.core.str("/core/node_modules/lighttable/background/walkdir2.js")].join(''));var grab_files = ((function (fs,fpath,walkdir){
return (function (all_files,folder){var root_length = (cljs.core.count.call(null,fpath.dirname(folder)) + 1);var walked = walkdir.call(null,folder,(function (){var obj12721 = {"filter":(new RegExp(pattern)),"limit":lim};return obj12721;
})());return all_files.concat(walked.paths.map(((function (root_length,walked,fs,fpath,walkdir){
return (function (p1__12707_SHARP_){var obj12723 = {"full":p1__12707_SHARP_,"rel":cljs.core.subs.call(null,p1__12707_SHARP_,root_length)};return obj12723;
});})(root_length,walked,fs,fpath,walkdir))
));
});})(fs,fpath,walkdir))
;var all_files = cljs.core.to_array.call(null,new cljs.core.Keyword(null,"folders","folders",4625622327).cljs$core$IFn$_invoke$arity$1(ws)).reduce(grab_files,[]);var other_files = cljs.core.to_array.call(null,new cljs.core.Keyword(null,"files","files",1111338473).cljs$core$IFn$_invoke$arity$1(ws)).map(((function (fs,fpath,walkdir,grab_files,all_files){
return (function (p1__12708_SHARP_){var obj12725 = {"full":p1__12708_SHARP_,"rel":fpath.basename(p1__12708_SHARP_)};return obj12725;
});})(fs,fpath,walkdir,grab_files,all_files))
);var final$ = all_files.concat(other_files);return _send(obj_id,new cljs.core.Keyword(null,"workspace-files","workspace-files",2894015153),final$);
}).apply(null,args__3400__auto__);
}));
lt.objs.sidebar.navigate.__BEH__workspace_files = (function __BEH__workspace_files(this$,files){lt.object.merge_BANG_.call(null,this$,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"files","files",1111338473),cljs.core.js__GT_clj.call(null,files,new cljs.core.Keyword(null,"keywordize-keys","keywordize-keys",4191781672),true)], null));
return lt.object.raise.call(null,new cljs.core.Keyword(null,"filter-list","filter-list",4372522309).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,this$)),new cljs.core.Keyword(null,"refresh!","refresh!",4597922840));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.sidebar.navigate","workspace-files","lt.objs.sidebar.navigate/workspace-files",1473144805),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.sidebar.navigate.__BEH__workspace_files,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"workspace-files","workspace-files",2894015153),null], null), null));
lt.objs.sidebar.navigate.__BEH__populate_on_ws_update = (function __BEH__populate_on_ws_update(ws){return lt.objs.sidebar.navigate.populate_bg.call(null,lt.objs.sidebar.navigate.sidebar_navigate,new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"lim","lim",1014011394),(new cljs.core.Keyword(null,"file-limit","file-limit",1720007580).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,lt.objs.sidebar.navigate.sidebar_navigate)) - 1),new cljs.core.Keyword(null,"pattern","pattern",4517781250),lt.objs.files.ignore_pattern.source,new cljs.core.Keyword(null,"ws","ws",1013908046),lt.objs.workspace.serialize.call(null,cljs.core.deref.call(null,ws))], null));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.sidebar.navigate","populate-on-ws-update","lt.objs.sidebar.navigate/populate-on-ws-update",3590833365),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.sidebar.navigate.__BEH__populate_on_ws_update,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"refresh","refresh",2099349069),null,new cljs.core.Keyword(null,"updated","updated",779473965),null], null), null),new cljs.core.Keyword(null,"debounce","debounce",1556599227),150);
lt.objs.sidebar.navigate.__BEH__watched__DOT__create = (function __BEH__watched__DOT__create(ws,path){if(cljs.core.truth_(lt.objs.sidebar.navigate.file_filters.call(null,lt.objs.files.basename.call(null,path))))
{return null;
} else
{var ws_parent = lt.objs.files.parent.call(null,cljs.core.first.call(null,cljs.core.filter.call(null,(function (p1__12726_SHARP_){return cljs.core._EQ_.call(null,0,path.indexOf(p1__12726_SHARP_));
}),new cljs.core.Keyword(null,"folders","folders",4625622327).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,ws)))));var rel_length = (cljs.core.count.call(null,ws_parent) + 1);lt.object.update_BANG_.call(null,lt.objs.sidebar.navigate.sidebar_navigate,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"files","files",1111338473)], null),cljs.core.conj,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"full","full",1017058817),path,new cljs.core.Keyword(null,"rel","rel",1014017035),cljs.core.subs.call(null,path,rel_length)], null));
return lt.object.raise.call(null,new cljs.core.Keyword(null,"filter-list","filter-list",4372522309).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,lt.objs.sidebar.navigate.sidebar_navigate)),new cljs.core.Keyword(null,"refresh!","refresh!",4597922840));
}
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.sidebar.navigate","watched.create","lt.objs.sidebar.navigate/watched.create",3621776872),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.sidebar.navigate.__BEH__watched__DOT__create,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"watched.create","watched.create",749519022),null], null), null));
lt.objs.sidebar.navigate.__BEH__watched__DOT__delete = (function __BEH__watched__DOT__delete(ws,path){lt.object.update_BANG_.call(null,lt.objs.sidebar.navigate.sidebar_navigate,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"files","files",1111338473)], null),(function (p1__12727_SHARP_){return cljs.core.remove.call(null,(function (x){return cljs.core._EQ_.call(null,0,new cljs.core.Keyword(null,"full","full",1017058817).cljs$core$IFn$_invoke$arity$1(x).indexOf(path));
}),p1__12727_SHARP_);
}));
return lt.object.raise.call(null,new cljs.core.Keyword(null,"filter-list","filter-list",4372522309).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,lt.objs.sidebar.navigate.sidebar_navigate)),new cljs.core.Keyword(null,"refresh!","refresh!",4597922840));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.sidebar.navigate","watched.delete","lt.objs.sidebar.navigate/watched.delete",3638485561),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.sidebar.navigate.__BEH__watched__DOT__delete,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"watched.delete","watched.delete",766354781),null], null), null));
lt.objs.sidebar.navigate.__BEH__focus_BANG_ = (function __BEH__focus_BANG_(this$){return lt.object.raise.call(null,new cljs.core.Keyword(null,"filter-list","filter-list",4372522309).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,this$)),new cljs.core.Keyword(null,"focus!","focus!",4039653819));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.sidebar.navigate","focus!","lt.objs.sidebar.navigate/focus!",4622481627),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.sidebar.navigate.__BEH__focus_BANG_,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"focus!","focus!",4039653819),null], null), null));
lt.objs.sidebar.navigate.__BEH__focus_on_show = (function __BEH__focus_on_show(this$){return lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"focus!","focus!",4039653819));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.sidebar.navigate","focus-on-show","lt.objs.sidebar.navigate/focus-on-show",2752811662),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.sidebar.navigate.__BEH__focus_on_show,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"show","show",1017433711),null], null), null));
lt.objs.sidebar.navigate.__BEH__open_on_select = (function __BEH__open_on_select(this$,cur){return lt.object.raise.call(null,lt.objs.opener.opener,new cljs.core.Keyword(null,"open!","open!",1119852169),new cljs.core.Keyword(null,"full","full",1017058817).cljs$core$IFn$_invoke$arity$1(cur));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.sidebar.navigate","open-on-select","lt.objs.sidebar.navigate/open-on-select",2251841341),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.sidebar.navigate.__BEH__open_on_select,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"select","select",4402849902),null], null), null));
lt.objs.sidebar.navigate.__BEH__escape_BANG_ = (function __BEH__escape_BANG_(this$){lt.objs.sidebar.command.exec_BANG_.call(null,new cljs.core.Keyword(null,"escape-navigate","escape-navigate",1610448047));
return lt.objs.sidebar.command.exec_BANG_.call(null,new cljs.core.Keyword(null,"focus-last-editor","focus-last-editor",3007568513));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.sidebar.navigate","escape!","lt.objs.sidebar.navigate/escape!",527020132),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.sidebar.navigate.__BEH__escape_BANG_,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"escape!","escape!",3844244274),null], null), null));
lt.objs.sidebar.navigate.__BEH__pop_transient_on_select = (function __BEH__pop_transient_on_select(this$){return lt.object.raise.call(null,lt.objs.sidebar.rightbar,new cljs.core.Keyword(null,"close!","close!",3951350939));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.sidebar.navigate","pop-transient-on-select","lt.objs.sidebar.navigate/pop-transient-on-select",3084691449),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.sidebar.navigate.__BEH__pop_transient_on_select,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"selected","selected",2205476365),null], null), null));
lt.objs.sidebar.navigate.__BEH__set_file_limit = (function __BEH__set_file_limit(this$,n){return lt.object.merge_BANG_.call(null,this$,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"file-limit","file-limit",1720007580),n], null));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.sidebar.navigate","set-file-limit","lt.objs.sidebar.navigate/set-file-limit",1656879311),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.sidebar.navigate.__BEH__set_file_limit,new cljs.core.Keyword(null,"desc","desc",1016984067),"Navigate: set maximum number of indexed files",new cljs.core.Keyword(null,"params","params",4313443576),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"label","label",1116631654),"Number",new cljs.core.Keyword(null,"example","example",3985900764),8000], null)], null),new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"object.instant","object.instant",773332388),null], null), null),new cljs.core.Keyword(null,"type","type",1017479852),new cljs.core.Keyword(null,"user","user",1017503549));
lt.object.object_STAR_.call(null,new cljs.core.Keyword("lt.objs.sidebar.navigate","sidebar.navigate","lt.objs.sidebar.navigate/sidebar.navigate",4211647585),new cljs.core.Keyword(null,"tags","tags",1017456523),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"navigator","navigator",1766727113),null], null), null),new cljs.core.Keyword(null,"label","label",1116631654),"navigate",new cljs.core.Keyword(null,"order","order",1119910592),-3,new cljs.core.Keyword(null,"selected","selected",2205476365),0,new cljs.core.Keyword(null,"files","files",1111338473),cljs.core.PersistentVector.EMPTY,new cljs.core.Keyword(null,"file-limit","file-limit",1720007580),8000,new cljs.core.Keyword(null,"search","search",4402534682),"",new cljs.core.Keyword(null,"init","init",1017141378),(function (this$){var list = lt.objs.sidebar.command.filter_list.call(null,new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"key","key",1014010321),new cljs.core.Keyword(null,"rel","rel",1014017035),new cljs.core.Keyword(null,"transform","transform",2066570974),(function (p1__12728_SHARP_,p2__12730_SHARP_,p3__12729_SHARP_){return [cljs.core.str("<h2>"),cljs.core.str(lt.objs.files.basename.call(null,p1__12728_SHARP_)),cljs.core.str("</h2><p>"),cljs.core.str(p3__12729_SHARP_),cljs.core.str("</p>")].join('');
}),new cljs.core.Keyword(null,"items","items",1114430258),crate.binding.subatom.call(null,this$,new cljs.core.Keyword(null,"files","files",1111338473)),new cljs.core.Keyword(null,"placeholder","placeholder",1612151013),"file"], null));lt.object.add_tags.call(null,list,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"navigate.selector","navigate.selector",4592755502)], null));
lt.object.merge_BANG_.call(null,this$,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"filter-list","filter-list",4372522309),list], null));
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"div.navigate","div.navigate",4481120672),lt.object.__GT_content.call(null,list)], null);
}));
lt.objs.sidebar.navigate.sidebar_navigate = lt.object.create.call(null,new cljs.core.Keyword("lt.objs.sidebar.navigate","sidebar.navigate","lt.objs.sidebar.navigate/sidebar.navigate",4211647585));
lt.objs.sidebar.add_item.call(null,lt.objs.sidebar.rightbar,lt.objs.sidebar.navigate.sidebar_navigate);
lt.objs.sidebar.command.command.call(null,new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"command","command",1964298941),new cljs.core.Keyword(null,"navigate-workspace","navigate-workspace",3310481067),new cljs.core.Keyword(null,"desc","desc",1016984067),"Navigate: open navigate",new cljs.core.Keyword(null,"exec","exec",1017031683),(function (){return lt.object.raise.call(null,lt.objs.sidebar.rightbar,new cljs.core.Keyword(null,"toggle","toggle",4440567494),lt.objs.sidebar.navigate.sidebar_navigate,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"transient?","transient?",3584270951),false], null));
})], null));
lt.objs.sidebar.command.command.call(null,new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"command","command",1964298941),new cljs.core.Keyword(null,"navigate-workspace-transient","navigate-workspace-transient",615022696),new cljs.core.Keyword(null,"desc","desc",1016984067),"Navigate: open navigate transient",new cljs.core.Keyword(null,"hidden","hidden",4091384092),true,new cljs.core.Keyword(null,"exec","exec",1017031683),(function (){return lt.object.raise.call(null,lt.objs.sidebar.rightbar,new cljs.core.Keyword(null,"toggle","toggle",4440567494),lt.objs.sidebar.navigate.sidebar_navigate,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"transient?","transient?",3584270951),true], null));
})], null));
lt.objs.sidebar.command.command.call(null,new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"command","command",1964298941),new cljs.core.Keyword(null,"escape-navigate","escape-navigate",1610448047),new cljs.core.Keyword(null,"desc","desc",1016984067),"Navigate: exit navigate",new cljs.core.Keyword(null,"hidden","hidden",4091384092),true,new cljs.core.Keyword(null,"exec","exec",1017031683),(function (){lt.objs.sidebar.command.exec_BANG_.call(null,new cljs.core.Keyword(null,"close-sidebar","close-sidebar",1108494329));
return lt.objs.sidebar.command.exec_BANG_.call(null,new cljs.core.Keyword(null,"focus-last-editor","focus-last-editor",3007568513));
})], null));
