// 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');
npm_force_resolutions.core.node$module$child_process = require('child_process');
(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.build_dependency_from_dist = (function npm_force_resolutions$core$build_dependency_from_dist(version,dist){
var tarball = cljs.core.get.call(null,dist,new cljs.core.Keyword(null,"tarball","tarball",697016887));
var integrity = cljs.core.get.call(null,dist,new cljs.core.Keyword(null,"integrity","integrity",-562947111));
var shasum = cljs.core.get.call(null,dist,new cljs.core.Keyword(null,"shasum","shasum",-2133358208));
if(cljs.core.truth_(integrity)){
return new cljs.core.PersistentArrayMap(null, 3, ["version",version,"resolved",tarball,"integrity",integrity], null);
} else {
if(cljs.core.truth_(shasum)){
return new cljs.core.PersistentArrayMap(null, 3, ["version",version,"resolved",tarball,"integrity",["sha1-",cljs.core.str.cljs$core$IFn$_invoke$arity$1(Buffer.from(shasum,"hex").toString("base64"))].join('')], null);
} else {
return new cljs.core.PersistentArrayMap(null, 1, ["version",version], null);
}
}
});
npm_force_resolutions.core.fetch_resolved_resolution = (function npm_force_resolutions$core$fetch_resolved_resolution(registry_url,key,version){
var c__2167__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,(function (){
var f__2168__auto__ = (function (){var switch__2144__auto__ = (function (state_2268){
var state_val_2269 = (state_2268[(1)]);
if((state_val_2269 === (1))){
var inst_2245 = cljs.core.re_find.call(null,/^\d/,version);
var state_2268__$1 = state_2268;
if(cljs.core.truth_(inst_2245)){
var statearr_2270_2278 = state_2268__$1;
(statearr_2270_2278[(1)] = (2));

} else {
var statearr_2271_2279 = state_2268__$1;
(statearr_2271_2279[(1)] = (3));

}

return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_2269 === (2))){
var inst_2247 = [cljs.core.str.cljs$core$IFn$_invoke$arity$1(registry_url),cljs.core.str.cljs$core$IFn$_invoke$arity$1(key),"/",cljs.core.str.cljs$core$IFn$_invoke$arity$1(version)].join('');
var inst_2248 = cljs_http.client.get.call(null,inst_2247);
var state_2268__$1 = state_2268;
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_2268__$1,(5),inst_2248);
} else {
if((state_val_2269 === (3))){
var inst_2260 = [key];
var inst_2261 = cljs.core.PersistentHashMap.EMPTY;
var inst_2262 = npm_force_resolutions.core.build_dependency_from_dist.call(null,version,inst_2261);
var inst_2263 = [inst_2262];
var inst_2264 = cljs.core.PersistentHashMap.fromArrays(inst_2260,inst_2263);
var state_2268__$1 = state_2268;
var statearr_2272_2280 = state_2268__$1;
(statearr_2272_2280[(2)] = inst_2264);

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


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_2269 === (4))){
var inst_2266 = (state_2268[(2)]);
var state_2268__$1 = state_2268;
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_2268__$1,inst_2266);
} else {
if((state_val_2269 === (5))){
var inst_2250 = (state_2268[(2)]);
var inst_2251 = cljs.core.PersistentVector.EMPTY_NODE;
var inst_2252 = [new cljs.core.Keyword(null,"body","body",-2049205669),new cljs.core.Keyword(null,"dist","dist",-1401837144)];
var inst_2253 = (new cljs.core.PersistentVector(null,2,(5),inst_2251,inst_2252,null));
var inst_2254 = cljs.core.get_in.call(null,inst_2250,inst_2253);
var inst_2255 = [key];
var inst_2256 = npm_force_resolutions.core.build_dependency_from_dist.call(null,version,inst_2254);
var inst_2257 = [inst_2256];
var inst_2258 = cljs.core.PersistentHashMap.fromArrays(inst_2255,inst_2257);
var state_2268__$1 = state_2268;
var statearr_2273_2281 = state_2268__$1;
(statearr_2273_2281[(2)] = inst_2258);

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


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
return null;
}
}
}
}
}
});
return (function() {
var npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2145__auto__ = null;
var npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2145__auto____0 = (function (){
var statearr_2274 = [null,null,null,null,null,null,null];
(statearr_2274[(0)] = npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2145__auto__);

(statearr_2274[(1)] = (1));

return statearr_2274;
});
var npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2145__auto____1 = (function (state_2268){
while(true){
var ret_value__2146__auto__ = (function (){try{while(true){
var result__2147__auto__ = switch__2144__auto__.call(null,state_2268);
if(cljs.core.keyword_identical_QMARK_.call(null,result__2147__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__2147__auto__;
}
break;
}
}catch (e2275){if((e2275 instanceof Object)){
var ex__2148__auto__ = e2275;
var statearr_2276_2282 = state_2268;
(statearr_2276_2282[(5)] = ex__2148__auto__);


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

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

}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__2146__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__2283 = state_2268;
state_2268 = G__2283;
continue;
} else {
return ret_value__2146__auto__;
}
break;
}
});
npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2145__auto__ = function(state_2268){
switch(arguments.length){
case 0:
return npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2145__auto____0.call(this);
case 1:
return npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2145__auto____1.call(this,state_2268);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2145__auto__.cljs$core$IFn$_invoke$arity$0 = npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2145__auto____0;
npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2145__auto__.cljs$core$IFn$_invoke$arity$1 = npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2145__auto____1;
return npm_force_resolutions$core$fetch_resolved_resolution_$_state_machine__2145__auto__;
})()
})();
var state__2169__auto__ = (function (){var statearr_2277 = f__2168__auto__.call(null);
(statearr_2277[(6)] = c__2167__auto__);

return statearr_2277;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__2169__auto__);
}));

return c__2167__auto__;
});
npm_force_resolutions.core.wait_all = (function npm_force_resolutions$core$wait_all(callbacks){
var c__2167__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,(function (){
var f__2168__auto__ = (function (){var switch__2144__auto__ = (function (state_2302){
var state_val_2303 = (state_2302[(1)]);
if((state_val_2303 === (1))){
var inst_2284 = cljs.core.async.merge.call(null,callbacks);
var inst_2285 = cljs.core.PersistentHashMap.EMPTY;
var inst_2286 = inst_2285;
var state_2302__$1 = (function (){var statearr_2304 = state_2302;
(statearr_2304[(7)] = inst_2284);

(statearr_2304[(8)] = inst_2286);

return statearr_2304;
})();
var statearr_2305_2316 = state_2302__$1;
(statearr_2305_2316[(2)] = null);

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


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_2303 === (2))){
var inst_2286 = (state_2302[(8)]);
var inst_2288 = cljs.core.count.call(null,inst_2286);
var inst_2289 = cljs.core.count.call(null,callbacks);
var inst_2290 = cljs.core._EQ_.call(null,inst_2288,inst_2289);
var state_2302__$1 = state_2302;
if(inst_2290){
var statearr_2306_2317 = state_2302__$1;
(statearr_2306_2317[(1)] = (4));

} else {
var statearr_2307_2318 = state_2302__$1;
(statearr_2307_2318[(1)] = (5));

}

return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_2303 === (3))){
var inst_2300 = (state_2302[(2)]);
var state_2302__$1 = state_2302;
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_2302__$1,inst_2300);
} else {
if((state_val_2303 === (4))){
var inst_2286 = (state_2302[(8)]);
var state_2302__$1 = state_2302;
var statearr_2308_2319 = state_2302__$1;
(statearr_2308_2319[(2)] = inst_2286);

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


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_2303 === (5))){
var inst_2284 = (state_2302[(7)]);
var state_2302__$1 = state_2302;
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_2302__$1,(7),inst_2284);
} else {
if((state_val_2303 === (6))){
var inst_2298 = (state_2302[(2)]);
var state_2302__$1 = state_2302;
var statearr_2309_2320 = state_2302__$1;
(statearr_2309_2320[(2)] = inst_2298);

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


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_2303 === (7))){
var inst_2286 = (state_2302[(8)]);
var inst_2294 = (state_2302[(2)]);
var inst_2295 = cljs.core.merge.call(null,inst_2286,inst_2294);
var inst_2286__$1 = inst_2295;
var state_2302__$1 = (function (){var statearr_2310 = state_2302;
(statearr_2310[(8)] = inst_2286__$1);

return statearr_2310;
})();
var statearr_2311_2321 = state_2302__$1;
(statearr_2311_2321[(2)] = null);

(statearr_2311_2321[(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__2145__auto__ = null;
var npm_force_resolutions$core$wait_all_$_state_machine__2145__auto____0 = (function (){
var statearr_2312 = [null,null,null,null,null,null,null,null,null];
(statearr_2312[(0)] = npm_force_resolutions$core$wait_all_$_state_machine__2145__auto__);

(statearr_2312[(1)] = (1));

return statearr_2312;
});
var npm_force_resolutions$core$wait_all_$_state_machine__2145__auto____1 = (function (state_2302){
while(true){
var ret_value__2146__auto__ = (function (){try{while(true){
var result__2147__auto__ = switch__2144__auto__.call(null,state_2302);
if(cljs.core.keyword_identical_QMARK_.call(null,result__2147__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__2147__auto__;
}
break;
}
}catch (e2313){if((e2313 instanceof Object)){
var ex__2148__auto__ = e2313;
var statearr_2314_2322 = state_2302;
(statearr_2314_2322[(5)] = ex__2148__auto__);


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

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

}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__2146__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__2323 = state_2302;
state_2302 = G__2323;
continue;
} else {
return ret_value__2146__auto__;
}
break;
}
});
npm_force_resolutions$core$wait_all_$_state_machine__2145__auto__ = function(state_2302){
switch(arguments.length){
case 0:
return npm_force_resolutions$core$wait_all_$_state_machine__2145__auto____0.call(this);
case 1:
return npm_force_resolutions$core$wait_all_$_state_machine__2145__auto____1.call(this,state_2302);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
npm_force_resolutions$core$wait_all_$_state_machine__2145__auto__.cljs$core$IFn$_invoke$arity$0 = npm_force_resolutions$core$wait_all_$_state_machine__2145__auto____0;
npm_force_resolutions$core$wait_all_$_state_machine__2145__auto__.cljs$core$IFn$_invoke$arity$1 = npm_force_resolutions$core$wait_all_$_state_machine__2145__auto____1;
return npm_force_resolutions$core$wait_all_$_state_machine__2145__auto__;
})()
})();
var state__2169__auto__ = (function (){var statearr_2315 = f__2168__auto__.call(null);
(statearr_2315[(6)] = c__2167__auto__);

return statearr_2315;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__2169__auto__);
}));

return c__2167__auto__;
});
npm_force_resolutions.core.get_registry_url = (function npm_force_resolutions$core$get_registry_url(){
return npm_force_resolutions.core.node$module$child_process.execSync("npm config get registry").toString().trim();
});
npm_force_resolutions.core.find_resolutions = (function npm_force_resolutions$core$find_resolutions(folder){
var c__2167__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,(function (){
var f__2168__auto__ = (function (){var switch__2144__auto__ = (function (state_2351){
var state_val_2352 = (state_2351[(1)]);
if((state_val_2352 === (1))){
var inst_2327 = [cljs.core.str.cljs$core$IFn$_invoke$arity$1(folder),"/package.json"].join('');
var inst_2328 = npm_force_resolutions.core.read_json.call(null,inst_2327);
var inst_2329 = cljs.core.get.call(null,inst_2328,"resolutions");
var inst_2330 = npm_force_resolutions.core.get_registry_url.call(null);
var inst_2332 = (function (){var package_json = inst_2328;
var resolutions = inst_2329;
var registry_url = inst_2330;
return (function (p__2331){
var vec__2353 = p__2331;
var k = cljs.core.nth.call(null,vec__2353,(0),null);
var v = cljs.core.nth.call(null,vec__2353,(1),null);
return npm_force_resolutions.core.fetch_resolved_resolution.call(null,registry_url,k,v);
});
})();
var inst_2333 = cljs.core.seq.call(null,inst_2329);
var inst_2334 = cljs.core.map.call(null,inst_2332,inst_2333);
var inst_2335 = cljs.core.PersistentVector.EMPTY_NODE;
var inst_2336 = npm_force_resolutions.core.wait_all.call(null,inst_2334);
var inst_2337 = cljs.core.async.timeout.call(null,(8000));
var inst_2338 = [inst_2336,inst_2337];
var inst_2339 = (new cljs.core.PersistentVector(null,2,(5),inst_2335,inst_2338,null));
var state_2351__$1 = state_2351;
return cljs.core.async.ioc_alts_BANG_.call(null,state_2351__$1,(2),inst_2339);
} else {
if((state_val_2352 === (2))){
var inst_2342 = (state_2351[(7)]);
var inst_2341 = (state_2351[(2)]);
var inst_2342__$1 = cljs.core.nth.call(null,inst_2341,(0),null);
var inst_2343 = cljs.core.nth.call(null,inst_2341,(1),null);
var state_2351__$1 = (function (){var statearr_2356 = state_2351;
(statearr_2356[(7)] = inst_2342__$1);

(statearr_2356[(8)] = inst_2343);

return statearr_2356;
})();
if(cljs.core.truth_(inst_2342__$1)){
var statearr_2357_2365 = state_2351__$1;
(statearr_2357_2365[(1)] = (3));

} else {
var statearr_2358_2366 = state_2351__$1;
(statearr_2358_2366[(1)] = (4));

}

return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_2352 === (3))){
var inst_2342 = (state_2351[(7)]);
var state_2351__$1 = state_2351;
var statearr_2359_2367 = state_2351__$1;
(statearr_2359_2367[(2)] = inst_2342);

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


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_2352 === (4))){
var inst_2346 = (new Error("Timeout trying to fetch resolutions from npm"));
var inst_2347 = (function(){throw inst_2346})();
var state_2351__$1 = state_2351;
var statearr_2360_2368 = state_2351__$1;
(statearr_2360_2368[(2)] = inst_2347);

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


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_2352 === (5))){
var inst_2349 = (state_2351[(2)]);
var state_2351__$1 = state_2351;
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_2351__$1,inst_2349);
} else {
return null;
}
}
}
}
}
});
return (function() {
var npm_force_resolutions$core$find_resolutions_$_state_machine__2145__auto__ = null;
var npm_force_resolutions$core$find_resolutions_$_state_machine__2145__auto____0 = (function (){
var statearr_2361 = [null,null,null,null,null,null,null,null,null];
(statearr_2361[(0)] = npm_force_resolutions$core$find_resolutions_$_state_machine__2145__auto__);

(statearr_2361[(1)] = (1));

return statearr_2361;
});
var npm_force_resolutions$core$find_resolutions_$_state_machine__2145__auto____1 = (function (state_2351){
while(true){
var ret_value__2146__auto__ = (function (){try{while(true){
var result__2147__auto__ = switch__2144__auto__.call(null,state_2351);
if(cljs.core.keyword_identical_QMARK_.call(null,result__2147__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__2147__auto__;
}
break;
}
}catch (e2362){if((e2362 instanceof Object)){
var ex__2148__auto__ = e2362;
var statearr_2363_2369 = state_2351;
(statearr_2363_2369[(5)] = ex__2148__auto__);


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

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

}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__2146__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__2370 = state_2351;
state_2351 = G__2370;
continue;
} else {
return ret_value__2146__auto__;
}
break;
}
});
npm_force_resolutions$core$find_resolutions_$_state_machine__2145__auto__ = function(state_2351){
switch(arguments.length){
case 0:
return npm_force_resolutions$core$find_resolutions_$_state_machine__2145__auto____0.call(this);
case 1:
return npm_force_resolutions$core$find_resolutions_$_state_machine__2145__auto____1.call(this,state_2351);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
npm_force_resolutions$core$find_resolutions_$_state_machine__2145__auto__.cljs$core$IFn$_invoke$arity$0 = npm_force_resolutions$core$find_resolutions_$_state_machine__2145__auto____0;
npm_force_resolutions$core$find_resolutions_$_state_machine__2145__auto__.cljs$core$IFn$_invoke$arity$1 = npm_force_resolutions$core$find_resolutions_$_state_machine__2145__auto____1;
return npm_force_resolutions$core$find_resolutions_$_state_machine__2145__auto__;
})()
})();
var state__2169__auto__ = (function (){var statearr_2364 = f__2168__auto__.call(null);
(statearr_2364[(6)] = c__2167__auto__);

return statearr_2364;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__2169__auto__);
}));

return c__2167__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__2371){
var vec__2372 = p__2371;
var k = cljs.core.nth.call(null,vec__2372,(0),null);
var v = cljs.core.nth.call(null,vec__2372,(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__2375_SHARP_,p2__2376_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__2375_SHARP_,p2__2376_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)){
var fixed_dep = cljs.core.conj.call(null,cljs.core.dissoc.call(null,dependency,"version","resolved","integrity","bundled"),cljs.core.get.call(null,resolutions,key));
return cljs.core.into.call(null,cljs.core.sorted_map_by.call(null,(function (p1__2377_SHARP_,p2__2378_SHARP_){
return cljs.core.compare.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.get.call(null,fixed_dep,p1__2377_SHARP_)),cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.get.call(null,fixed_dep,p2__2378_SHARP_)));
})),fixed_dep);
} 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__2379_SHARP_,p2__2380_SHARP_){
return npm_force_resolutions.core.patch_dependency.call(null,resolutions,p1__2379_SHARP_,p2__2380_SHARP_);
}),dependencies);
}));
});
npm_force_resolutions.core.update_package_lock = (function npm_force_resolutions$core$update_package_lock(folder){
var c__2167__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,(function (){
var f__2168__auto__ = (function (){var switch__2144__auto__ = (function (state_2389){
var state_val_2390 = (state_2389[(1)]);
if((state_val_2390 === (1))){
var inst_2381 = [cljs.core.str.cljs$core$IFn$_invoke$arity$1(folder),"/package-lock.json"].join('');
var inst_2382 = npm_force_resolutions.core.read_json.call(null,inst_2381);
var inst_2383 = npm_force_resolutions.core.find_resolutions.call(null,folder);
var state_2389__$1 = (function (){var statearr_2391 = state_2389;
(statearr_2391[(7)] = inst_2382);

return statearr_2391;
})();
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_2389__$1,(2),inst_2383);
} else {
if((state_val_2390 === (2))){
var inst_2382 = (state_2389[(7)]);
var inst_2385 = (state_2389[(2)]);
var inst_2386 = npm_force_resolutions.core.patch_all_dependencies.call(null,inst_2385,inst_2382);
var inst_2387 = npm_force_resolutions.core.sort_or_remove_map.call(null,"dependencies",inst_2386);
var state_2389__$1 = state_2389;
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_2389__$1,inst_2387);
} else {
return null;
}
}
});
return (function() {
var npm_force_resolutions$core$update_package_lock_$_state_machine__2145__auto__ = null;
var npm_force_resolutions$core$update_package_lock_$_state_machine__2145__auto____0 = (function (){
var statearr_2392 = [null,null,null,null,null,null,null,null];
(statearr_2392[(0)] = npm_force_resolutions$core$update_package_lock_$_state_machine__2145__auto__);

(statearr_2392[(1)] = (1));

return statearr_2392;
});
var npm_force_resolutions$core$update_package_lock_$_state_machine__2145__auto____1 = (function (state_2389){
while(true){
var ret_value__2146__auto__ = (function (){try{while(true){
var result__2147__auto__ = switch__2144__auto__.call(null,state_2389);
if(cljs.core.keyword_identical_QMARK_.call(null,result__2147__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__2147__auto__;
}
break;
}
}catch (e2393){if((e2393 instanceof Object)){
var ex__2148__auto__ = e2393;
var statearr_2394_2396 = state_2389;
(statearr_2394_2396[(5)] = ex__2148__auto__);


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

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

}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__2146__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__2397 = state_2389;
state_2389 = G__2397;
continue;
} else {
return ret_value__2146__auto__;
}
break;
}
});
npm_force_resolutions$core$update_package_lock_$_state_machine__2145__auto__ = function(state_2389){
switch(arguments.length){
case 0:
return npm_force_resolutions$core$update_package_lock_$_state_machine__2145__auto____0.call(this);
case 1:
return npm_force_resolutions$core$update_package_lock_$_state_machine__2145__auto____1.call(this,state_2389);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
npm_force_resolutions$core$update_package_lock_$_state_machine__2145__auto__.cljs$core$IFn$_invoke$arity$0 = npm_force_resolutions$core$update_package_lock_$_state_machine__2145__auto____0;
npm_force_resolutions$core$update_package_lock_$_state_machine__2145__auto__.cljs$core$IFn$_invoke$arity$1 = npm_force_resolutions$core$update_package_lock_$_state_machine__2145__auto____1;
return npm_force_resolutions$core$update_package_lock_$_state_machine__2145__auto__;
})()
})();
var state__2169__auto__ = (function (){var statearr_2395 = f__2168__auto__.call(null);
(statearr_2395[(6)] = c__2167__auto__);

return statearr_2395;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__2169__auto__);
}));

return c__2167__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 obj2399 = ({"type":"space","size":(2)});
return obj2399;
})()),/\\\\\^/,"^"),/ +\n/,"");
});
npm_force_resolutions.core.main = (function npm_force_resolutions$core$main(var_args){
var args__4795__auto__ = [];
var len__4789__auto___2427 = arguments.length;
var i__4790__auto___2428 = (0);
while(true){
if((i__4790__auto___2428 < len__4789__auto___2427)){
args__4795__auto__.push((arguments[i__4790__auto___2428]));

var G__2429 = (i__4790__auto___2428 + (1));
i__4790__auto___2428 = G__2429;
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__2167__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,(function (){
var f__2168__auto__ = (function (){var switch__2144__auto__ = (function (state_2415){
var state_val_2416 = (state_2415[(1)]);
if((state_val_2416 === (1))){
var inst_2401 = (state_2415[(7)]);
var inst_2401__$1 = cljs.core.first.call(null,args);
var state_2415__$1 = (function (){var statearr_2417 = state_2415;
(statearr_2417[(7)] = inst_2401__$1);

return statearr_2417;
})();
if(cljs.core.truth_(inst_2401__$1)){
var statearr_2418_2430 = state_2415__$1;
(statearr_2418_2430[(1)] = (2));

} else {
var statearr_2419_2431 = state_2415__$1;
(statearr_2419_2431[(1)] = (3));

}

return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_2416 === (2))){
var inst_2401 = (state_2415[(7)]);
var state_2415__$1 = state_2415;
var statearr_2420_2432 = state_2415__$1;
(statearr_2420_2432[(2)] = inst_2401);

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


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_2416 === (3))){
var state_2415__$1 = state_2415;
var statearr_2421_2433 = state_2415__$1;
(statearr_2421_2433[(2)] = ".");

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


return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
if((state_val_2416 === (4))){
var inst_2405 = (state_2415[(8)]);
var inst_2405__$1 = (state_2415[(2)]);
var inst_2406 = npm_force_resolutions.core.update_package_lock.call(null,inst_2405__$1);
var state_2415__$1 = (function (){var statearr_2422 = state_2415;
(statearr_2422[(8)] = inst_2405__$1);

return statearr_2422;
})();
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_2415__$1,(5),inst_2406);
} else {
if((state_val_2416 === (5))){
var inst_2405 = (state_2415[(8)]);
var inst_2408 = (state_2415[(2)]);
var inst_2409 = cognitect.transit.writer.call(null,new cljs.core.Keyword(null,"json-verbose","json-verbose",-542533531));
var inst_2410 = cognitect.transit.write.call(null,inst_2409,inst_2408);
var inst_2411 = [cljs.core.str.cljs$core$IFn$_invoke$arity$1(inst_2405),"/package-lock.json"].join('');
var inst_2412 = npm_force_resolutions.core.indent_json.call(null,inst_2410);
var inst_2413 = npm_force_resolutions.core.node_spit.call(null,inst_2411,inst_2412);
var state_2415__$1 = state_2415;
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_2415__$1,inst_2413);
} else {
return null;
}
}
}
}
}
});
return (function() {
var npm_force_resolutions$core$state_machine__2145__auto__ = null;
var npm_force_resolutions$core$state_machine__2145__auto____0 = (function (){
var statearr_2423 = [null,null,null,null,null,null,null,null,null];
(statearr_2423[(0)] = npm_force_resolutions$core$state_machine__2145__auto__);

(statearr_2423[(1)] = (1));

return statearr_2423;
});
var npm_force_resolutions$core$state_machine__2145__auto____1 = (function (state_2415){
while(true){
var ret_value__2146__auto__ = (function (){try{while(true){
var result__2147__auto__ = switch__2144__auto__.call(null,state_2415);
if(cljs.core.keyword_identical_QMARK_.call(null,result__2147__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__2147__auto__;
}
break;
}
}catch (e2424){if((e2424 instanceof Object)){
var ex__2148__auto__ = e2424;
var statearr_2425_2434 = state_2415;
(statearr_2425_2434[(5)] = ex__2148__auto__);


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

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

}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__2146__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__2435 = state_2415;
state_2415 = G__2435;
continue;
} else {
return ret_value__2146__auto__;
}
break;
}
});
npm_force_resolutions$core$state_machine__2145__auto__ = function(state_2415){
switch(arguments.length){
case 0:
return npm_force_resolutions$core$state_machine__2145__auto____0.call(this);
case 1:
return npm_force_resolutions$core$state_machine__2145__auto____1.call(this,state_2415);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
npm_force_resolutions$core$state_machine__2145__auto__.cljs$core$IFn$_invoke$arity$0 = npm_force_resolutions$core$state_machine__2145__auto____0;
npm_force_resolutions$core$state_machine__2145__auto__.cljs$core$IFn$_invoke$arity$1 = npm_force_resolutions$core$state_machine__2145__auto____1;
return npm_force_resolutions$core$state_machine__2145__auto__;
})()
})();
var state__2169__auto__ = (function (){var statearr_2426 = f__2168__auto__.call(null);
(statearr_2426[(6)] = c__2167__auto__);

return statearr_2426;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__2169__auto__);
}));

return c__2167__auto__;
}));

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

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

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

//# sourceMappingURL=core.js.map
