text: // Compiled by ClojureScript 1.10.773 {:static-fns true, :optimize-constants true}
  goog.provide('clojure.set');
  goog.require('cljs.core');
  goog.require('cljs.core.constants');
  clojure.set.bubble_max_key = (function clojure$set$bubble_max_key(k,coll){
  
  var max = cljs.core.apply.cljs$core$IFn$_invoke$arity$3(cljs.core.max_key,k,coll);
  return cljs.core.cons(max,cljs.core.remove.cljs$core$IFn$_invoke$arity$2((function (p1__26681_SHARP_){
  return (max === p1__26681_SHARP_);
  }),coll));
  });
  /**
   * Return a set that is the union of the input sets
   */
  clojure.set.union = (function clojure$set$union(var_args){
  var G__26686 = arguments.length;
  switch (G__26686) {
  case 0:
  return clojure.set.union.cljs$core$IFn$_invoke$arity$0();
  
  break;
  case 1:
  return clojure.set.union.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
  
  break;
  case 2:
  return clojure.set.union.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
  
  break;
  default:
  var args_arr__4757__auto__ = [];
  var len__4736__auto___26688 = arguments.length;
  var i__4737__auto___26689 = (0);
  while(true){
  if((i__4737__auto___26689 < len__4736__auto___26688)){
  args_arr__4757__auto__.push((arguments[i__4737__auto___26689]));
  
  var G__26690 = (i__4737__auto___26689 + (1));
  i__4737__auto___26689 = G__26690;
  continue;
  } else {
  }
  break;
  }
  
  var argseq__4758__auto__ = (new cljs.core.IndexedSeq(args_arr__4757__auto__.slice((2)),(0),null));
  return clojure.set.union.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__4758__auto__);
  
  }
  });
  
  (clojure.set.union.cljs$core$IFn$_invoke$arity$0 = (function (){
  return cljs.core.PersistentHashSet.EMPTY;
  }));
  
  (clojure.set.union.cljs$core$IFn$_invoke$arity$1 = (function (s1){
  return s1;
  }));
  
  (clojure.set.union.cljs$core$IFn$_invoke$arity$2 = (function (s1,s2){
  if((cljs.core.count(s1) < cljs.core.count(s2))){
  return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(cljs.core.conj,s2,s1);
  } else {
  return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(cljs.core.conj,s1,s2);
  }
  }));
  
  (clojure.set.union.cljs$core$IFn$_invoke$arity$variadic = (function (s1,s2,sets){
  var bubbled_sets = clojure.set.bubble_max_key(cljs.core.count,cljs.core.conj.cljs$core$IFn$_invoke$arity$variadic(sets,s2,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([s1], 0)));
  return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(cljs.core.into,cljs.core.first(bubbled_sets),cljs.core.rest(bubbled_sets));
  }));
  
  /** @this {Function} */
  (clojure.set.union.cljs$lang$applyTo = (function (seq26683){
  var G__26684 = cljs.core.first(seq26683);
  var seq26683__$1 = cljs.core.next(seq26683);
  var G__26685 = cljs.core.first(seq26683__$1);
  var seq26683__$2 = cljs.core.next(seq26683__$1);
  var self__4723__auto__ = this;
  return self__4723__auto__.cljs$core$IFn$_invoke$arity$variadic(G__26684,G__26685,seq26683__$2);
  }));
  
  (clojure.set.union.cljs$lang$maxFixedArity = (2));
  
  /**
   * Return a set that is the intersection of the input sets
   */
  clojure.set.intersection = (function clojure$set$intersection(var_args){
  var G__26696 = arguments.length;
  switch (G__26696) {
  case 1:
  return clojure.set.intersection.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
  
  break;
  case 2:
  return clojure.set.intersection.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
  
  break;
  default:
  var args_arr__4757__auto__ = [];
  var len__4736__auto___26698 = arguments.length;
  var i__4737__auto___26699 = (0);
  while(true){
  if((i__4737__auto___26699 < len__4736__auto___26698)){
  args_arr__4757__auto__.push((arguments[i__4737__auto___26699]));
  
  var G__26700 = (i__4737__auto___26699 + (1));
  i__4737__auto___26699 = G__26700;
  continue;
  } else {
  }
  break;
  }
  
  var argseq__4758__auto__ = (new cljs.core.IndexedSeq(args_arr__4757__auto__.slice((2)),(0),null));
  return clojure.set.intersection.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__4758__auto__);
  
  }
  });
  
  (clojure.set.intersection.cljs$core$IFn$_invoke$arity$1 = (function (s1){
  return s1;
  }));
  
  (clojure.set.intersection.cljs$core$IFn$_invoke$arity$2 = (function (s1,s2){
  while(true){
  if((cljs.core.count(s2) < cljs.core.count(s1))){
  var G__26701 = s2;
  var G__26702 = s1;
  s1 = G__26701;
  s2 = G__26702;
  continue;
  } else {
  return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(((function (s1,s2){
  return (function (result,item){
  if(cljs.core.contains_QMARK_(s2,item)){
  return result;
  } else {
  return cljs.core.disj.cljs$core$IFn$_invoke$arity$2(result,item);
  }
  });})(s1,s2))
  ,s1,s1);
  }
  break;
  }
  }));
  
  (clojure.set.intersection.cljs$core$IFn$_invoke$arity$variadic = (function (s1,s2,sets){
  var bubbled_sets = clojure.set.bubble_max_key((function (p1__26691_SHARP_){
  return (- cljs.core.count(p1__26691_SHARP_));
  }),cljs.core.conj.cljs$core$IFn$_invoke$arity$variadic(sets,s2,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([s1], 0)));
  return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(clojure.set.intersection,cljs.core.first(bubbled_sets),cljs.core.rest(bubbled_sets));
  }));
  
  /** @this {Function} */
  (clojure.set.intersection.cljs$lang$applyTo = (function (seq26693){
  var G__26694 = cljs.core.first(seq26693);
  var seq26693__$1 = cljs.core.next(seq26693);
  var G__26695 = cljs.core.first(seq26693__$1);
  var seq26693__$2 = cljs.core.next(seq26693__$1);
  var self__4723__auto__ = this;
  return self__4723__auto__.cljs$core$IFn$_invoke$arity$variadic(G__26694,G__26695,seq26693__$2);
  }));
  
  (clojure.set.intersection.cljs$lang$maxFixedArity = (2));
  
  /**
   * Return a set that is the first set without elements of the remaining sets
   */
  clojure.set.difference = (function clojure$set$difference(var_args){
  var G__26707 = arguments.length;
  switch (G__26707) {
  case 1:
  return clojure.set.difference.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
  
  break;
  case 2:
  return clojure.set.difference.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
  
  break;
  default:
  var args_arr__4757__auto__ = [];
  var len__4736__auto___26709 = arguments.length;
  var i__4737__auto___26710 = (0);
  while(true){
  if((i__4737__auto___26710 < len__4736__auto___26709)){
  args_arr__4757__auto__.push((arguments[i__4737__auto___26710]));
  
  var G__26711 = (i__4737__auto___26710 + (1));
  i__4737__auto___26710 = G__26711;
  continue;
  } else {
  }
  break;
  }
  
  var argseq__4758__auto__ = (new cljs.core.IndexedSeq(args_arr__4757__auto__.slice((2)),(0),null));
  return clojure.set.difference.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__4758__auto__);
  
  }
  });
  
  (clojure.set.difference.cljs$core$IFn$_invoke$arity$1 = (function (s1){
  return s1;
  }));
  
  (clojure.set.difference.cljs$core$IFn$_invoke$arity$2 = (function (s1,s2){
  if((cljs.core.count(s1) < cljs.core.count(s2))){
  return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (result,item){
  if(cljs.core.contains_QMARK_(s2,item)){
  return cljs.core.disj.cljs$core$IFn$_invoke$arity$2(result,item);
  } else {
  return result;
  }
  }),s1,s1);
  } else {
  return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(cljs.core.disj,s1,s2);
  }
  }));
  
  (clojure.set.difference.cljs$core$IFn$_invoke$arity$variadic = (function (s1,s2,sets){
  return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(clojure.set.difference,s1,cljs.core.conj.cljs$core$IFn$_invoke$arity$2(sets,s2));
  }));
  
  /** @this {Function} */
  (clojure.set.difference.cljs$lang$applyTo = (function (seq26704){
  var G__26705 = cljs.core.first(seq26704);
  var seq26704__$1 = cljs.core.next(seq26704);
  var G__26706 = cljs.core.first(seq26704__$1);
  var seq26704__$2 = cljs.core.next(seq26704__$1);
  var self__4723__auto__ = this;
  return self__4723__auto__.cljs$core$IFn$_invoke$arity$variadic(G__26705,G__26706,seq26704__$2);
  }));
  
  (clojure.set.difference.cljs$lang$maxFixedArity = (2));
  
  /**
   * Returns a set of the elements for which pred is true
   */
  clojure.set.select = (function clojure$set$select(pred,xset){
  return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (s,k){
  if(cljs.core.truth_((pred.cljs$core$IFn$_invoke$arity$1 ? pred.cljs$core$IFn$_invoke$arity$1(k) : pred.call(null,k)))){
  return s;
  } else {
  return cljs.core.disj.cljs$core$IFn$_invoke$arity$2(s,k);
  }
  }),xset,xset);
  });
  /**
   * Returns a rel of the elements of xrel with only the keys in ks
   */
  clojure.set.project = (function clojure$set$project(xrel,ks){
  return cljs.core.set(cljs.core.map.cljs$core$IFn$_invoke$arity$2((function (p1__26712_SHARP_){
  return cljs.core.select_keys(p1__26712_SHARP_,ks);
  }),xrel));
  });
  /**
   * Returns the map with the keys in kmap renamed to the vals in kmap
   */
  clojure.set.rename_keys = (function clojure$set$rename_keys(map,kmap){
  return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (m,p__26713){
  var vec__26714 = p__26713;
  var old = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__26714,(0),null);
  var new$ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__26714,(1),null);
  if(cljs.core.contains_QMARK_(map,old)){
  return cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(m,new$,cljs.core.get.cljs$core$IFn$_invoke$arity$2(map,old));
  } else {
  return m;
  }
  }),cljs.core.apply.cljs$core$IFn$_invoke$arity$3(cljs.core.dissoc,map,cljs.core.keys(kmap)),kmap);
  });
  /**
   * Returns a rel of the maps in xrel with the keys in kmap renamed to the vals in kmap
   */
  clojure.set.rename = (function clojure$set$rename(xrel,kmap){
  return cljs.core.set(cljs.core.map.cljs$core$IFn$_invoke$arity$2((function (p1__26717_SHARP_){
  return clojure.set.rename_keys(p1__26717_SHARP_,kmap);
  }),xrel));
  });
  /**
   * Returns a map of the distinct values of ks in the xrel mapped to a
   *   set of the maps in xrel with the corresponding values of ks.
   */
  clojure.set.index = (function clojure$set$index(xrel,ks){
  return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (m,x){
  var ik = cljs.core.select_keys(x,ks);
  return cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(m,ik,cljs.core.conj.cljs$core$IFn$_invoke$arity$2(cljs.core.get.cljs$core$IFn$_invoke$arity$3(m,ik,cljs.core.PersistentHashSet.EMPTY),x));
  }),cljs.core.PersistentArrayMap.EMPTY,xrel);
  });
  /**
   * Returns the map with the vals mapped to the keys.
   */
  clojure.set.map_invert = (function clojure$set$map_invert(m){
  return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (m__$1,p__26718){
  var vec__26719 = p__26718;
  var k = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__26719,(0),null);
  var v = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__26719,(1),null);
  return cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(m__$1,v,k);
  }),cljs.core.PersistentArrayMap.EMPTY,m);
  });
  /**
   * When passed 2 rels, returns the rel corresponding to the natural
   *   join. When passed an additional keymap, joins on the corresponding
   *   keys.
   */
  clojure.set.join = (function clojure$set$join(var_args){
  var G__26727 = arguments.length;
  switch (G__26727) {
  case 2:
  return clojure.set.join.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
  
  break;
  case 3:
  return clojure.set.join.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
  
  break;
  default:
  throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
  
  }
  });
  
  (clojure.set.join.cljs$core$IFn$_invoke$arity$2 = (function (xrel,yrel){
  if(((cljs.core.seq(xrel)) && (cljs.core.seq(yrel)))){
  var ks = clojure.set.intersection.cljs$core$IFn$_invoke$arity$2(cljs.core.set(cljs.core.keys(cljs.core.first(xrel))),cljs.core.set(cljs.core.keys(cljs.core.first(yrel))));
  var vec__26728 = (((cljs.core.count(xrel) <= cljs.core.count(yrel)))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [xrel,yrel], null):new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [yrel,xrel], null));
  var r = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__26728,(0),null);
  var s = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__26728,(1),null);
  var idx = clojure.set.index(r,ks);
  return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (ret,x){
  var found = (function (){var G__26731 = cljs.core.select_keys(x,ks);
  return (idx.cljs$core$IFn$_invoke$arity$1 ? idx.cljs$core$IFn$_invoke$arity$1(G__26731) : idx.call(null,G__26731));
  })();
  if(cljs.core.truth_(found)){
  return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (p1__26722_SHARP_,p2__26723_SHARP_){
  return cljs.core.conj.cljs$core$IFn$_invoke$arity$2(p1__26722_SHARP_,cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([p2__26723_SHARP_,x], 0)));
  }),ret,found);
  } else {
  return ret;
  }
  }),cljs.core.PersistentHashSet.EMPTY,s);
  } else {
  return cljs.core.PersistentHashSet.EMPTY;
  }
  }));
  
  (clojure.set.join.cljs$core$IFn$_invoke$arity$3 = (function (xrel,yrel,km){
  var vec__26732 = (((cljs.core.count(xrel) <= cljs.core.count(yrel)))?new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [xrel,yrel,clojure.set.map_invert(km)], null):new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [yrel,xrel,km], null));
  var r = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__26732,(0),null);
  var s = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__26732,(1),null);
  var k = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__26732,(2),null);
  var idx = clojure.set.index(r,cljs.core.vals(k));
  return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (ret,x){
  var found = (function (){var G__26735 = clojure.set.rename_keys(cljs.core.select_keys(x,cljs.core.keys(k)),k);
  return (idx.cljs$core$IFn$_invoke$arity$1 ? idx.cljs$core$IFn$_invoke$arity$1(G__26735) : idx.call(null,G__26735));
  })();
  if(cljs.core.truth_(found)){
  return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (p1__26724_SHARP_,p2__26725_SHARP_){
  return cljs.core.conj.cljs$core$IFn$_invoke$arity$2(p1__26724_SHARP_,cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([p2__26725_SHARP_,x], 0)));
  }),ret,found);
  } else {
  return ret;
  }
  }),cljs.core.PersistentHashSet.EMPTY,s);
  }));
  
  (clojure.set.join.cljs$lang$maxFixedArity = 3);
  
  /**
   * Is set1 a subset of set2?
   */
  clojure.set.subset_QMARK_ = (function clojure$set$subset_QMARK_(set1,set2){
  return (((cljs.core.count(set1) <= cljs.core.count(set2))) && (cljs.core.every_QMARK_((function (p1__26737_SHARP_){
  return cljs.core.contains_QMARK_(set2,p1__26737_SHARP_);
  }),set1)));
  });
  /**
   * Is set1 a superset of set2?
   */
  clojure.set.superset_QMARK_ = (function clojure$set$superset_QMARK_(set1,set2){
  return (((cljs.core.count(set1) >= cljs.core.count(set2))) && (cljs.core.every_QMARK_((function (p1__26738_SHARP_){
  return cljs.core.contains_QMARK_(set1,p1__26738_SHARP_);
  }),set2)));
  });
  