// Compiled by ClojureScript 1.10.597 {:target :nodejs}
goog.provide('npm_force_resolutions.core');
goog.require('cljs.core');
goog.require('cljs.nodejs');
goog.require('cljs_http.client');
goog.require('cljs.core.async');
goog.require('clojure.string');
goog.require('cognitect.transit');
npm_force_resolutions.core.node$module$xmlhttprequest = require('xmlhttprequest');
(XMLHttpRequest = npm_force_resolutions.core.node$module$xmlhttprequest.XMLHttpRequest);
npm_force_resolutions.core.node_slurp = (function npm_force_resolutions$core$node_slurp(path){
var fs = cljs.nodejs.require.call(null,"fs");
return fs.readFileSync(path,"utf8");
});
npm_force_resolutions.core.node_spit = (function npm_force_resolutions$core$node_spit(path,data){
var fs = cljs.nodejs.require.call(null,"fs");
return fs.writeFileSync(path,data);
});
npm_force_resolutions.core.read_json = (function npm_force_resolutions$core$read_json(path){
return cognitect.transit.read.call(null,cognitect.transit.reader.call(null,new cljs.core.Keyword(null,"json","json",1279968570)),clojure.string.replace.call(null,npm_force_resolutions.core.node_slurp.call(null,path),/\^/,"\\\\^"));
});
npm_force_resolutions.core.fetch_resolved_resolution = (function npm_force_resolutions$core$fetch_resolved_resolution(key,version){
var c__2985__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,(function (){
var f__2986__auto__ = (function (){var switch__2890__auto__ = (function (state_5211){
var state_val_5212 = (state_5211[(1)]);
if((state_val_5212 === (1))){
var inst_5194 = ["https://registry.npmjs.org/",cljs.core.str.cljs$core$IFn$_invoke$arity$1(key),"/",cljs.core.str.cljs$core$IFn$_invoke$arity$1(version)].join('');
var inst_5195 = cljs_http.client.get.call(null,inst_5194);
var state_5211__$1 = state_5211;
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_5211__$1,(2),inst_5195);
} else {
if((state_val_5212 === (2))){
var inst_5197 = (state_5211[(2)]);
var inst_5198 = cljs.core.PersistentVector.EMPTY_NODE;
var inst_5199 = [new cljs.core.Keyword(null,"body","body",-2049205669),new cljs.core.Keyword(null,"dist","dist",-1401837144)];
var inst_5200 = (new cljs.core.PersistentVector(null,2,(5),inst_5198,inst_5199,null));
var inst_5201 = cljs.core.get_in.call(null,inst_5197,inst_5200);
var inst_5202 = [key];
var inst_5203 = ["version","resolved","integrity"];
var inst_5204 = cljs.core.get.call(null,inst_5201,new cljs.core.Keyword(null,"tarball","tarball",697016887));
var inst_5205 = cljs.core.get.call(null,inst_5201,new cljs.core.Keyword(null,"integrity","integrity",-562947111));
var inst_5206 = [version,inst_5204,inst_5205];
var inst_5207 = cljs.core.PersistentHashMap.fromArrays(inst_5203,inst_5206);
var inst_5208 = [inst_5207];
var inst_5209 = cljs.core.PersistentHashMap.fromArrays(inst_5202,inst_5208);
var state_5211__$1 = state_5211;
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_5211__$1,inst_5209);
} else {
return null;
}
}
});
return (function() {
var npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2891__auto__ = null;
var npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2891__auto____0 = (function (){
var statearr_5213 = [null,null,null,null,null,null,null];
(statearr_5213[(0)] = npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2891__auto__);

(statearr_5213[(1)] = (1));

return statearr_5213;
});
var npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2891__auto____1 = (function (state_5211){
while(true){
var ret_value__2892__auto__ = (function (){try{while(true){
var result__2893__auto__ = switch__2890__auto__.call(null,state_5211);
if(cljs.core.keyword_identical_QMARK_.call(null,result__2893__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__2893__auto__;
}
break;
}
}catch (e5214){if((e5214 instanceof Object)){
var ex__2894__auto__ = e5214;
var statearr_5215_5217 = state_5211;
(statearr_5215_5217[(5)] = ex__2894__auto__);


cljs.core.async.impl.ioc_helpers.process_exception.call(null,state_5211);

return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
throw e5214;

}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__2892__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__5218 = state_5211;
state_5211 = G__5218;
continue;
} else {
return ret_value__2892__auto__;
}
break;
}
});
npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2891__auto__ = function(state_5211){
switch(arguments.length){
case 0:
return npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2891__auto____0.call(this);
case 1:
return npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2891__auto____1.call(this,state_5211);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2891__auto__.cljs$core$IFn$_invoke$arity$0 = npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2891__auto____0;
npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2891__auto__.cljs$core$IFn$_invoke$arity$1 = npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2891__auto____1;
return npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2891__auto__;
})()
})();
var state__2987__auto__ = (function (){var statearr_5216 = f__2986__auto__.call(null);
(statearr_5216[(6)] = c__2985__auto__);

return statearr_5216;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__2987__auto__);
}));

return c__2985__auto__;
});
npm_force_resolutions.core.wait_all = (function npm_force_resolutions$core$wait_all(callbacks){
var c__2985__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,(function (){
var f__2986__auto__ = (function (){var switch__2890__auto__ = (function (state_5237){
var state_val_5238 = (state_5237[(1)]);
if((state_val_5238 === (1))){
var inst_5219 = cljs.core.async.merge.call(null,callbacks);
var inst_5220 = cljs.core.PersistentHashMap.EMPTY;
var inst_5221 = inst_5220;
var state_5237__$1 = (function (){var statearr_5239 = state_5237;
(statearr_5239[(7)] = inst_5221);

(statearr_5239[(8)] = inst_5219);

return statearr_5239;
})();
var statearr_5240_5251 = state_5237__$1;
(statearr_5240_5251[(2)] = null);

(statearr_5240_5251[(1)] = (2));


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_5238 === (2))){
var inst_5221 = (state_5237[(7)]);
var inst_5223 = cljs.core.count.call(null,inst_5221);
var inst_5224 = cljs.core.count.call(null,callbacks);
var inst_5225 = cljs.core._EQ_.call(null,inst_5223,inst_5224);
var state_5237__$1 = state_5237;
if(inst_5225){
var statearr_5241_5252 = state_5237__$1;
(statearr_5241_5252[(1)] = (4));

} else {
var statearr_5242_5253 = state_5237__$1;
(statearr_5242_5253[(1)] = (5));

}

return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_5238 === (3))){
var inst_5235 = (state_5237[(2)]);
var state_5237__$1 = state_5237;
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_5237__$1,inst_5235);
} else {
if((state_val_5238 === (4))){
var inst_5221 = (state_5237[(7)]);
var state_5237__$1 = state_5237;
var statearr_5243_5254 = state_5237__$1;
(statearr_5243_5254[(2)] = inst_5221);

(statearr_5243_5254[(1)] = (6));


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_5238 === (5))){
var inst_5219 = (state_5237[(8)]);
var state_5237__$1 = state_5237;
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_5237__$1,(7),inst_5219);
} else {
if((state_val_5238 === (6))){
var inst_5233 = (state_5237[(2)]);
var state_5237__$1 = state_5237;
var statearr_5244_5255 = state_5237__$1;
(statearr_5244_5255[(2)] = inst_5233);

(statearr_5244_5255[(1)] = (3));


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_5238 === (7))){
var inst_5221 = (state_5237[(7)]);
var inst_5229 = (state_5237[(2)]);
var inst_5230 = cljs.core.merge.call(null,inst_5221,inst_5229);
var inst_5221__$1 = inst_5230;
var state_5237__$1 = (function (){var statearr_5245 = state_5237;
(statearr_5245[(7)] = inst_5221__$1);

return statearr_5245;
})();
var statearr_5246_5256 = state_5237__$1;
(statearr_5246_5256[(2)] = null);

(statearr_5246_5256[(1)] = (2));


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
return null;
}
}
}
}
}
}
}
});
return (function() {
var npm_force_resolutions$core$wait_all_$_state_machine__2891__auto__ = null;
var npm_force_resolutions$core$wait_all_$_state_machine__2891__auto____0 = (function (){
var statearr_5247 = [null,null,null,null,null,null,null,null,null];
(statearr_5247[(0)] = npm_force_resolutions$core$wait_all_$_state_machine__2891__auto__);

(statearr_5247[(1)] = (1));

return statearr_5247;
});
var npm_force_resolutions$core$wait_all_$_state_machine__2891__auto____1 = (function (state_5237){
while(true){
var ret_value__2892__auto__ = (function (){try{while(true){
var result__2893__auto__ = switch__2890__auto__.call(null,state_5237);
if(cljs.core.keyword_identical_QMARK_.call(null,result__2893__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__2893__auto__;
}
break;
}
}catch (e5248){if((e5248 instanceof Object)){
var ex__2894__auto__ = e5248;
var statearr_5249_5257 = state_5237;
(statearr_5249_5257[(5)] = ex__2894__auto__);


cljs.core.async.impl.ioc_helpers.process_exception.call(null,state_5237);

return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
throw e5248;

}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__2892__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__5258 = state_5237;
state_5237 = G__5258;
continue;
} else {
return ret_value__2892__auto__;
}
break;
}
});
npm_force_resolutions$core$wait_all_$_state_machine__2891__auto__ = function(state_5237){
switch(arguments.length){
case 0:
return npm_force_resolutions$core$wait_all_$_state_machine__2891__auto____0.call(this);
case 1:
return npm_force_resolutions$core$wait_all_$_state_machine__2891__auto____1.call(this,state_5237);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
npm_force_resolutions$core$wait_all_$_state_machine__2891__auto__.cljs$core$IFn$_invoke$arity$0 = npm_force_resolutions$core$wait_all_$_state_machine__2891__auto____0;
npm_force_resolutions$core$wait_all_$_state_machine__2891__auto__.cljs$core$IFn$_invoke$arity$1 = npm_force_resolutions$core$wait_all_$_state_machine__2891__auto____1;
return npm_force_resolutions$core$wait_all_$_state_machine__2891__auto__;
})()
})();
var state__2987__auto__ = (function (){var statearr_5250 = f__2986__auto__.call(null);
(statearr_5250[(6)] = c__2985__auto__);

return statearr_5250;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__2987__auto__);
}));

return c__2985__auto__;
});
npm_force_resolutions.core.find_resolutions = (function npm_force_resolutions$core$find_resolutions(folder){
var c__2985__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,(function (){
var f__2986__auto__ = (function (){var switch__2890__auto__ = (function (state_5285){
var state_val_5286 = (state_5285[(1)]);
if((state_val_5286 === (1))){
var inst_5262 = [cljs.core.str.cljs$core$IFn$_invoke$arity$1(folder),"/package.json"].join('');
var inst_5263 = npm_force_resolutions.core.read_json.call(null,inst_5262);
var inst_5264 = cljs.core.get.call(null,inst_5263,"resolutions");
var inst_5266 = (function (){var package_json = inst_5263;
var resolutions = inst_5264;
return (function (p__5265){
var vec__5287 = p__5265;
var k = cljs.core.nth.call(null,vec__5287,(0),null);
var v = cljs.core.nth.call(null,vec__5287,(1),null);
return npm_force_resolutions.core.fetch_resolved_resolution.call(null,k,v);
});
})();
var inst_5267 = cljs.core.seq.call(null,inst_5264);
var inst_5268 = cljs.core.map.call(null,inst_5266,inst_5267);
var inst_5269 = cljs.core.PersistentVector.EMPTY_NODE;
var inst_5270 = npm_force_resolutions.core.wait_all.call(null,inst_5268);
var inst_5271 = cljs.core.async.timeout.call(null,(8000));
var inst_5272 = [inst_5270,inst_5271];
var inst_5273 = (new cljs.core.PersistentVector(null,2,(5),inst_5269,inst_5272,null));
var state_5285__$1 = state_5285;
return cljs.core.async.ioc_alts_BANG_.call(null,state_5285__$1,(2),inst_5273);
} else {
if((state_val_5286 === (2))){
var inst_5276 = (state_5285[(7)]);
var inst_5275 = (state_5285[(2)]);
var inst_5276__$1 = cljs.core.nth.call(null,inst_5275,(0),null);
var inst_5277 = cljs.core.nth.call(null,inst_5275,(1),null);
var state_5285__$1 = (function (){var statearr_5290 = state_5285;
(statearr_5290[(8)] = inst_5277);

(statearr_5290[(7)] = inst_5276__$1);

return statearr_5290;
})();
if(cljs.core.truth_(inst_5276__$1)){
var statearr_5291_5299 = state_5285__$1;
(statearr_5291_5299[(1)] = (3));

} else {
var statearr_5292_5300 = state_5285__$1;
(statearr_5292_5300[(1)] = (4));

}

return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_5286 === (3))){
var inst_5276 = (state_5285[(7)]);
var state_5285__$1 = state_5285;
var statearr_5293_5301 = state_5285__$1;
(statearr_5293_5301[(2)] = inst_5276);

(statearr_5293_5301[(1)] = (5));


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_5286 === (4))){
var inst_5280 = (new Error("Timeout trying to fetch resolutions from npm"));
var inst_5281 = (function(){throw inst_5280})();
var state_5285__$1 = state_5285;
var statearr_5294_5302 = state_5285__$1;
(statearr_5294_5302[(2)] = inst_5281);

(statearr_5294_5302[(1)] = (5));


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_5286 === (5))){
var inst_5283 = (state_5285[(2)]);
var state_5285__$1 = state_5285;
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_5285__$1,inst_5283);
} else {
return null;
}
}
}
}
}
});
return (function() {
var npm_force_resolutions$core$find_resolutions_$_state_machine__2891__auto__ = null;
var npm_force_resolutions$core$find_resolutions_$_state_machine__2891__auto____0 = (function (){
var statearr_5295 = [null,null,null,null,null,null,null,null,null];
(statearr_5295[(0)] = npm_force_resolutions$core$find_resolutions_$_state_machine__2891__auto__);

(statearr_5295[(1)] = (1));

return statearr_5295;
});
var npm_force_resolutions$core$find_resolutions_$_state_machine__2891__auto____1 = (function (state_5285){
while(true){
var ret_value__2892__auto__ = (function (){try{while(true){
var result__2893__auto__ = switch__2890__auto__.call(null,state_5285);
if(cljs.core.keyword_identical_QMARK_.call(null,result__2893__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__2893__auto__;
}
break;
}
}catch (e5296){if((e5296 instanceof Object)){
var ex__2894__auto__ = e5296;
var statearr_5297_5303 = state_5285;
(statearr_5297_5303[(5)] = ex__2894__auto__);


cljs.core.async.impl.ioc_helpers.process_exception.call(null,state_5285);

return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
throw e5296;

}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__2892__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__5304 = state_5285;
state_5285 = G__5304;
continue;
} else {
return ret_value__2892__auto__;
}
break;
}
});
npm_force_resolutions$core$find_resolutions_$_state_machine__2891__auto__ = function(state_5285){
switch(arguments.length){
case 0:
return npm_force_resolutions$core$find_resolutions_$_state_machine__2891__auto____0.call(this);
case 1:
return npm_force_resolutions$core$find_resolutions_$_state_machine__2891__auto____1.call(this,state_5285);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
npm_force_resolutions$core$find_resolutions_$_state_machine__2891__auto__.cljs$core$IFn$_invoke$arity$0 = npm_force_resolutions$core$find_resolutions_$_state_machine__2891__auto____0;
npm_force_resolutions$core$find_resolutions_$_state_machine__2891__auto__.cljs$core$IFn$_invoke$arity$1 = npm_force_resolutions$core$find_resolutions_$_state_machine__2891__auto____1;
return npm_force_resolutions$core$find_resolutions_$_state_machine__2891__auto__;
})()
})();
var state__2987__auto__ = (function (){var statearr_5298 = f__2986__auto__.call(null);
(statearr_5298[(6)] = c__2985__auto__);

return statearr_5298;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__2987__auto__);
}));

return c__2985__auto__;
});
npm_force_resolutions.core.map_vals = (function npm_force_resolutions$core$map_vals(f,m){
return cljs.core.apply.call(null,cljs.core.merge,cljs.core.map.call(null,(function (p__5305){
var vec__5306 = p__5305;
var k = cljs.core.nth.call(null,vec__5306,(0),null);
var v = cljs.core.nth.call(null,vec__5306,(1),null);
return cljs.core.PersistentArrayMap.createAsIfByAssoc([k,f.call(null,k,v)]);
}),m));
});
npm_force_resolutions.core.update_on_requires = (function npm_force_resolutions$core$update_on_requires(resolutions,dependency){
return cljs.core.update.call(null,dependency,"requires",(function (requires){
return npm_force_resolutions.core.map_vals.call(null,(function (p1__5309_SHARP_,p2__5310_SHARP_){
return (function (key,version){
if(cljs.core.contains_QMARK_.call(null,resolutions,key)){
return cljs.core.get_in.call(null,resolutions,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [key,"version"], null));
} else {
return version;
}
}).call(null,p1__5309_SHARP_,p2__5310_SHARP_);
}),requires);
}));
});
npm_force_resolutions.core.add_dependencies = (function npm_force_resolutions$core$add_dependencies(resolutions,dependency){
var required_dependencies = cljs.core.keys.call(null,cljs.core.get.call(null,dependency,"requires"));
var new_deps = cljs.core.select_keys.call(null,resolutions,required_dependencies);
var dependencies = cljs.core.merge.call(null,new_deps,cljs.core.get.call(null,dependency,"dependencies",cljs.core.PersistentArrayMap.EMPTY));
return cljs.core.merge.call(null,dependency,new cljs.core.PersistentArrayMap(null, 1, ["dependencies",dependencies], null));
});
npm_force_resolutions.core.fix_existing_dependency = (function npm_force_resolutions$core$fix_existing_dependency(resolutions,key,dependency){
if(cljs.core.contains_QMARK_.call(null,resolutions,key)){
return cljs.core.conj.call(null,cljs.core.dissoc.call(null,dependency,"version","resolved","integrity","bundled"),cljs.core.get.call(null,resolutions,key));
} else {
return dependency;
}
});
npm_force_resolutions.core.order_map = (function npm_force_resolutions$core$order_map(target){
return cljs.core.into.call(null,cljs.core.sorted_map_by.call(null,(function (key1,key2){
return cljs.core.compare.call(null,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [key1], null),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [key2], null));
})),target);
});
npm_force_resolutions.core.sort_or_remove_map = (function npm_force_resolutions$core$sort_or_remove_map(key,dependency){
if(cljs.core.map_QMARK_.call(null,cljs.core.get.call(null,dependency,key))){
return cljs.core.update.call(null,dependency,key,npm_force_resolutions.core.order_map);
} else {
return cljs.core.dissoc.call(null,dependency,key);
}
});
npm_force_resolutions.core.patch_dependency = (function npm_force_resolutions$core$patch_dependency(resolutions,key,dependency){
if(cljs.core.contains_QMARK_.call(null,dependency,"requires")){
return npm_force_resolutions.core.sort_or_remove_map.call(null,"requires",npm_force_resolutions.core.sort_or_remove_map.call(null,"dependencies",npm_force_resolutions.core.patch_all_dependencies.call(null,resolutions,npm_force_resolutions.core.fix_existing_dependency.call(null,resolutions,key,npm_force_resolutions.core.update_on_requires.call(null,resolutions,npm_force_resolutions.core.add_dependencies.call(null,resolutions,dependency))))));
} else {
return npm_force_resolutions.core.fix_existing_dependency.call(null,resolutions,key,dependency);
}
});
npm_force_resolutions.core.patch_all_dependencies = (function npm_force_resolutions$core$patch_all_dependencies(resolutions,package_lock){
return cljs.core.update.call(null,package_lock,"dependencies",(function (dependencies){
return npm_force_resolutions.core.map_vals.call(null,(function (p1__5311_SHARP_,p2__5312_SHARP_){
return npm_force_resolutions.core.patch_dependency.call(null,resolutions,p1__5311_SHARP_,p2__5312_SHARP_);
}),dependencies);
}));
});
npm_force_resolutions.core.update_package_lock = (function npm_force_resolutions$core$update_package_lock(folder){
var c__2985__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,(function (){
var f__2986__auto__ = (function (){var switch__2890__auto__ = (function (state_5321){
var state_val_5322 = (state_5321[(1)]);
if((state_val_5322 === (1))){
var inst_5313 = [cljs.core.str.cljs$core$IFn$_invoke$arity$1(folder),"/package-lock.json"].join('');
var inst_5314 = npm_force_resolutions.core.read_json.call(null,inst_5313);
var inst_5315 = npm_force_resolutions.core.find_resolutions.call(null,folder);
var state_5321__$1 = (function (){var statearr_5323 = state_5321;
(statearr_5323[(7)] = inst_5314);

return statearr_5323;
})();
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_5321__$1,(2),inst_5315);
} else {
if((state_val_5322 === (2))){
var inst_5314 = (state_5321[(7)]);
var inst_5317 = (state_5321[(2)]);
var inst_5318 = npm_force_resolutions.core.patch_all_dependencies.call(null,inst_5317,inst_5314);
var inst_5319 = npm_force_resolutions.core.sort_or_remove_map.call(null,"dependencies",inst_5318);
var state_5321__$1 = state_5321;
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_5321__$1,inst_5319);
} else {
return null;
}
}
});
return (function() {
var npm_force_resolutions$core$update_package_lock_$_state_machine__2891__auto__ = null;
var npm_force_resolutions$core$update_package_lock_$_state_machine__2891__auto____0 = (function (){
var statearr_5324 = [null,null,null,null,null,null,null,null];
(statearr_5324[(0)] = npm_force_resolutions$core$update_package_lock_$_state_machine__2891__auto__);

(statearr_5324[(1)] = (1));

return statearr_5324;
});
var npm_force_resolutions$core$update_package_lock_$_state_machine__2891__auto____1 = (function (state_5321){
while(true){
var ret_value__2892__auto__ = (function (){try{while(true){
var result__2893__auto__ = switch__2890__auto__.call(null,state_5321);
if(cljs.core.keyword_identical_QMARK_.call(null,result__2893__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__2893__auto__;
}
break;
}
}catch (e5325){if((e5325 instanceof Object)){
var ex__2894__auto__ = e5325;
var statearr_5326_5328 = state_5321;
(statearr_5326_5328[(5)] = ex__2894__auto__);


cljs.core.async.impl.ioc_helpers.process_exception.call(null,state_5321);

return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
throw e5325;

}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__2892__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__5329 = state_5321;
state_5321 = G__5329;
continue;
} else {
return ret_value__2892__auto__;
}
break;
}
});
npm_force_resolutions$core$update_package_lock_$_state_machine__2891__auto__ = function(state_5321){
switch(arguments.length){
case 0:
return npm_force_resolutions$core$update_package_lock_$_state_machine__2891__auto____0.call(this);
case 1:
return npm_force_resolutions$core$update_package_lock_$_state_machine__2891__auto____1.call(this,state_5321);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
npm_force_resolutions$core$update_package_lock_$_state_machine__2891__auto__.cljs$core$IFn$_invoke$arity$0 = npm_force_resolutions$core$update_package_lock_$_state_machine__2891__auto____0;
npm_force_resolutions$core$update_package_lock_$_state_machine__2891__auto__.cljs$core$IFn$_invoke$arity$1 = npm_force_resolutions$core$update_package_lock_$_state_machine__2891__auto____1;
return npm_force_resolutions$core$update_package_lock_$_state_machine__2891__auto__;
})()
})();
var state__2987__auto__ = (function (){var statearr_5327 = f__2986__auto__.call(null);
(statearr_5327[(6)] = c__2985__auto__);

return statearr_5327;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__2987__auto__);
}));

return c__2985__auto__;
});
npm_force_resolutions.core.indent_json = (function npm_force_resolutions$core$indent_json(json){
var json_format = cljs.nodejs.require.call(null,"json-format");
return clojure.string.replace.call(null,clojure.string.replace.call(null,json_format.call(null,JSON.parse(json),(function (){var obj5331 = ({"type":"space","size":(2)});
return obj5331;
})()),/\\\\\^/,"^"),/ +\n/,"");
});
npm_force_resolutions.core.main = (function npm_force_resolutions$core$main(var_args){
var args__4795__auto__ = [];
var len__4789__auto___5359 = arguments.length;
var i__4790__auto___5360 = (0);
while(true){
if((i__4790__auto___5360 < len__4789__auto___5359)){
args__4795__auto__.push((arguments[i__4790__auto___5360]));

var G__5361 = (i__4790__auto___5360 + (1));
i__4790__auto___5360 = G__5361;
continue;
} else {
}
break;
}

var argseq__4796__auto__ = ((((0) < args__4795__auto__.length))?(new cljs.core.IndexedSeq(args__4795__auto__.slice((0)),(0),null)):null);
return npm_force_resolutions.core.main.cljs$core$IFn$_invoke$arity$variadic(argseq__4796__auto__);
});

(npm_force_resolutions.core.main.cljs$core$IFn$_invoke$arity$variadic = (function (args){
var c__2985__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,(function (){
var f__2986__auto__ = (function (){var switch__2890__auto__ = (function (state_5347){
var state_val_5348 = (state_5347[(1)]);
if((state_val_5348 === (1))){
var inst_5333 = (state_5347[(7)]);
var inst_5333__$1 = cljs.core.first.call(null,args);
var state_5347__$1 = (function (){var statearr_5349 = state_5347;
(statearr_5349[(7)] = inst_5333__$1);

return statearr_5349;
})();
if(cljs.core.truth_(inst_5333__$1)){
var statearr_5350_5362 = state_5347__$1;
(statearr_5350_5362[(1)] = (2));

} else {
var statearr_5351_5363 = state_5347__$1;
(statearr_5351_5363[(1)] = (3));

}

return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_5348 === (2))){
var inst_5333 = (state_5347[(7)]);
var state_5347__$1 = state_5347;
var statearr_5352_5364 = state_5347__$1;
(statearr_5352_5364[(2)] = inst_5333);

(statearr_5352_5364[(1)] = (4));


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_5348 === (3))){
var state_5347__$1 = state_5347;
var statearr_5353_5365 = state_5347__$1;
(statearr_5353_5365[(2)] = ".");

(statearr_5353_5365[(1)] = (4));


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_5348 === (4))){
var inst_5337 = (state_5347[(8)]);
var inst_5337__$1 = (state_5347[(2)]);
var inst_5338 = npm_force_resolutions.core.update_package_lock.call(null,inst_5337__$1);
var state_5347__$1 = (function (){var statearr_5354 = state_5347;
(statearr_5354[(8)] = inst_5337__$1);

return statearr_5354;
})();
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_5347__$1,(5),inst_5338);
} else {
if((state_val_5348 === (5))){
var inst_5337 = (state_5347[(8)]);
var inst_5340 = (state_5347[(2)]);
var inst_5341 = cognitect.transit.writer.call(null,new cljs.core.Keyword(null,"json-verbose","json-verbose",-542533531));
var inst_5342 = cognitect.transit.write.call(null,inst_5341,inst_5340);
var inst_5343 = [cljs.core.str.cljs$core$IFn$_invoke$arity$1(inst_5337),"/package-lock.json"].join('');
var inst_5344 = npm_force_resolutions.core.indent_json.call(null,inst_5342);
var inst_5345 = npm_force_resolutions.core.node_spit.call(null,inst_5343,inst_5344);
var state_5347__$1 = state_5347;
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_5347__$1,inst_5345);
} else {
return null;
}
}
}
}
}
});
return (function() {
var npm_force_resolutions$core$state_machine__2891__auto__ = null;
var npm_force_resolutions$core$state_machine__2891__auto____0 = (function (){
var statearr_5355 = [null,null,null,null,null,null,null,null,null];
(statearr_5355[(0)] = npm_force_resolutions$core$state_machine__2891__auto__);

(statearr_5355[(1)] = (1));

return statearr_5355;
});
var npm_force_resolutions$core$state_machine__2891__auto____1 = (function (state_5347){
while(true){
var ret_value__2892__auto__ = (function (){try{while(true){
var result__2893__auto__ = switch__2890__auto__.call(null,state_5347);
if(cljs.core.keyword_identical_QMARK_.call(null,result__2893__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__2893__auto__;
}
break;
}
}catch (e5356){if((e5356 instanceof Object)){
var ex__2894__auto__ = e5356;
var statearr_5357_5366 = state_5347;
(statearr_5357_5366[(5)] = ex__2894__auto__);


cljs.core.async.impl.ioc_helpers.process_exception.call(null,state_5347);

return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
throw e5356;

}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__2892__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__5367 = state_5347;
state_5347 = G__5367;
continue;
} else {
return ret_value__2892__auto__;
}
break;
}
});
npm_force_resolutions$core$state_machine__2891__auto__ = function(state_5347){
switch(arguments.length){
case 0:
return npm_force_resolutions$core$state_machine__2891__auto____0.call(this);
case 1:
return npm_force_resolutions$core$state_machine__2891__auto____1.call(this,state_5347);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
npm_force_resolutions$core$state_machine__2891__auto__.cljs$core$IFn$_invoke$arity$0 = npm_force_resolutions$core$state_machine__2891__auto____0;
npm_force_resolutions$core$state_machine__2891__auto__.cljs$core$IFn$_invoke$arity$1 = npm_force_resolutions$core$state_machine__2891__auto____1;
return npm_force_resolutions$core$state_machine__2891__auto__;
})()
})();
var state__2987__auto__ = (function (){var statearr_5358 = f__2986__auto__.call(null);
(statearr_5358[(6)] = c__2985__auto__);

return statearr_5358;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__2987__auto__);
}));

return c__2985__auto__;
}));

(npm_force_resolutions.core.main.cljs$lang$maxFixedArity = (0));

/** @this {Function} */
(npm_force_resolutions.core.main.cljs$lang$applyTo = (function (seq5332){
var self__4777__auto__ = this;
return self__4777__auto__.cljs$core$IFn$_invoke$arity$variadic(cljs.core.seq.call(null,seq5332));
}));

(cljs.core._STAR_main_cli_fn_STAR_ = npm_force_resolutions.core.main);

//# sourceMappingURL=core.js.map
