// Compiled by ClojureScript 0.0-2138
goog.provide('lt.objs.workspace');
goog.require('cljs.core');
goog.require('lt.util.js');
goog.require('lt.util.cljs');
goog.require('lt.objs.app');
goog.require('lt.objs.files');
goog.require('lt.util.js');
goog.require('lt.objs.cache');
goog.require('cljs.reader');
goog.require('lt.objs.notifos');
goog.require('lt.objs.notifos');
goog.require('lt.util.cljs');
goog.require('lt.objs.command');
goog.require('lt.objs.files');
goog.require('lt.objs.app');
goog.require('lt.util.load');
goog.require('lt.object');
goog.require('cljs.reader');
goog.require('lt.object');
goog.require('lt.util.load');
goog.require('lt.objs.console');
goog.require('lt.objs.console');
goog.require('lt.objs.cache');
goog.require('lt.objs.command');
lt.objs.workspace.fs = require("fs");
lt.objs.workspace.max_depth = 10;
lt.objs.workspace.watch_interval = 1000;
lt.object.object_STAR_.call(null,new cljs.core.Keyword("lt.objs.workspace","workspace","lt.objs.workspace/workspace",619438026),new cljs.core.Keyword(null,"tags","tags",1017456523),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"workspace","workspace",2122768391),null], null), null),new cljs.core.Keyword(null,"files","files",1111338473),cljs.core.PersistentVector.EMPTY,new cljs.core.Keyword(null,"folders","folders",4625622327),cljs.core.PersistentVector.EMPTY,new cljs.core.Keyword(null,"watches","watches",2139868463),cljs.core.PersistentArrayMap.EMPTY,new cljs.core.Keyword(null,"ws-behaviors","ws-behaviors",2339346978),"",new cljs.core.Keyword(null,"init","init",1017141378),(function (this$){return null;
}));
lt.objs.workspace.current_ws = lt.object.create.call(null,new cljs.core.Keyword("lt.objs.workspace","workspace","lt.objs.workspace/workspace",619438026));
lt.objs.workspace.unwatch = (function unwatch(watches,path,recursive_QMARK_){if(cljs.core.truth_(watches))
{var removes = ((cljs.core.coll_QMARK_.call(null,path))?path:((cljs.core.not.call(null,recursive_QMARK_))?new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [path], null):((new cljs.core.Keyword(null,"else","else",1017020587))?cljs.core.filter.call(null,(function (p1__14282_SHARP_){return (p1__14282_SHARP_.indexOf(path) > -1);
}),cljs.core.keys.call(null,watches)):null)));var seq__14289_14295 = cljs.core.seq.call(null,cljs.core.map.call(null,watches,removes));var chunk__14291_14296 = null;var count__14292_14297 = 0;var i__14293_14298 = 0;while(true){
if((i__14293_14298 < count__14292_14297))
{var r_14299 = cljs.core._nth.call(null,chunk__14291_14296,i__14293_14298);if(cljs.core.truth_((function (){var and__3508__auto__ = r_14299;if(cljs.core.truth_(and__3508__auto__))
{return new cljs.core.Keyword(null,"close","close",1108660586).cljs$core$IFn$_invoke$arity$1(r_14299);
} else
{return and__3508__auto__;
}
})()))
{new cljs.core.Keyword(null,"close","close",1108660586).cljs$core$IFn$_invoke$arity$1(r_14299).call(null);
{
var G__14300 = seq__14289_14295;
var G__14301 = chunk__14291_14296;
var G__14302 = count__14292_14297;
var G__14303 = (i__14293_14298 + 1);
seq__14289_14295 = G__14300;
chunk__14291_14296 = G__14301;
count__14292_14297 = G__14302;
i__14293_14298 = G__14303;
continue;
}
} else
{{
var G__14304 = seq__14289_14295;
var G__14305 = chunk__14291_14296;
var G__14306 = count__14292_14297;
var G__14307 = (i__14293_14298 + 1);
seq__14289_14295 = G__14304;
chunk__14291_14296 = G__14305;
count__14292_14297 = G__14306;
i__14293_14298 = G__14307;
continue;
}
}
} else
{var temp__4092__auto___14308 = cljs.core.seq.call(null,seq__14289_14295);if(temp__4092__auto___14308)
{var seq__14289_14309__$1 = temp__4092__auto___14308;if(cljs.core.chunked_seq_QMARK_.call(null,seq__14289_14309__$1))
{var c__4262__auto___14310 = cljs.core.chunk_first.call(null,seq__14289_14309__$1);{
var G__14311 = cljs.core.chunk_rest.call(null,seq__14289_14309__$1);
var G__14312 = c__4262__auto___14310;
var G__14313 = cljs.core.count.call(null,c__4262__auto___14310);
var G__14314 = 0;
seq__14289_14295 = G__14311;
chunk__14291_14296 = G__14312;
count__14292_14297 = G__14313;
i__14293_14298 = G__14314;
continue;
}
} else
{var r_14315 = cljs.core.first.call(null,seq__14289_14309__$1);if(cljs.core.truth_((function (){var and__3508__auto__ = r_14315;if(cljs.core.truth_(and__3508__auto__))
{return new cljs.core.Keyword(null,"close","close",1108660586).cljs$core$IFn$_invoke$arity$1(r_14315);
} else
{return and__3508__auto__;
}
})()))
{new cljs.core.Keyword(null,"close","close",1108660586).cljs$core$IFn$_invoke$arity$1(r_14315).call(null);
{
var G__14316 = cljs.core.next.call(null,seq__14289_14309__$1);
var G__14317 = null;
var G__14318 = 0;
var G__14319 = 0;
seq__14289_14295 = G__14316;
chunk__14291_14296 = G__14317;
count__14292_14297 = G__14318;
i__14293_14298 = G__14319;
continue;
}
} else
{{
var G__14320 = cljs.core.next.call(null,seq__14289_14309__$1);
var G__14321 = null;
var G__14322 = 0;
var G__14323 = 0;
seq__14289_14295 = G__14320;
chunk__14291_14296 = G__14321;
count__14292_14297 = G__14322;
i__14293_14298 = G__14323;
continue;
}
}
}
} else
{}
}
break;
}
return cljs.core.apply.call(null,cljs.core.dissoc,watches,removes);
} else
{return null;
}
});
lt.objs.workspace.unwatch_BANG_ = (function() {
var unwatch_BANG_ = null;
var unwatch_BANG___1 = (function (path){return unwatch_BANG_.call(null,path,false);
});
var unwatch_BANG___2 = (function (path,recursive_QMARK_){return lt.object.merge_BANG_.call(null,lt.objs.workspace.current_ws,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"watches","watches",2139868463),lt.objs.workspace.unwatch.call(null,new cljs.core.Keyword(null,"watches","watches",2139868463).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,lt.objs.workspace.current_ws)),path,recursive_QMARK_)], null));
});
unwatch_BANG_ = function(path,recursive_QMARK_){
switch(arguments.length){
case 1:
return unwatch_BANG___1.call(this,path);
case 2:
return unwatch_BANG___2.call(this,path,recursive_QMARK_);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
unwatch_BANG_.cljs$core$IFn$_invoke$arity$1 = unwatch_BANG___1;
unwatch_BANG_.cljs$core$IFn$_invoke$arity$2 = unwatch_BANG___2;
return unwatch_BANG_;
})()
;
lt.objs.workspace.alert_file = (function alert_file(path){return (function (cur,prev){if(cljs.core.truth_(lt.objs.workspace.fs.existsSync(path)))
{return lt.object.raise.call(null,lt.objs.workspace.current_ws,new cljs.core.Keyword(null,"watched.update","watched.update",1262966907),path,cur);
} else
{lt.objs.workspace.unwatch_BANG_.call(null,path);
return lt.object.raise.call(null,lt.objs.workspace.current_ws,new cljs.core.Keyword(null,"watched.delete","watched.delete",766354781),path);
}
});
});
lt.objs.workspace.file__GT_watch = (function file__GT_watch(path){var alert = lt.objs.workspace.alert_file.call(null,path);return new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"path","path",1017337751),path,new cljs.core.Keyword(null,"alert","alert",1106803918),alert,new cljs.core.Keyword(null,"close","close",1108660586),(function (){return lt.objs.workspace.fs.unwatchFile(path,alert);
})], null);
});
lt.objs.workspace.watch_BANG_ = (function() {
var watch_BANG_ = null;
var watch_BANG___1 = (function (path){return watch_BANG_.call(null,cljs.core.transient$.call(null,cljs.core.PersistentArrayMap.EMPTY),path,null);
});
var watch_BANG___2 = (function (path,recursive_QMARK_){return watch_BANG_.call(null,cljs.core.transient$.call(null,cljs.core.PersistentArrayMap.EMPTY),path,recursive_QMARK_);
});
var watch_BANG___3 = (function (results,path,recursive_QMARK_){var seq__14336_14348 = cljs.core.seq.call(null,((cljs.core.coll_QMARK_.call(null,path))?path:new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [path], null)));var chunk__14337_14349 = null;var count__14338_14350 = 0;var i__14339_14351 = 0;while(true){
if((i__14339_14351 < count__14338_14350))
{var path_14352__$1 = cljs.core._nth.call(null,chunk__14337_14349,i__14339_14351);if(cljs.core.truth_(cljs.core.re_seq.call(null,lt.objs.files.ignore_pattern,path_14352__$1)))
{} else
{if(cljs.core.truth_(lt.objs.files.dir_QMARK_.call(null,path_14352__$1)))
{var recursive_QMARK__14353__$1 = ((cljs.core.not.call(null,recursive_QMARK_))?0:((typeof recursive_QMARK_ === 'number')?(recursive_QMARK_ - 1):((new cljs.core.Keyword(null,"else","else",1017020587))?lt.objs.workspace.max_depth:null)));var watch_14354 = lt.objs.workspace.folder__GT_watch.call(null,path_14352__$1);if(cljs.core.truth_(cljs.core.get.call(null,new cljs.core.Keyword(null,"watches","watches",2139868463).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,lt.objs.workspace.current_ws)),path_14352__$1)))
{} else
{cljs.core.assoc_BANG_.call(null,results,path_14352__$1,watch_14354);
lt.objs.workspace.fs.watchFile(path_14352__$1,(function (){var obj14341 = {"interval":lt.objs.workspace.watch_interval,"persistent":false};return obj14341;
})(),new cljs.core.Keyword(null,"alert","alert",1106803918).cljs$core$IFn$_invoke$arity$1(watch_14354));
}
if((recursive_QMARK__14353__$1 > -1))
{watch_BANG_.call(null,results,lt.objs.files.full_path_ls.call(null,path_14352__$1),recursive_QMARK__14353__$1);
} else
{}
} else
{if((cljs.core.not.call(null,cljs.core.get.call(null,new cljs.core.Keyword(null,"watches","watches",2139868463).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,lt.objs.workspace.current_ws)),path_14352__$1))) && (cljs.core.not.call(null,cljs.core.get.call(null,results,path_14352__$1))))
{var watch_14355 = lt.objs.workspace.file__GT_watch.call(null,path_14352__$1);cljs.core.assoc_BANG_.call(null,results,path_14352__$1,watch_14355);
lt.objs.workspace.fs.watchFile(path_14352__$1,(function (){var obj14343 = {"interval":lt.objs.workspace.watch_interval,"persistent":false};return obj14343;
})(),new cljs.core.Keyword(null,"alert","alert",1106803918).cljs$core$IFn$_invoke$arity$1(watch_14355));
} else
{}
}
}
{
var G__14356 = seq__14336_14348;
var G__14357 = chunk__14337_14349;
var G__14358 = count__14338_14350;
var G__14359 = (i__14339_14351 + 1);
seq__14336_14348 = G__14356;
chunk__14337_14349 = G__14357;
count__14338_14350 = G__14358;
i__14339_14351 = G__14359;
continue;
}
} else
{var temp__4092__auto___14360 = cljs.core.seq.call(null,seq__14336_14348);if(temp__4092__auto___14360)
{var seq__14336_14361__$1 = temp__4092__auto___14360;if(cljs.core.chunked_seq_QMARK_.call(null,seq__14336_14361__$1))
{var c__4262__auto___14362 = cljs.core.chunk_first.call(null,seq__14336_14361__$1);{
var G__14363 = cljs.core.chunk_rest.call(null,seq__14336_14361__$1);
var G__14364 = c__4262__auto___14362;
var G__14365 = cljs.core.count.call(null,c__4262__auto___14362);
var G__14366 = 0;
seq__14336_14348 = G__14363;
chunk__14337_14349 = G__14364;
count__14338_14350 = G__14365;
i__14339_14351 = G__14366;
continue;
}
} else
{var path_14367__$1 = cljs.core.first.call(null,seq__14336_14361__$1);if(cljs.core.truth_(cljs.core.re_seq.call(null,lt.objs.files.ignore_pattern,path_14367__$1)))
{} else
{if(cljs.core.truth_(lt.objs.files.dir_QMARK_.call(null,path_14367__$1)))
{var recursive_QMARK__14368__$1 = ((cljs.core.not.call(null,recursive_QMARK_))?0:((typeof recursive_QMARK_ === 'number')?(recursive_QMARK_ - 1):((new cljs.core.Keyword(null,"else","else",1017020587))?lt.objs.workspace.max_depth:null)));var watch_14369 = lt.objs.workspace.folder__GT_watch.call(null,path_14367__$1);if(cljs.core.truth_(cljs.core.get.call(null,new cljs.core.Keyword(null,"watches","watches",2139868463).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,lt.objs.workspace.current_ws)),path_14367__$1)))
{} else
{cljs.core.assoc_BANG_.call(null,results,path_14367__$1,watch_14369);
lt.objs.workspace.fs.watchFile(path_14367__$1,(function (){var obj14345 = {"interval":lt.objs.workspace.watch_interval,"persistent":false};return obj14345;
})(),new cljs.core.Keyword(null,"alert","alert",1106803918).cljs$core$IFn$_invoke$arity$1(watch_14369));
}
if((recursive_QMARK__14368__$1 > -1))
{watch_BANG_.call(null,results,lt.objs.files.full_path_ls.call(null,path_14367__$1),recursive_QMARK__14368__$1);
} else
{}
} else
{if((cljs.core.not.call(null,cljs.core.get.call(null,new cljs.core.Keyword(null,"watches","watches",2139868463).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,lt.objs.workspace.current_ws)),path_14367__$1))) && (cljs.core.not.call(null,cljs.core.get.call(null,results,path_14367__$1))))
{var watch_14370 = lt.objs.workspace.file__GT_watch.call(null,path_14367__$1);cljs.core.assoc_BANG_.call(null,results,path_14367__$1,watch_14370);
lt.objs.workspace.fs.watchFile(path_14367__$1,(function (){var obj14347 = {"interval":lt.objs.workspace.watch_interval,"persistent":false};return obj14347;
})(),new cljs.core.Keyword(null,"alert","alert",1106803918).cljs$core$IFn$_invoke$arity$1(watch_14370));
} else
{}
}
}
{
var G__14371 = cljs.core.next.call(null,seq__14336_14361__$1);
var G__14372 = null;
var G__14373 = 0;
var G__14374 = 0;
seq__14336_14348 = G__14371;
chunk__14337_14349 = G__14372;
count__14338_14350 = G__14373;
i__14339_14351 = G__14374;
continue;
}
}
} else
{}
}
break;
}
if(typeof recursive_QMARK_ === 'number')
{return null;
} else
{return lt.object.update_BANG_.call(null,lt.objs.workspace.current_ws,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"watches","watches",2139868463)], null),cljs.core.merge,cljs.core.persistent_BANG_.call(null,results));
}
});
watch_BANG_ = function(results,path,recursive_QMARK_){
switch(arguments.length){
case 1:
return watch_BANG___1.call(this,results);
case 2:
return watch_BANG___2.call(this,results,path);
case 3:
return watch_BANG___3.call(this,results,path,recursive_QMARK_);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
watch_BANG_.cljs$core$IFn$_invoke$arity$1 = watch_BANG___1;
watch_BANG_.cljs$core$IFn$_invoke$arity$2 = watch_BANG___2;
watch_BANG_.cljs$core$IFn$_invoke$arity$3 = watch_BANG___3;
return watch_BANG_;
})()
;
lt.objs.workspace.alert_folder = (function alert_folder(path){return (function (cur,prev){if(cljs.core.truth_(lt.objs.workspace.fs.existsSync(path)))
{var watches = new cljs.core.Keyword(null,"watches","watches",2139868463).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,lt.objs.workspace.current_ws));var neue = cljs.core.first.call(null,cljs.core.filter.call(null,((function (watches){
return (function (p1__14375_SHARP_){return (cljs.core.not.call(null,cljs.core.get.call(null,watches,p1__14375_SHARP_))) && (cljs.core.not.call(null,cljs.core.re_seq.call(null,lt.objs.files.ignore_pattern,p1__14375_SHARP_)));
});})(watches))
,lt.objs.files.full_path_ls.call(null,path)));if(cljs.core.truth_(neue))
{lt.objs.workspace.watch_BANG_.call(null,neue);
return lt.object.raise.call(null,lt.objs.workspace.current_ws,new cljs.core.Keyword(null,"watched.create","watched.create",749519022),neue,lt.objs.workspace.fs.statSync(neue));
} else
{return null;
}
} else
{lt.objs.workspace.unwatch_BANG_.call(null,path,new cljs.core.Keyword(null,"recursive","recursive",2179684260));
return lt.object.raise.call(null,lt.objs.workspace.current_ws,new cljs.core.Keyword(null,"watched.delete","watched.delete",766354781),path);
}
});
});
lt.objs.workspace.folder__GT_watch = (function folder__GT_watch(path){var alert = lt.objs.workspace.alert_folder.call(null,path);return new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"path","path",1017337751),path,new cljs.core.Keyword(null,"alert","alert",1106803918),alert,new cljs.core.Keyword(null,"close","close",1108660586),(function (){return lt.objs.workspace.fs.unwatchFile(path,alert);
})], null);
});
lt.objs.workspace.stop_watching = (function stop_watching(ws){return lt.objs.workspace.unwatch_BANG_.call(null,cljs.core.keys.call(null,new cljs.core.Keyword(null,"watches","watches",2139868463).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,ws))));
});
lt.objs.workspace.watch_workspace = (function watch_workspace(ws){lt.objs.workspace.stop_watching.call(null,ws);
return lt.objs.workspace.watch_BANG_.call(null,lt.object.raise_reduce.call(null,ws,new cljs.core.Keyword(null,"watch-paths+","watch-paths+",2265407277),cljs.core.PersistentVector.EMPTY));
});
lt.objs.workspace.workspace_cache_path = lt.objs.files.join.call(null,lt.objs.cache.cache_path,"workspace");
lt.objs.workspace.files_and_folders = (function files_and_folders(path){return cljs.core.reduce.call(null,(function (res,cur){var dir_QMARK_ = lt.objs.files.dir_QMARK_.call(null,cur);if(cljs.core.truth_(cljs.core.re_seq.call(null,lt.objs.files.ignore_pattern,[cljs.core.str(lt.objs.files.basename.call(null,cur)),cljs.core.str((cljs.core.truth_(dir_QMARK_)?lt.objs.files.separator:null))].join(''))))
{return res;
} else
{if(cljs.core.truth_(dir_QMARK_))
{return cljs.core.update_in.call(null,res,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"folders","folders",4625622327)], null),cljs.core.conj,cur);
} else
{return cljs.core.update_in.call(null,res,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"files","files",1111338473)], null),cljs.core.conj,cur);
}
}
}),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"folders","folders",4625622327),cljs.core.PersistentVector.EMPTY,new cljs.core.Keyword(null,"files","files",1111338473),cljs.core.PersistentVector.EMPTY], null),lt.objs.files.full_path_ls.call(null,path));
});
lt.objs.workspace.serialize = (function serialize(ws){return cljs.core.select_keys.call(null,ws,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"files","files",1111338473),new cljs.core.Keyword(null,"folders","folders",4625622327),new cljs.core.Keyword(null,"ws-behaviors","ws-behaviors",2339346978)], null));
});
lt.objs.workspace.reconstitute = (function reconstitute(ws,v){return lt.object.raise.call(null,ws,new cljs.core.Keyword(null,"set!","set!",1017430897),new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"files","files",1111338473),new cljs.core.Keyword(null,"files","files",1111338473).cljs$core$IFn$_invoke$arity$1(v),new cljs.core.Keyword(null,"folders","folders",4625622327),cljs.core.filter.call(null,lt.objs.files.exists_QMARK_,new cljs.core.Keyword(null,"folders","folders",4625622327).cljs$core$IFn$_invoke$arity$1(v)),new cljs.core.Keyword(null,"ws-behaviors","ws-behaviors",2339346978),new cljs.core.Keyword(null,"ws-behaviors","ws-behaviors",2339346978).cljs$core$IFn$_invoke$arity$1(v)], null));
});
lt.objs.workspace.add_BANG_ = (function add_BANG_(ws,k,v){return lt.object.update_BANG_.call(null,ws,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [k], null),cljs.core.conj,v);
});
lt.objs.workspace.remove_BANG_ = (function remove_BANG_(ws,k,v){return lt.object.update_BANG_.call(null,ws,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [k], null),(function (p1__14376_SHARP_){return cljs.core.vec.call(null,cljs.core.remove.call(null,cljs.core.PersistentHashSet.fromArray([v], true),p1__14376_SHARP_));
}));
});
lt.objs.workspace.new_cached_file = (function new_cached_file(){return [cljs.core.str(lt.util.js.now.call(null)),cljs.core.str(".clj")].join('');
});
lt.objs.workspace.file__GT_ws = (function file__GT_ws(file){return cljs.core.assoc.call(null,cljs.reader.read_string.call(null,new cljs.core.Keyword(null,"content","content",1965434859).cljs$core$IFn$_invoke$arity$1(lt.objs.files.open_sync.call(null,file))),new cljs.core.Keyword(null,"path","path",1017337751),file);
});
lt.objs.workspace.save = (function save(ws,file){lt.objs.files.save.call(null,lt.objs.files.join.call(null,lt.objs.workspace.workspace_cache_path,file),cljs.core.pr_str.call(null,lt.objs.workspace.serialize.call(null,cljs.core.deref.call(null,ws))));
return lt.object.raise.call(null,ws,new cljs.core.Keyword(null,"save","save",1017427183));
});
lt.objs.workspace.open = (function open(ws,file){var loc = ((!((file.indexOf(lt.objs.files.separator) > -1)))?lt.objs.files.join.call(null,lt.objs.workspace.workspace_cache_path,file):file);lt.object.merge_BANG_.call(null,ws,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"file","file",1017047278),lt.objs.workspace.new_cached_file.call(null)], null));
try{lt.objs.workspace.reconstitute.call(null,ws,lt.objs.workspace.file__GT_ws.call(null,loc));
lt.objs.workspace.save.call(null,ws,new cljs.core.Keyword(null,"file","file",1017047278).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,ws)));
return lt.objs.files.delete_BANG_.call(null,loc);
}catch (e14378){var e = e14378;return lt.objs.console.error.call(null,e);
}});
lt.objs.workspace.cached = (function cached(){return cljs.core.filter.call(null,(function (p1__14379_SHARP_){return (p1__14379_SHARP_.indexOf(".clj") > -1);
}),lt.objs.files.full_path_ls.call(null,lt.objs.workspace.workspace_cache_path));
});
lt.objs.workspace.all = (function all(){var fs = cljs.core.sort.call(null,cljs.core._GT_,lt.objs.workspace.cached.call(null));var seq__14384_14388 = cljs.core.seq.call(null,cljs.core.drop.call(null,20,fs));var chunk__14385_14389 = null;var count__14386_14390 = 0;var i__14387_14391 = 0;while(true){
if((i__14387_14391 < count__14386_14390))
{var file_14392 = cljs.core._nth.call(null,chunk__14385_14389,i__14387_14391);lt.objs.files.delete_BANG_.call(null,file_14392);
{
var G__14393 = seq__14384_14388;
var G__14394 = chunk__14385_14389;
var G__14395 = count__14386_14390;
var G__14396 = (i__14387_14391 + 1);
seq__14384_14388 = G__14393;
chunk__14385_14389 = G__14394;
count__14386_14390 = G__14395;
i__14387_14391 = G__14396;
continue;
}
} else
{var temp__4092__auto___14397 = cljs.core.seq.call(null,seq__14384_14388);if(temp__4092__auto___14397)
{var seq__14384_14398__$1 = temp__4092__auto___14397;if(cljs.core.chunked_seq_QMARK_.call(null,seq__14384_14398__$1))
{var c__4262__auto___14399 = cljs.core.chunk_first.call(null,seq__14384_14398__$1);{
var G__14400 = cljs.core.chunk_rest.call(null,seq__14384_14398__$1);
var G__14401 = c__4262__auto___14399;
var G__14402 = cljs.core.count.call(null,c__4262__auto___14399);
var G__14403 = 0;
seq__14384_14388 = G__14400;
chunk__14385_14389 = G__14401;
count__14386_14390 = G__14402;
i__14387_14391 = G__14403;
continue;
}
} else
{var file_14404 = cljs.core.first.call(null,seq__14384_14398__$1);lt.objs.files.delete_BANG_.call(null,file_14404);
{
var G__14405 = cljs.core.next.call(null,seq__14384_14398__$1);
var G__14406 = null;
var G__14407 = 0;
var G__14408 = 0;
seq__14384_14388 = G__14405;
chunk__14385_14389 = G__14406;
count__14386_14390 = G__14407;
i__14387_14391 = G__14408;
continue;
}
}
} else
{}
}
break;
}
return cljs.core.map.call(null,lt.objs.workspace.file__GT_ws,cljs.core.take.call(null,20,fs));
});
lt.objs.workspace.ws_empty_QMARK_ = (function ws_empty_QMARK_(ws){return !((cljs.core.seq.call(null,new cljs.core.Keyword(null,"files","files",1111338473).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,ws)))) || (cljs.core.seq.call(null,new cljs.core.Keyword(null,"folders","folders",4625622327).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,ws)))));
});
lt.objs.workspace.__BEH__serialize_workspace = (function __BEH__serialize_workspace(this$){if(cljs.core.truth_(cljs.core.deref.call(null,this$).call(null,new cljs.core.Keyword(null,"file","file",1017047278))))
{} else
{lt.object.merge_BANG_.call(null,this$,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"file","file",1017047278),lt.objs.workspace.new_cached_file.call(null)], null));
}
if(cljs.core.truth_((function (){var and__3508__auto__ = cljs.core.deref.call(null,this$).call(null,new cljs.core.Keyword(null,"initialized?","initialized?",613820253));if(cljs.core.truth_(and__3508__auto__))
{return !(lt.objs.workspace.ws_empty_QMARK_.call(null,this$));
} else
{return and__3508__auto__;
}
})()))
{return lt.objs.workspace.save.call(null,this$,new cljs.core.Keyword(null,"file","file",1017047278).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,this$)));
} else
{return null;
}
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.workspace","serialize-workspace","lt.objs.workspace/serialize-workspace",966599259),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.workspace.__BEH__serialize_workspace,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"serialize!","serialize!",4710885555),null,new cljs.core.Keyword(null,"updated","updated",779473965),null], null), null));
lt.objs.workspace.__BEH__reconstitute_last_workspace = (function __BEH__reconstitute_last_workspace(app){if((lt.objs.app.first_window_QMARK_.call(null)) && (cljs.core.not.call(null,new cljs.core.Keyword(null,"initialized","initialized",2247924294).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,lt.objs.workspace.current_ws)))))
{var temp__4092__auto___14409 = cljs.core.first.call(null,lt.objs.workspace.all.call(null));if(cljs.core.truth_(temp__4092__auto___14409))
{var ws_14410 = temp__4092__auto___14409;lt.objs.workspace.open.call(null,lt.objs.workspace.current_ws,lt.objs.files.basename.call(null,new cljs.core.Keyword(null,"path","path",1017337751).cljs$core$IFn$_invoke$arity$1(ws_14410)));
} else
{}
} else
{}
return lt.object.merge_BANG_.call(null,lt.objs.workspace.current_ws,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"initialized?","initialized?",613820253),true], null));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.workspace","reconstitute-last-workspace","lt.objs.workspace/reconstitute-last-workspace",3568425507),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.workspace.__BEH__reconstitute_last_workspace,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"post-init","post-init",2970371471),null], null), null));
lt.objs.workspace.__BEH__new_BANG_ = (function __BEH__new_BANG_(this$){lt.object.merge_BANG_.call(null,this$,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"file","file",1017047278),lt.objs.workspace.new_cached_file.call(null)], null));
return lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"clear!","clear!",3951036134));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.workspace","new!","lt.objs.workspace/new!",1591819718),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.workspace.__BEH__new_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,"new!","new!",1017282035),null], null), null));
lt.objs.workspace.__BEH__add_file_BANG_ = (function __BEH__add_file_BANG_(this$,f){if(!(cljs.core.contains_QMARK_.call(null,cljs.core.set.call(null,new cljs.core.Keyword(null,"files","files",1111338473).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,this$))),f)))
{lt.objs.workspace.add_BANG_.call(null,this$,new cljs.core.Keyword(null,"files","files",1111338473),f);
lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"add","add",1014000659),f);
return lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"updated","updated",779473965));
} else
{return lt.objs.notifos.set_msg_BANG_.call(null,"This file is already in your workspace.",new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"class","class",1108647146),"error"], null));
}
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.workspace","add-file!","lt.objs.workspace/add-file!",2702786158),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.workspace.__BEH__add_file_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,"add.file!","add.file!",4237252106),null], null), null));
lt.objs.workspace.__BEH__add_folder_BANG_ = (function __BEH__add_folder_BANG_(this$,f){if(!(cljs.core.contains_QMARK_.call(null,cljs.core.set.call(null,new cljs.core.Keyword(null,"folders","folders",4625622327).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,this$))),f)))
{lt.objs.workspace.add_BANG_.call(null,this$,new cljs.core.Keyword(null,"folders","folders",4625622327),f);
lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"add","add",1014000659),f);
return lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"updated","updated",779473965));
} else
{return lt.objs.notifos.set_msg_BANG_.call(null,"This folder is already in your workspace.",new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"class","class",1108647146),"error"], null));
}
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.workspace","add-folder!","lt.objs.workspace/add-folder!",3399790716),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.workspace.__BEH__add_folder_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,"add.folder!","add.folder!",2151595160),null], null), null));
lt.objs.workspace.__BEH__remove_file_BANG_ = (function __BEH__remove_file_BANG_(this$,f){lt.objs.workspace.remove_BANG_.call(null,this$,new cljs.core.Keyword(null,"files","files",1111338473),f);
lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"remove","remove",4374260726),f);
return lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"updated","updated",779473965));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.workspace","remove-file!","lt.objs.workspace/remove-file!",4736710351),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.workspace.__BEH__remove_file_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,"remove.file!","remove.file!",3382976429),null], null), null));
lt.objs.workspace.__BEH__remove_folder_BANG_ = (function __BEH__remove_folder_BANG_(this$,f){lt.objs.workspace.remove_BANG_.call(null,this$,new cljs.core.Keyword(null,"folders","folders",4625622327),f);
lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"remove","remove",4374260726),f);
return lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"updated","updated",779473965));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.workspace","remove-folder!","lt.objs.workspace/remove-folder!",2848800157),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.workspace.__BEH__remove_folder_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,"remove.folder!","remove.folder!",1531423099),null], null), null));
lt.objs.workspace.__BEH__rename_BANG_ = (function __BEH__rename_BANG_(this$,f,neue){var key = (cljs.core.truth_(lt.objs.files.file_QMARK_.call(null,f))?new cljs.core.Keyword(null,"files","files",1111338473):new cljs.core.Keyword(null,"folders","folders",4625622327));lt.objs.workspace.remove_BANG_.call(null,this$,key,f);
lt.objs.workspace.add_BANG_.call(null,this$,key,neue);
lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"rename","rename",4374276784),f,neue);
return lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"updated","updated",779473965));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.workspace","rename!","lt.objs.workspace/rename!",535270440),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.workspace.__BEH__rename_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,"rename!","rename!",2106237973),null], null), null));
lt.objs.workspace.__BEH__clear_BANG_ = (function __BEH__clear_BANG_(this$){var old = cljs.core.deref.call(null,this$);lt.object.merge_BANG_.call(null,this$,new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"files","files",1111338473),cljs.core.PersistentVector.EMPTY,new cljs.core.Keyword(null,"folders","folders",4625622327),cljs.core.PersistentVector.EMPTY,new cljs.core.Keyword(null,"ws-behaviors","ws-behaviors",2339346978),""], null));
lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"set","set",1014018004),old);
return lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"updated","updated",779473965));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.workspace","clear!","lt.objs.workspace/clear!",2982360823),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.workspace.__BEH__clear_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,"clear!","clear!",3951036134),null], null), null));
lt.objs.workspace.__BEH__set_BANG_ = (function __BEH__set_BANG_(this$,fs){var old = cljs.core.deref.call(null,this$);lt.object.merge_BANG_.call(null,this$,fs);
lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"set","set",1014018004),old);
return lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"updated","updated",779473965));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.workspace","set!","lt.objs.workspace/set!",1594750020),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.workspace.__BEH__set_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,"set!","set!",1017430897),null], null), null));
lt.objs.workspace.__BEH__watch_on_set = (function __BEH__watch_on_set(this$){return lt.objs.workspace.watch_workspace.call(null,this$);
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.workspace","watch-on-set","lt.objs.workspace/watch-on-set",1548262069),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.workspace.__BEH__watch_on_set,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"set","set",1014018004),null], null), null));
lt.objs.workspace.__BEH__stop_watch_on_close = (function __BEH__stop_watch_on_close(app){return lt.objs.workspace.stop_watching.call(null,lt.objs.workspace.current_ws);
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.workspace","stop-watch-on-close","lt.objs.workspace/stop-watch-on-close",2718554488),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.workspace.__BEH__stop_watch_on_close,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"close","close",1108660586),null,new cljs.core.Keyword(null,"refresh","refresh",2099349069),null], null), null));
lt.objs.workspace.__BEH__init_workspace_cache_dir = (function __BEH__init_workspace_cache_dir(app){if(cljs.core.truth_(lt.objs.files.exists_QMARK_.call(null,lt.objs.workspace.workspace_cache_path)))
{return null;
} else
{return lt.objs.files.mkdir.call(null,lt.objs.workspace.workspace_cache_path);
}
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.workspace","init-workspace-cache-dir","lt.objs.workspace/init-workspace-cache-dir",1768943762),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.workspace.__BEH__init_workspace_cache_dir,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"init","init",1017141378),null], null), null));
lt.objs.command.command.call(null,new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"command","command",1964298941),new cljs.core.Keyword(null,"workspace.new","workspace.new",2700812345),new cljs.core.Keyword(null,"desc","desc",1016984067),"Workspace: Create new workspace",new cljs.core.Keyword(null,"exec","exec",1017031683),(function (){return lt.object.raise.call(null,lt.objs.workspace.current_ws,new cljs.core.Keyword(null,"new!","new!",1017282035));
})], null));
