function $AdfPreferredSuggestionsManager$$() {
}
$goog$exportSymbol$$("AdfPreferredSuggestionsManager", $AdfPreferredSuggestionsManager$$);
$AdfObject$$.$createSubclass$($AdfPreferredSuggestionsManager$$);
$AdfPreferredSuggestionsManager$$.$InitClass$ = function $$AdfPreferredSuggestionsManager$$$$InitClass$$() {
  this.$_DONT_CACHE_REPLACEMENT_STR$ = "\u2022\u2022\u2022\u2022\u2022";
  this.$_SUGGESTIONS_TOO_LESS_COUNT$ = 16;
};
$goog$exportSymbol$$("AdfPreferredSuggestionsManager.InitClass", $AdfPreferredSuggestionsManager$$.$InitClass$);
$AdfPreferredSuggestionsManager$$.add = function $$AdfPreferredSuggestionsManager$$$add$($inputSearch_storageKey$$2$$, $newValues$$2$$, $suggestionMap$$6$$) {
  var $suggestionsSection$$ = $AdfInputSearchUtils$getSuggestionsSection$$($inputSearch_storageKey$$2$$);
  if ($suggestionsSection$$ && $suggestionMap$$6$$) {
    $inputSearch_storageKey$$2$$ = $AdfPreferredSuggestionsManager$$.$_getCacheKey$($inputSearch_storageKey$$2$$, $suggestionsSection$$);
    for (var $preferredSuggestions$$2$$ = $AdfPreferredSuggestionsManager$$.$_read$($inputSearch_storageKey$$2$$, $suggestionsSection$$.getDisplayCount()), $preferredSuggestionsList$$ = $preferredSuggestions$$2$$.$suggestions$, $scoreMap$$4$$ = $preferredSuggestions$$2$$.$score$, $i$$144$$ = 0, $length$$40$$ = $newValues$$2$$.length;$i$$144$$ < $length$$40$$;$i$$144$$++) {
      var $newValue$$25$$ = $newValues$$2$$[$i$$144$$];
      if (!$scoreMap$$4$$[$newValue$$25$$] && ($preferredSuggestionsList$$.unshift($AdfPreferredSuggestionsManager$$.$_getCacheableSuggestionData$($suggestionsSection$$, $suggestionMap$$6$$.get($newValue$$25$$))), $preferredSuggestionsList$$.length > $preferredSuggestions$$2$$.$maxDisplayCount$)) {
        var $minScoredSuggestionKey$$1$$ = $AdfInputSearchScoreUtils$$.$getMinScoredSuggestionKey$($scoreMap$$4$$);
        delete $scoreMap$$4$$[$minScoredSuggestionKey$$1$$];
        $preferredSuggestionsList$$.splice($AdfPreferredSuggestionsManager$$.$_findIndex$($preferredSuggestionsList$$, $minScoredSuggestionKey$$1$$), 1);
      }
      $AdfInputSearchScoreUtils$$.$updateScores$($inputSearch_storageKey$$2$$, $preferredSuggestions$$2$$, $newValue$$25$$);
    }
    localStorage.setItem($inputSearch_storageKey$$2$$, JSON.stringify($preferredSuggestions$$2$$));
  }
};
$goog$exportSymbol$$("AdfPreferredSuggestionsManager.add", $AdfPreferredSuggestionsManager$$.add);
$AdfPreferredSuggestionsManager$$.get = function $$AdfPreferredSuggestionsManager$$$get$($inputSearch$$1_preferredSuggestionMap$$) {
  var $suggestionsSection$$1$$ = $AdfInputSearchUtils$getSuggestionsSection$$($inputSearch$$1_preferredSuggestionMap$$);
  if ($suggestionsSection$$1$$) {
    var $preferredSuggestions$$3_storageKey$$3$$ = $AdfPreferredSuggestionsManager$$.$_getCacheKey$($inputSearch$$1_preferredSuggestionMap$$, $suggestionsSection$$1$$);
    if ($preferredSuggestions$$3_storageKey$$3$$ = localStorage.getItem($preferredSuggestions$$3_storageKey$$3$$)) {
      if ($preferredSuggestions$$3_storageKey$$3$$ = JSON.parse($preferredSuggestions$$3_storageKey$$3$$), 1 == $preferredSuggestions$$3_storageKey$$3$$.version) {
        var $preferredSuggestionsList$$1$$ = $preferredSuggestions$$3_storageKey$$3$$.$suggestions$;
        if (!$AdfPreferredSuggestionsManager$$.$_isSuggestionsTooLess$($inputSearch$$1_preferredSuggestionMap$$, $preferredSuggestions$$3_storageKey$$3$$.$totalSize$) && ($preferredSuggestionsList$$1$$ = $AdfSequencedSections$$.$prefilter$($inputSearch$$1_preferredSuggestionMap$$, $preferredSuggestionsList$$1$$), $preferredSuggestionsList$$1$$ = $AdfInputSearchScoreUtils$$.$sortPerScore$($preferredSuggestionsList$$1$$, $preferredSuggestions$$3_storageKey$$3$$.$score$), $preferredSuggestionsList$$1$$ = 
        $AdfPreferredSuggestionsManager$$.$_capPreferredSuggestions$($preferredSuggestionsList$$1$$, $suggestionsSection$$1$$.getDisplayCount()), $AdfPreferredSuggestionsManager$$.$_substituteDontCacheAttributes$($suggestionsSection$$1$$, $preferredSuggestionsList$$1$$), $inputSearch$$1_preferredSuggestionMap$$ = new $AdfSuggestionMap$$($preferredSuggestionsList$$1$$), 0 < $inputSearch$$1_preferredSuggestionMap$$.length)) {
          return $inputSearch$$1_preferredSuggestionMap$$;
        }
      }
    }
  }
};
$goog$exportSymbol$$("AdfPreferredSuggestionsManager.get", $AdfPreferredSuggestionsManager$$.get);
$AdfPreferredSuggestionsManager$$.update = function $$AdfPreferredSuggestionsManager$$$update$($inputSearch$$2_storageKey$$4$$, $isMasterList$$, $suggestions$$1$$) {
  var $suggestionsSection$$2$$ = $AdfInputSearchUtils$getSuggestionsSection$$($inputSearch$$2_storageKey$$4$$);
  if ($suggestionsSection$$2$$) {
    $inputSearch$$2_storageKey$$4$$ = $AdfPreferredSuggestionsManager$$.$_getCacheKey$($inputSearch$$2_storageKey$$4$$, $suggestionsSection$$2$$);
    for (var $preferredSuggestions$$4$$ = $AdfPreferredSuggestionsManager$$.$_read$($inputSearch$$2_storageKey$$4$$, $suggestionsSection$$2$$.getDisplayCount(), $isMasterList$$ ? $suggestions$$1$$ : null), $preferredSuggestionsList$$2$$ = $preferredSuggestions$$4$$.$suggestions$, $length$$41$$ = $preferredSuggestionsList$$2$$.length, $updatedList$$ = [], $i$$145$$ = 0, $j$$17$$ = 0;$i$$145$$ < $length$$41$$;$i$$145$$++) {
      var $suggestionItem$$ = $suggestions$$1$$.get($preferredSuggestionsList$$2$$[$i$$145$$].key);
      $suggestionItem$$ ? $updatedList$$[$j$$17$$++] = $AdfPreferredSuggestionsManager$$.$_getCacheableSuggestionData$($suggestionsSection$$2$$, $suggestionItem$$) : $isMasterList$$ ? delete $preferredSuggestions$$4$$.$score$[$preferredSuggestionsList$$2$$[$i$$145$$].key] : $updatedList$$[$j$$17$$++] = $preferredSuggestionsList$$2$$[$i$$145$$];
    }
    $preferredSuggestions$$4$$.$suggestions$ = $updatedList$$;
    localStorage.setItem($inputSearch$$2_storageKey$$4$$, JSON.stringify($preferredSuggestions$$4$$));
  }
};
$goog$exportSymbol$$("AdfPreferredSuggestionsManager.update", $AdfPreferredSuggestionsManager$$.update);
$AdfPreferredSuggestionsManager$$.$isDisplayAttributesCacheable$ = function $$AdfPreferredSuggestionsManager$$$$isDisplayAttributesCacheable$$($displayAttributes_inputSearch$$3$$) {
  var $dontCache$$ = $AdfInputSearchUtils$getSuggestionsSection$$($displayAttributes_inputSearch$$3$$).getDontCache();
  if (!$dontCache$$) {
    return !0;
  }
  $displayAttributes_inputSearch$$3$$ = $displayAttributes_inputSearch$$3$$.getDisplayAttributes();
  for (var $isCacheable$$ = !0, $i$$146$$ = 0, $length$$42$$ = $displayAttributes_inputSearch$$3$$.length;$i$$146$$ < $length$$42$$;$i$$146$$++) {
    if ($dontCache$$[$displayAttributes_inputSearch$$3$$[$i$$146$$]]) {
      $isCacheable$$ = !1;
      break;
    }
  }
  return $isCacheable$$;
};
$goog$exportSymbol$$("AdfPreferredSuggestionsManager.isDisplayAttributesCacheable", $AdfPreferredSuggestionsManager$$.$isDisplayAttributesCacheable$);
$AdfPreferredSuggestionsManager$$.$_capPreferredSuggestions$ = function $$AdfPreferredSuggestionsManager$$$$_capPreferredSuggestions$$($preferredSuggestionsList$$3$$, $displayCount$$) {
  if ($preferredSuggestionsList$$3$$.length <= $displayCount$$) {
    return $preferredSuggestionsList$$3$$;
  }
  for (var $cappedCollection$$ = Array($displayCount$$), $i$$147$$ = 0;$i$$147$$ < $displayCount$$;$i$$147$$++) {
    $cappedCollection$$[$i$$147$$] = $preferredSuggestionsList$$3$$[$i$$147$$];
  }
  return $cappedCollection$$;
};
$AdfPreferredSuggestionsManager$$.$_findIndex$ = function $$AdfPreferredSuggestionsManager$$$$_findIndex$$($preferredSuggestionsList$$4$$, $value$$159$$) {
  for (var $i$$148$$ = 0, $length$$43$$ = $preferredSuggestionsList$$4$$.length;$i$$148$$ < $length$$43$$;$i$$148$$++) {
    if ($preferredSuggestionsList$$4$$[$i$$148$$].key == $value$$159$$) {
      return $i$$148$$;
    }
  }
  return -1;
};
$AdfPreferredSuggestionsManager$$.$_getCacheKey$ = function $$AdfPreferredSuggestionsManager$$$$_getCacheKey$$($inputSearch$$4$$, $suggestionsSection$$4$$) {
  var $dataUrl$$1$$ = $AdfInputSearchUtils$getDefaultSearchSection$$($inputSearch$$4$$).getDataUrl(), $dataUrl$$1$$ = $AdfRestDataService$$.$normalizeUrl$($dataUrl$$1$$), $cacheKeyGeneratorFuncName$$ = $suggestionsSection$$4$$.getCacheKeyGenerator(), $cacheKey$$1$$ = $dataUrl$$1$$;
  if ($cacheKeyGeneratorFuncName$$) {
    var $cacheKeyGeneratorFunc$$ = $AdfInputSearchUtils$getFunction$$($cacheKeyGeneratorFuncName$$);
    if ($cacheKeyGeneratorFunc$$) {
      try {
        $cacheKey$$1$$ = $cacheKeyGeneratorFunc$$.call($inputSearch$$4$$, $dataUrl$$1$$);
      } catch ($e$$89$$) {
        throw $AdfLogger$$.$LOGGER$.severe("cacheKeyGenerator ", $cacheKeyGeneratorFuncName$$, " set on the component ", $suggestionsSection$$4$$.$getClientId$(), " has thrown an exception"), $e$$89$$;
      }
    }
  }
  return $AdfRestDataService$$.$__removeTrailingSlashQuestionMarkAmpersand$($cacheKey$$1$$);
};
$AdfPreferredSuggestionsManager$$.$_getCacheableSuggestionData$ = function $$AdfPreferredSuggestionsManager$$$$_getCacheableSuggestionData$$($suggestionsSection$$5$$, $suggestionItem$$1$$) {
  var $dontCache$$1$$ = $suggestionsSection$$5$$.getDontCache();
  if (!$dontCache$$1$$) {
    return $suggestionItem$$1$$;
  }
  var $dontCache$$1$$ = Object.keys($dontCache$$1$$), $copySuggestion$$ = $AdfInputSearchUtils$cloneSimpleObject$$($suggestionItem$$1$$);
  $copySuggestion$$.data = $AdfInputSearchUtils$cloneSimpleObject$$($suggestionItem$$1$$.data);
  for (var $i$$149$$ = 0, $length$$44$$ = $dontCache$$1$$.length;$i$$149$$ < $length$$44$$;$i$$149$$++) {
    delete $copySuggestion$$.data[$dontCache$$1$$[$i$$149$$]];
  }
  return $copySuggestion$$;
};
$AdfPreferredSuggestionsManager$$.$_isSuggestionsTooLess$ = function $$AdfPreferredSuggestionsManager$$$$_isSuggestionsTooLess$$($inputSearch$$5$$, $totalSuggestionsCount$$1$$) {
  return $totalSuggestionsCount$$1$$ <= $inputSearch$$5$$.getRowCount() && $totalSuggestionsCount$$1$$ <= $AdfPreferredSuggestionsManager$$.$_SUGGESTIONS_TOO_LESS_COUNT$;
};
$AdfPreferredSuggestionsManager$$.$_read$ = function $$AdfPreferredSuggestionsManager$$$$_read$$($preferredSuggestions$$5_storageKey$$5$$, $limit$$, $suggestions$$2$$) {
  ($preferredSuggestions$$5_storageKey$$5$$ = localStorage.getItem($preferredSuggestions$$5_storageKey$$5$$)) ? ($preferredSuggestions$$5_storageKey$$5$$ = JSON.parse($preferredSuggestions$$5_storageKey$$5$$), $preferredSuggestions$$5_storageKey$$5$$.$maxDisplayCount$ = $limit$$ > $preferredSuggestions$$5_storageKey$$5$$.$maxDisplayCount$ ? $limit$$ : $preferredSuggestions$$5_storageKey$$5$$.$maxDisplayCount$) : ($preferredSuggestions$$5_storageKey$$5$$ = {version:1, $suggestions$:[]}, $preferredSuggestions$$5_storageKey$$5$$.$maxDisplayCount$ = 
  $limit$$, $preferredSuggestions$$5_storageKey$$5$$.$score$ = {});
  $preferredSuggestions$$5_storageKey$$5$$.$totalSize$ = $suggestions$$2$$ ? $suggestions$$2$$.length : $preferredSuggestions$$5_storageKey$$5$$.$totalSize$;
  null == $preferredSuggestions$$5_storageKey$$5$$.$totalSize$ && ($preferredSuggestions$$5_storageKey$$5$$.$totalSize$ = $AdfDhtmlInputSearchPeer$$.$__SUGGESTIONS_RENDERING_CHUNK_SIZE$);
  return $preferredSuggestions$$5_storageKey$$5$$;
};
$AdfPreferredSuggestionsManager$$.$_substituteDontCacheAttributes$ = function $$AdfPreferredSuggestionsManager$$$$_substituteDontCacheAttributes$$($suggestionsSection$$6$$, $preferredSuggestionsList$$5$$) {
  var $dontCache$$2$$ = $suggestionsSection$$6$$.getDontCache();
  if ($dontCache$$2$$) {
    for (var $dontCache$$2$$ = Object.keys($dontCache$$2$$), $i$$150$$ = 0, $len1$$2$$ = $preferredSuggestionsList$$5$$.length;$i$$150$$ < $len1$$2$$;$i$$150$$++) {
      for (var $suggestion$$1$$ = $preferredSuggestionsList$$5$$[$i$$150$$], $j$$18$$ = 0, $len2$$1$$ = $dontCache$$2$$.length;$j$$18$$ < $len2$$1$$;$j$$18$$++) {
        $suggestion$$1$$.data[$dontCache$$2$$[$j$$18$$]] = $AdfPreferredSuggestionsManager$$.$_DONT_CACHE_REPLACEMENT_STR$;
      }
    }
  }
};
