AdfRichUIPeer.createPeerClass(AdfDhtmlInputBasePeer, "AdfDhtmlInputSearchPeer", false);
AdfDhtmlInputSearchPeer.InitSubclass = function() {
  AdfObject.ensureClassInitialization(AdfRichPopup);
  AdfObject.ensureClassInitialization(AdfRestDataService);
  AdfObject.ensureClassInitialization(AdfInputSearchScrollManager);
  AdfObject.ensureClassInitialization(AdfInputSearchScoreUtils);
  AdfObject.ensureClassInitialization(AdfInputSearchMruCache);
  AdfObject.ensureClassInitialization(AdfPreferredSuggestionsManager);
  AdfObject.ensureClassInitialization(AdfSuggestionsContainer);
  AdfObject.ensureClassInitialization(AdfSuggestionsPanel);
  AdfObject.ensureClassInitialization(AdfToolbarPanel);
  AdfObject.ensureClassInitialization(AdfDhtmlSuggestionsSectionPeer);
  AdfRichUIPeer.addComponentEventHandlers(this, AdfUIInputEvent.CLICK_EVENT_TYPE, AdfUIInputEvent.KEY_DOWN_EVENT_TYPE, AdfUIInputEvent.KEY_UP_EVENT_TYPE, AdfUIInputEvent.FOCUS_EVENT_TYPE);
  this.SELECTION_PROPERTY = "_selection";
  this._VALUE_ATTRIBUTE_DATA_TYPE = "_valJsType";
  AdfRichUIPeer.addComponentPropertyGetters(this, AdfRichInputSearch.LABEL);
  AdfRichUIPeer.addComponentPropertyChanges(this, AdfRichInputSearch.LABEL, this._VALUE_ATTRIBUTE_DATA_TYPE);
  this._CUSTOM_NAME_EXPANDO = "data-afr-name";
  this._BUTTON_SUB_ID = "btn";
  this._SUGGESTIONS_POPUP_SUB_ID = "suggestions-popup";
  this._CONTENT_MODE_LIST = "LIST";
  this.__CONTENT_MODE_TABLE = "TABLE";
  this._SELECTION_MODE_SINGLE = "SINGLE";
  this.__SELECTION_MODE_MULTIPLE = "MULTIPLE";
  this.__SEARCH_SECTION_TYPE_DEFAULT = "default";
  this._VALUE_UPDATING_STYLE_CLASS = "p_AFValueUpdating";
  this.__SUGGESTIONS_RENDERING_CHUNK_SIZE = 300;
  this._SPECIAL_CHARS_REGEX_STR = "~`!@#$%^\x26*()_+{}|:;\"'\x3c,\x3e.?/[\\]\\-\\\\";
};
AdfDhtmlInputSearchPeer.prototype.InitDomElement = function(component, element) {
  this.BindToComponent(component, element);
  AdfDhtmlInputSearchPeer.superclass.InitDomElement.call(this, component, element);
  this._suggestionsContainer = new AdfSuggestionsContainer(this);
  this._toolbarPanel = new AdfToolbarPanel(this);
  if (!AdfInputSearchUtils.isReadOnlyOrDisabled(component)) {
    var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component, element);
    AdfDhtmlInputBasePeer.setLastValue(contentNode);
    AdfDhtmlInputSearchPeer._setIdOnLabelElement(component, contentNode);
  }
};
AdfDhtmlInputSearchPeer.prototype.compareValues = function(oldValues, newValues) {
  if (!newValues) {
    newValues = [];
  }
  AdfAssert.assertArray(oldValues);
  AdfAssert.assertArray(newValues);
  if (newValues == oldValues) {
    return true;
  }
  if (newValues.length != oldValues.length) {
    return false;
  }
  for (var i = 0, len = newValues.length;i < len;i++) {
    if (oldValues.indexOf(newValues[i]) == -1) {
      return false;
    }
  }
  return true;
};
AdfDhtmlInputSearchPeer.prototype.getDisplayedValue = function(component) {
  return this.GetDisplayValue(component, this.getDomElement());
};
AdfDhtmlInputSearchPeer.prototype.getSearchSections = function(component) {
  var searchSections = AdfInputSearchUtils.getChildrenSection(component, AdfRichSearchSection);
  var searchSectionMap = {};
  for (var i = 0, length = searchSections.length;i < length;i++) {
    var searchSection = searchSections[i];
    searchSectionMap[searchSection.getType()] = searchSection;
  }
  return searchSectionMap;
};
AdfDhtmlInputSearchPeer.prototype.getSuggestions = function() {
  var displayedSuggestions = this.GetSuggestionsPanel().getDisplayedSuggestions();
  return displayedSuggestions && displayedSuggestions.getArray();
};
AdfDhtmlInputSearchPeer.prototype.getConvertedObject = function(component, newValues) {
  AdfAssert.assertArray(newValues);
  var converter = component.getConverter();
  var hasConverter = !(converter == null || converter instanceof AdfMissingConverter);
  var isClientOnly = hasConverter && converter.isClientOnly && converter.isClientOnly();
  if (hasConverter && !isClientOnly) {
    newValues = AdfDhtmlInputSearchPeer._deriveDisplayValueFromConv(component, converter, newValues);
  } else {
    var suggestions = this.GetSuggestionMapContainingSelections();
    if (!suggestions) {
      suggestions = new Map;
    }
    newValues = AdfDhtmlInputSearchPeer._defaultDisplayValueDerivation(component, suggestions, newValues);
    if (isClientOnly) {
      newValues = this._doDisplayValueFormatting(component, this.getDomElement(), converter, newValues);
    }
  }
  return newValues;
};
AdfDhtmlInputSearchPeer.prototype.getConvertedValue = function(component, submittedValues) {
  AdfAssert.assertArray(submittedValues);
  var valueDataType = AdfDhtmlInputSearchPeer.getValueAttributeType(component);
  if (valueDataType == "Number") {
    for (var i = 0, len = submittedValues.length;i < len;i++) {
      submittedValues[i] = Number(submittedValues[i]);
    }
  }
  return submittedValues;
};
AdfDhtmlInputSearchPeer.prototype.ComponentValueChanged = function(component, domElement, newValues, oldValues) {
  if (!newValues) {
    newValues = [];
  } else {
    if (!Array.prototype.isPrototypeOf(newValues)) {
      newValues = [newValues];
    }
  }
  AdfAssert.assertArray(oldValues);
  var suggestionMap = this.GetSuggestionMapContainingSelections(newValues);
  AdfDhtmlInputSearchPeer._deriveAndSetSelection(component, newValues, suggestionMap);
  var realNewValues = this.GetRealNewValues(newValues, oldValues);
  AdfPreferredSuggestionsManager.add(component, realNewValues, suggestionMap);
  AdfDhtmlInputSearchPeer.superclass.ComponentValueChanged.call(this, component, domElement, newValues, oldValues);
  this._setHiddenValueElementsValue(component, domElement, newValues, oldValues);
};
AdfDhtmlInputSearchPeer.prototype.LazyInitialize = function(component, domElement) {
};
AdfDhtmlInputSearchPeer.prototype.GetComponentValue = function(component, domElement) {
  var hiddenValueElems = AdfDhtmlInputSearchPeer._getHiddenValueElements(component, domElement);
  var selections = [];
  if (hiddenValueElems) {
    for (var i = 0;i < hiddenValueElems.length;i++) {
      var value = hiddenValueElems[i].value;
      if (value && value.length > 0) {
        selections.push(value);
      }
    }
  }
  return this.getConvertedValue(component, selections);
};
AdfDhtmlInputSearchPeer.prototype.GetFormattedDisplayValue = function(component, domElement, clientConverter) {
  var rawDisplayValues = this.GetDisplayValue(component, domElement, true);
  return this._doDisplayValueFormatting(component, domElement, clientConverter, rawDisplayValues);
};
AdfDhtmlInputSearchPeer.prototype.GetInlineEditor = function(event) {
  return AdfDhtmlSimpleLabelEditor.getInlineEditor();
};
AdfDhtmlInputSearchPeer.prototype.GetNullDefault = function() {
  return AdfCollections.EMPTY_ARRAY;
};
AdfDhtmlInputSearchPeer.prototype.GetSubmittedValue = function(component, domElement) {
  return this.GetComponentValue(component, domElement);
};
AdfDhtmlInputSearchPeer.prototype.GetCombinedDisplayValue = function(newValues) {
  AdfAssert.failedInAbstractFunction();
};
AdfDhtmlInputSearchPeer.prototype.SetDisplayValue = function(component, domElement, newValues) {
  AdfAssert.assertArray(newValues);
  var newValue = this.GetCombinedDisplayValue(newValues);
  AdfAssert.assertString(newValue);
  this._lastValue = newValue;
  var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component, domElement);
  if (contentNode.tagName == "INPUT") {
    contentNode.value = newValue;
    AdfDhtmlInputBasePeer.setLastValue(contentNode, contentNode.value);
  } else {
    AdfAgent.AGENT.setTextContent(contentNode, newValue);
  }
};
AdfDhtmlInputSearchPeer.prototype.VetoBlurValidation = function() {
  return true;
};
AdfDhtmlInputSearchPeer.prototype.setTextAndShowSuggestions = function(component, newText) {
  var domElement = this.getDomElement();
  var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component, domElement);
  contentNode.value = newText;
  this._filterSuggestions(component);
};
AdfDhtmlInputSearchPeer.GetValue = function(component) {
  return component.getProperty(AdfUIValue.VALUE);
};
AdfDhtmlInputSearchPeer.prototype.DeriveAndSetDisplayValue = function(component, domElement, values) {
  if (!values) {
    values = AdfDhtmlInputSearchPeer.GetValue(component);
  }
  var newDisplayValues = this.getConvertedObject(component, values);
  this.SetDisplayValue(component, domElement, newDisplayValues);
};
AdfDhtmlInputSearchPeer.prototype._doDisplayValueFormatting = function(component, domElement, clientConverter, rawDisplayValues) {
  var label = this.GetComponentLabel(component, domElement);
  try {
    var formattedValues = [];
    for (var i = 0, len = rawDisplayValues.length;i < len;i++) {
      formattedValues.push(clientConverter.getAsString(rawDisplayValues[i], label));
    }
    return formattedValues;
  } catch (e) {
    AdfLogger.LOGGER.logErrorAsSevere(e, "Invoking TrClientConverter.getAsString on component (id\x3d'" + component.getClientId() + "') resulted in an unexpected exception. The component's display value will not be formatted.");
  }
  return rawDisplayValues;
};
AdfDhtmlInputSearchPeer._defaultDisplayValueDerivation = function(component, suggestions, newValues) {
  if (!suggestions || suggestions.size == 0) {
    return newValues;
  }
  var values = [];
  for (var i = 0, length = newValues.length;i < length;i++) {
    var newValue = newValues[i];
    if (newValue) {
      var selectedItem = suggestions.get(newValue);
      if (selectedItem) {
        newValue = AdfDhtmlInputSearchPeer._getDisplayValueFromSelection(component, selectedItem);
      } else {
        newValue = String(newValue);
      }
      values.push(newValue);
    }
  }
  return values;
};
AdfDhtmlInputSearchPeer._deriveDisplayValueFromConv = function(component, converter, newValues) {
  var values = [];
  var label = component.getProperty("label");
  for (var i = 0, length = newValues.length;i < length;i++) {
    var newValue = newValues[i];
    if (newValue) {
      newValue = converter.getAsString(newValue, label);
      if (newValue) {
        values.push(newValue);
      }
    }
  }
  return values;
};
AdfDhtmlInputSearchPeer._getDisplayValueFromSelection = function(component, selectedItem) {
  if (selectedItem) {
    var displayValues = "";
    selectedItem = selectedItem.data;
    var displayAttributes = component.getDisplayAttributes();
    for (var i = 0, len = displayAttributes.length;i < len;i++) {
      var displayValue = selectedItem[displayAttributes[i]];
      if (displayValue != null) {
        displayValues += displayValue + " ";
      }
    }
    return displayValues.trim();
  }
  return null;
};
AdfDhtmlInputSearchPeer._deriveAndSetSelection = function(component, newValues, suggestionMap) {
  if (!suggestionMap) {
    return;
  }
  var newSuggestionsObjs = [];
  for (var i = 0;i < newValues.length;i++) {
    var suggestionObj = suggestionMap.get(newValues[i]);
    if (suggestionObj) {
      newSuggestionsObjs.push(suggestionObj);
    }
  }
  AdfDhtmlInputSearchPeer.SetSelectionProp(component, newSuggestionsObjs);
};
AdfDhtmlInputSearchPeer.prototype.prefetchOrUpdate = function(component, searchSection) {
  this._isPrefetchListComprehensive = null;
  if (this.IsSuggestionPopupVisible(component)) {
    this._lastFilteredText = "";
    this.CacheServerSuggestionsList(null);
    var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component, this.getDomElement());
    this.ShowSuggestionsPopup(component, AdfDhtmlInputBasePeer.getLastValue(contentNode) != contentNode.value) ? "filtering" : "initial";
  } else {
    this._prefetch(component, searchSection);
  }
};
AdfDhtmlInputSearchPeer.getValueAttributeType = function(component) {
  return component.getProperty(AdfDhtmlInputSearchPeer._VALUE_ATTRIBUTE_DATA_TYPE);
};
AdfDhtmlInputSearchPeer.propagateValueAttributeDataType = function(component, suggestions) {
  var sampleValue = suggestions && suggestions.at(0) && suggestions.at(0).key;
  if (sampleValue != null) {
    var typeFunc = sampleValue.constructor;
    var type = null;
    if (typeFunc == Number) {
      type = "Number";
    }
    if (type) {
      component.setProperty(AdfDhtmlInputSearchPeer._VALUE_ATTRIBUTE_DATA_TYPE, type, false, AdfUIComponent.PROPAGATE_ALWAYS);
    } else {
      component.setProperty(AdfDhtmlInputSearchPeer._VALUE_ATTRIBUTE_DATA_TYPE, "String", false, AdfUIComponent.PROPAGATE_NEVER);
    }
  }
};
AdfDhtmlInputSearchPeer.prototype.Component_valJsTypeChanged = function(component, domElement, newValue, oldValue) {
  var values = this.GetComponentValue(component, domElement);
  component.initializeProperty(AdfUIValue.VALUE, values);
};
AdfDhtmlInputSearchPeer.prototype.HandleComponentClick = function(componentEvent) {
  AdfDhtmlInputSearchPeer.superclass.HandleComponentClick.call(this, componentEvent);
  var component = this.getComponent();
  if (!componentEvent.isLeftButtonPressed() || AdfInputSearchUtils.isReadOnlyOrDisabled(component)) {
    return;
  }
  var clientId = component.getClientId();
  var eventTarget = componentEvent.getNativeEventTarget();
  var contentContainer = AdfInputSearchUtils.getContentContainer(component);
  var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component, this.getDomElement());
  if (eventTarget == AdfInputSearchUtils.getSelectionsButton(component)) {
    this.ShowSelectionsPopup(component, contentNode);
    return;
  }
  if (eventTarget == contentNode || eventTarget == contentContainer || eventTarget.parentElement == contentContainer) {
    if (this.IsSelectionsShown(component)) {
      this.ShowSuggestionsPopup(component, "initial");
      component.focus();
      return;
    }
    if (this.IsSuggestionPopupVisible(component)) {
      return;
    }
    contentNode.select();
    component.focus();
    this.ShowSuggestionsPopup(component, "initial");
    return;
  }
  if (this.IsSuggestionPopupVisible(component)) {
    this.GetSuggestionsPanel().handleClick(eventTarget);
  }
};
AdfDhtmlInputSearchPeer.prototype.HandleComponentKeyDown = function(componentEvent) {
  var component = this.getComponent();
  var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component, this.getDomElement());
  if (!this._keyUpNotExecuted) {
    this._keyUpNotExecuted = true;
    this._lastValue = contentNode.value.trim();
  }
  if (this.IsSuggestionPopupVisible(component)) {
    this._toolbarPanel.handleKeyDown(componentEvent, contentNode);
    this.GetSuggestionsPanel().handleKeyDown(componentEvent, contentNode);
  }
};
AdfDhtmlInputSearchPeer.prototype.HandleComponentKeyUp = function(componentEvent) {
  this._keyUpNotExecuted = null;
  var component = this.getComponent();
  var domElement = this.getDomElement();
  var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component, this.getDomElement());
  var keyCode = componentEvent.getKeyCode();
  var isSuggestionPopupVisible = this.IsSuggestionPopupVisible(component);
  if (!isSuggestionPopupVisible) {
    if (keyCode == AdfKeyStroke.ARROWDOWN_KEY) {
      this.ShowSuggestionsPopup(component, "initial");
      return;
    }
    var isRTL = AdfPage.PAGE.getLocaleContext().isRightToLeft();
    var isEndArrowKey = isRTL && keyCode == AdfKeyStroke.ARROWLEFT_KEY || !isRTL && keyCode == AdfKeyStroke.ARROWRIGHT_KEY;
    var isTextCaretAtEndPos = contentNode.selectionEnd == contentNode.value.length;
    if (isEndArrowKey && isTextCaretAtEndPos) {
      this.ShowSelectionsPopup(component, contentNode);
      return;
    }
  } else {
    if (keyCode == AdfKeyStroke.ESC_KEY) {
      this.RestoreSelectionOnEscape(component, domElement, contentNode);
      this.HideSuggestionPopup(component);
    }
  }
  if (keyCode == AdfKeyStroke.TAB_KEY || keyCode == 16) {
    return;
  }
  if (this._hasValueChanged(contentNode.value.trim())) {
    if (!isSuggestionPopupVisible) {
      this.ToggleDisplayValueToFiltering(contentNode, keyCode);
    }
    this._filterSuggestions(component);
  }
};
AdfDhtmlInputSearchPeer.prototype.HandleComponentFocus = function(componentEvent, contentNode) {
  var component = this.getComponent();
  if (!contentNode) {
    contentNode = AdfDhtmlEditableValuePeer.getContentNode(component, this.getDomElement());
  }
  var targetNode = componentEvent.getNativeEventTarget();
  if (targetNode == contentNode) {
    AdfDhtmlInputBasePeer.setLastValue(contentNode);
  }
  AdfDhtmlInputSearchPeer.superclass.HandleComponentFocus.call(this, componentEvent);
};
AdfDhtmlInputSearchPeer.prototype._handleSuggestionsPopupClosed = function(component) {
  var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component, this.getDomElement());
  this.RunValidation(component, contentNode, true);
  var container = contentNode.parentElement;
  container.setAttribute("aria-expanded", "false");
  this._toolbarPanel.detach(component);
  this._suggestionsContainer.detach(component, contentNode, this.GetSuggestionsPanel(), this.IsUnderAutocompletion());
  this.ClearTemporaryStorage();
};
AdfDhtmlInputSearchPeer.prototype._handleSuggestionsPopupOpening = function(component) {
  var container = AdfInputSearchUtils.getContentContainer(component);
  container.setAttribute("aria-expanded", "true");
};
AdfDhtmlInputSearchPeer.SetSelectionProp = function(component, selection) {
  component.setProperty(AdfDhtmlInputSearchPeer.SELECTION_PROPERTY, selection, false, AdfUIComponent.PROPAGATE_ALWAYS);
};
AdfDhtmlInputSearchPeer.prototype.ClearTemporaryStorage = function() {
  if (this._fastKeyInputTimer) {
    AdfPage.PAGE.cancelTimer(this._fastKeyInputTimer);
    this._fastKeyInputTimer = null;
  }
  if (this._serverFilterTimer) {
    AdfPage.PAGE.cancelTimer(this._serverFilterTimer);
    this._serverFilterTimer = null;
  }
  this._keyUpNotExecuted = null;
  this._lastFilteredText = null;
  this.CacheServerSuggestionsList(null);
};
AdfDhtmlInputSearchPeer.prototype.DerivePropsFromPrefSuggestions = function(component, preferredSuggestions) {
  AdfDhtmlInputSearchPeer.propagateValueAttributeDataType(component, preferredSuggestions);
};
AdfDhtmlInputSearchPeer.prototype.GetRealNewValues = function(newValues, oldValues) {
  AdfAssert.failedInAbstractFunction();
};
AdfDhtmlInputSearchPeer.prototype.GetSuggestionMapContainingSelections = function(newValues) {
  AdfAssert.failedInAbstractFunction();
};
AdfDhtmlInputSearchPeer.prototype.GetSuggestionsPanel = function() {
  AdfAssert.failedInAbstractFunction();
};
AdfDhtmlInputSearchPeer.prototype.ShowSelectionsPopup = function(component, contentNode) {
  AdfAssert.failedInAbstractFunction();
};
AdfDhtmlInputSearchPeer.prototype.IsUnderAutocompletion = function() {
  AdfAssert.failedInAbstractFunction();
};
AdfDhtmlInputSearchPeer.prototype.RestoreSelectionOnEscape = function(component, domElement, contentNode) {
  AdfAssert.failedInAbstractFunction();
};
AdfDhtmlInputSearchPeer.prototype.RenderSelections = function(component) {
  AdfAssert.failedInAbstractFunction();
};
AdfDhtmlInputSearchPeer.prototype.ToggleDisplayValueToFiltering = function(contentNode, keyCode) {
  this._lastFilteredText = "";
  this._lastValue = "";
  if (keyCode === AdfKeyStroke.BACKSPACE_KEY || keyCode === AdfKeyStroke.DELETE_KEY) {
    this._lastFilteredText = null;
  }
  AdfDhtmlInputBasePeer.setLastValue(contentNode, "");
};
AdfDhtmlInputSearchPeer.prototype.UpdateDisplayValueAndSelection = function(component, domElement, values, freshSuggestions, isMasterList) {
  var suggestionMap = this.GetSuggestionMapContainingSelections();
  AdfDhtmlInputSearchPeer._deriveAndSetSelection(component, values, suggestionMap);
  this.DeriveAndSetDisplayValue(component, domElement, values);
};
AdfDhtmlInputSearchPeer.__isSimpleFetchRequest = function(options) {
  var serverFilterContext = options._serverFilterContext;
  var request = options[AdfRestDataService.REQUEST_DATA];
  return !serverFilterContext || request.method == "GET" && request.queryString == null;
};
AdfDhtmlInputSearchPeer.prototype._prefetch = function(component, searchSection) {
  var endpoint = searchSection.getDataUrl();
  if (!endpoint) {
    return;
  }
  var isReadonlyOrDisabled = AdfInputSearchUtils.isReadOnlyOrDisabled(component);
  if (searchSection.getType() == AdfDhtmlInputSearchPeer.__SEARCH_SECTION_TYPE_DEFAULT) {
    var value = AdfDhtmlInputSearchPeer.GetValue(component);
    var domElement = this.getDomElement();
    var displayValue = AdfDhtmlEditableValuePeer.getContentNodeText(component, domElement);
    if (value.length !== 0 && displayValue.length === 0) {
      AdfDomUtils.addCSSClassName(domElement, AdfDhtmlInputSearchPeer._VALUE_UPDATING_STYLE_CLASS);
    } else {
      if (isReadonlyOrDisabled) {
        return;
      }
    }
  } else {
    if (isReadonlyOrDisabled) {
      return;
    }
  }
  AdfSequencedSections.fetchSection(component, searchSection, true);
};
AdfDhtmlInputSearchPeer.prototype._fetchAll = function(component) {
  var preferredSuggestions = AdfPreferredSuggestionsManager.get(component);
  var searchSections = AdfInputSearchUtils.getChildrenSection(component, AdfRichSearchSection);
  if (preferredSuggestions) {
    var suggestionsSection = AdfInputSearchUtils.getSuggestionsSection(component);
    var renderingContext = {};
    renderingContext.isPreferredList = true;
    renderingContext.isPartialList = searchSections.length > 1;
    renderingContext.source = suggestionsSection;
    this.GetSuggestionsPanel().render(component, preferredSuggestions, renderingContext);
    if (suggestionsSection.getDontCache()) {
      AdfDomUtils.addCSSClassName(this.getDomElement(), AdfDhtmlInputSearchPeer._VALUE_UPDATING_STYLE_CLASS);
    }
  }
  (new AdfSequencedSections(searchSections)).sendRequests();
};
AdfDhtmlInputSearchPeer.prototype._fetch = function(component, options) {
  var type = AdfDhtmlInputSearchPeer.__SEARCH_SECTION_TYPE_DEFAULT;
  var searchSection = component.getSearchSections()[type];
  if (!searchSection) {
    AdfLogger.LOGGER.severe("Can't locate the searchSection component of type ", type);
    return;
  }
  AdfSequencedSections.fetchSection(component, searchSection, false, options);
};
AdfDhtmlInputSearchPeer.prototype.__getFetchOptions = function(component, searchSection, options, isFiltering) {
  if (!isFiltering) {
    options._isPreferredSuggestionsDisplayed = !!AdfPreferredSuggestionsManager.get(component);
  }
  options._lastValue = AdfDhtmlEditableValuePeer.getContentNode(component, this.getDomElement()).value;
  if (!this._getPrefetchListComprehensive(component)) {
    var context = {};
    context.filterAttributes = component.getFilterAttributes();
    context.criteria = component.getCriteria();
    context.searchTerms = options._isServerFiltering && options._lastValue ? AdfInputSearchMruCache.__splitAndSort(options._lastValue) : null;
    options._serverFilterContext = context;
    options[AdfRestDataService.REQUEST_DATA] = AdfDhtmlSearchSectionPeer.executeFilterParametersFunc(searchSection, context);
  }
  return options;
};
AdfDhtmlInputSearchPeer.prototype.__sequencedCallback = function(component, searchSection, suggestions, isListComprehensive, options, searchSectionIndex) {
  if (searchSection.getType() == AdfDhtmlInputSearchPeer.__SEARCH_SECTION_TYPE_DEFAULT) {
    var hasOtherSearchSections = AdfSuggestionsPanel.removePartialSuggestionsLoadingIndicator(component);
    this.__fetchComplete(component, suggestions, isListComprehensive, options, hasOtherSearchSections);
    return;
  }
  if (!this.IsSuggestionPopupVisible(component) || suggestions.length == 0) {
    return;
  }
  var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component, this.getDomElement());
  var lastValue = AdfDhtmlInputBasePeer.getLastValue(contentNode);
  if (lastValue && lastValue !== contentNode.value) {
    return;
  }
  var renderingContext = {};
  renderingContext.isPartialList = true;
  renderingContext.source = searchSection;
  this.GetSuggestionsPanel().render(component, suggestions, renderingContext);
};
AdfDhtmlInputSearchPeer.prototype.__fetchComplete = function(component, prefilteredSuggestions, isListComprehensive, options, hasOtherSearchSections) {
  var isMasterList = false;
  if (AdfDhtmlInputSearchPeer.__isSimpleFetchRequest(options)) {
    this._isPrefetchListComprehensive = isListComprehensive;
    isMasterList = isListComprehensive;
  }
  var domElement = this.getDomElement();
  if (options._isPreferredSuggestionsDisplayed) {
    AdfDomUtils.removeCSSClassName(domElement, AdfDhtmlInputSearchPeer._VALUE_UPDATING_STYLE_CLASS);
  }
  if (!this.IsSuggestionPopupVisible(component)) {
    if (options._isPreferredSuggestionsDisplayed) {
      this._updateIncompleteDisplayValue(component, domElement, prefilteredSuggestions, isMasterList);
    } else {
      AdfLogger.LOGGER.info("Popup dismissed while fetching the suggestions for InputSearch with client id ", component.getClientId());
    }
    return;
  }
  var serverFilterContext = options._serverFilterContext;
  var cacheTerm = serverFilterContext && serverFilterContext.searchTerms ? serverFilterContext.searchTerms : "";
  this.CacheServerSuggestionsList(prefilteredSuggestions, cacheTerm, isListComprehensive);
  if (options._lastValue !== AdfDhtmlEditableValuePeer.getContentNode(component, domElement).value || options._isClientFiltering) {
    this._filterSuggestionsImpl(component, options._isServerFiltering || !isListComprehensive);
  } else {
    if (options._isPreferredSuggestionsDisplayed) {
      this.GetSuggestionsPanel().update(component, prefilteredSuggestions, isMasterList);
    } else {
      if (!hasOtherSearchSections) {
        var renderingContext = {};
        if (options._isServerFiltering) {
          if (this._isFilteredResultsDisplayed(component, options._lastValue)) {
            return;
          }
          this._lastFilteredText = options._lastValue;
          renderingContext.shouldHighlight = true;
        }
        this.GetSuggestionsPanel().render(component, prefilteredSuggestions, renderingContext);
      }
    }
  }
};
AdfDhtmlInputSearchPeer.prototype.__fetchFailed = function(component, statusCode, response, options) {
  AdfDomUtils.removeCSSClassName(this.getDomElement(), AdfDhtmlInputSearchPeer._VALUE_UPDATING_STYLE_CLASS);
  if (!this.GetSuggestionsPanel().getDisplayedSuggestions()) {
    this.GetSuggestionsPanel().render(component, new AdfSuggestionMap([]));
  }
};
AdfDhtmlInputSearchPeer.prototype._isFilteredResultsDisplayed = function(component, searchText) {
  return this._lastFilteredText == searchText && !AdfSuggestionsContainer.needsUpdate(component);
};
AdfDhtmlInputSearchPeer.prototype.PrefetchComplete = function(component, suggestions, isListComprehensive, needsFurtherFetching) {
  this._isPrefetchListComprehensive = isListComprehensive;
  this.SetDisplayValueOnPrefetch(component, suggestions, isListComprehensive, needsFurtherFetching);
};
AdfDhtmlInputSearchPeer.prototype.__prefetchFailed = function(component, statusCode, response) {
  AdfDomUtils.removeCSSClassName(this.getDomElement(), AdfDhtmlInputSearchPeer._VALUE_UPDATING_STYLE_CLASS);
};
AdfDhtmlInputSearchPeer.prototype.SetDisplayValueOnPrefetch = function(component, suggestions, isListComprehensive, needsFurtherFetching) {
  AdfPreferredSuggestionsManager.update(component, isListComprehensive, suggestions);
  var domElement = AdfRichUIPeer.getDomElementForComponent(component);
  var displayValue = AdfDhtmlEditableValuePeer.getContentNodeText(component, domElement);
  if (displayValue !== "") {
    AdfDomUtils.removeCSSClassName(domElement, AdfDhtmlInputSearchPeer._VALUE_UPDATING_STYLE_CLASS);
    return;
  }
  if (needsFurtherFetching) {
    return;
  }
  AdfDomUtils.removeCSSClassName(domElement, AdfDhtmlInputSearchPeer._VALUE_UPDATING_STYLE_CLASS);
  if (this.IsSuggestionPopupVisible(component)) {
    return;
  }
  var contentNodeValue = AdfDhtmlEditableValuePeer.getContentNodeText(component, domElement);
  if (contentNodeValue == "") {
    this.DeriveAndSetDisplayValue(component, domElement);
  }
};
AdfDhtmlInputSearchPeer.prototype._updateIncompleteDisplayValue = function(component, domElement, prefilteredSuggestions, isMasterList) {
  if (!AdfPreferredSuggestionsManager.isDisplayAttributesCacheable(component)) {
    var values = component.getValue();
    if (values == null || values.length == 0) {
      return;
    }
    this.UpdateDisplayValueAndSelection(component, domElement, values, prefilteredSuggestions, isMasterList);
  }
};
AdfDhtmlInputSearchPeer.prototype.CacheServerSuggestionsList = function(data, searchTerms, isListComprehensive) {
  if (!data) {
    this._suggestionsCacheMap = null;
    return;
  }
  if (isListComprehensive === undefined) {
    isListComprehensive = true;
  }
  if (!this._suggestionsCacheMap) {
    this._suggestionsCacheMap = new AdfInputSearchMruCache(3);
  }
  this._suggestionsCacheMap.put(searchTerms, data, isListComprehensive);
};
AdfDhtmlInputSearchPeer.prototype.GetCachedServerSuggestionsList = function(searchTerms) {
  if (!this._suggestionsCacheMap) {
    return;
  }
  var data = this._suggestionsCacheMap.get(searchTerms);
  if (data) {
    return data[AdfInputSearchMruCache.SUGGESTIONS];
  }
};
AdfDhtmlInputSearchPeer.prototype._getCachedPartialSuggestionsList = function(searchTerms) {
  if (!this._suggestionsCacheMap) {
    this._suggestionsCacheMap = new AdfInputSearchMruCache(3);
  }
  var data = this._suggestionsCacheMap.getBestMatch(searchTerms);
  if (data) {
    return data[AdfInputSearchMruCache.SUGGESTIONS];
  }
};
AdfDhtmlInputSearchPeer._attributeStartsWithFilter = function(component, searchText, suggestions) {
  var filterAttrs = component.getFilterAttributes();
  var userOrderedSearchTerms = searchText.split(" ");
  var searchTerms = searchText.split(" ").sort(function(a, b) {
    return a.length - b.length;
  });
  var filterFunc = function(item) {
    return AdfDhtmlInputSearchPeer._isAttributeStartsWithMatch(item, searchTerms, filterAttrs, userOrderedSearchTerms);
  };
  return suggestions.filter(filterFunc);
};
AdfDhtmlInputSearchPeer._isAttributeStartsWithMatch = function(suggestion, searchTerms, filterAttrs, userOrderedSearchTerms) {
  searchTerms = searchTerms.slice();
  for (var i = filterAttrs.length - 1;i >= 0;i--) {
    var attrValue = suggestion[filterAttrs[i]];
    if (attrValue === null || attrValue === undefined) {
      continue;
    }
    attrValue = attrValue + "";
    for (var j = searchTerms.length - 1;j >= 0;j--) {
      var term = searchTerms[j];
      var whitespaceIndex = AdfDhtmlInputSearchPeer._startsWithWhitespaceIndex(attrValue, term, 0);
      if (whitespaceIndex >= 0) {
        searchTerms.splice(j, 1);
        if (whitespaceIndex > 0) {
          var currentLength = searchTerms.length;
          AdfDhtmlInputSearchPeer._doNextWordMatch(attrValue, whitespaceIndex + 1, term, searchTerms, userOrderedSearchTerms);
          j -= currentLength - searchTerms.length;
        }
        break;
      }
    }
  }
  return searchTerms.length == 0;
};
AdfDhtmlInputSearchPeer._doNextWordMatch = function(attrValue, startIndex, currentTerm, searchTerms, userOrderedSearchTerms) {
  var nextTermIndex = userOrderedSearchTerms.indexOf(currentTerm) + 1;
  if (nextTermIndex >= userOrderedSearchTerms.length) {
    return;
  }
  var nextTerm = userOrderedSearchTerms[nextTermIndex];
  var whitespaceIndex = AdfDhtmlInputSearchPeer._startsWithWhitespaceIndex(attrValue, nextTerm, startIndex);
  if (whitespaceIndex >= 0) {
    var nextTermPosInSearchTerms = searchTerms.indexOf(nextTerm);
    if (nextTermPosInSearchTerms == -1) {
      return;
    }
    searchTerms.splice(nextTermPosInSearchTerms, 1);
    if (whitespaceIndex > 0) {
      AdfDhtmlInputSearchPeer._doNextWordMatch(attrValue, whitespaceIndex + 1, nextTerm, searchTerms, userOrderedSearchTerms);
    }
  }
};
AdfDhtmlInputSearchPeer._startsWithWhitespaceIndex = function(attrValue, term, startIndex) {
  if (attrValue.length - startIndex < term.length) {
    return;
  }
  var i, len;
  for (i = 0, len = term.length;i < len;i++) {
    if (term.charAt(i).toLocaleLowerCase() != attrValue.charAt(i + startIndex).toLocaleLowerCase()) {
      return -1;
    }
  }
  if (attrValue.charAt(len + startIndex) == " ") {
    return len + startIndex;
  }
  return 0;
};
AdfDhtmlInputSearchPeer._getBoundaryRegex = function(word) {
  var specialCharsRegexStr = AdfDhtmlInputSearchPeer._SPECIAL_CHARS_REGEX_STR;
  var firstChar = word.charAt(0);
  if (firstChar == "\\") {
    firstChar = word.charAt(1);
  }
  switch(firstChar) {
    case "\\":
      firstChar = "\\\\";
      break;
    case "-":
      firstChar = "\\-";
      break;
    case "]":
      firstChar = "\\]";
      break;
  }
  if (specialCharsRegexStr.indexOf(firstChar)) {
    specialCharsRegexStr = specialCharsRegexStr.replace(firstChar, "");
  }
  return "(?:^|[\\s" + specialCharsRegexStr + "])+" + "(?\x3d[^\\s" + specialCharsRegexStr + "])";
};
AdfDhtmlInputSearchPeer._getBoundaryRegexList = function(searchTextList) {
  var list = [];
  for (var i = 0, len = searchTextList.length;i < len;i++) {
    list.push(AdfDhtmlInputSearchPeer._getBoundaryRegex(searchTextList[i]));
  }
  return list;
};
AdfDhtmlInputSearchPeer._getContainsFilterRegex = function(searchText) {
  searchText = AdfInputSearchUtils.escapeRegexChars(searchText);
  var searchTextList = AdfInputSearchUtils.splitAndSort(searchText);
  var boundaryRegexList = AdfDhtmlInputSearchPeer._getBoundaryRegexList(searchTextList);
  var regex = "^";
  for (var z = 0, lenz = searchTextList.length;z < lenz;z++) {
    regex += "(?\x3d[\\s\\S]*?" + boundaryRegexList[z] + "(\\w*?)(";
    if (z != 0) {
      regex += "?!";
      for (var y = 1;y <= z;y++) {
        regex += "\\" + 2 * y + "$|";
      }
      regex = regex.substr(0, regex.length - 1) + ")(";
      regex += searchTextList[z] + "(?:(?\x3d[\\s\\S]*?" + boundaryRegexList[z] + "(?:";
      for (var y = 1;y <= z;y++) {
        regex += "\\" + 2 * y + "$|";
      }
      regex = regex.substr(0, regex.length - 1) + "))|(?![\\s\\S]*?" + boundaryRegexList[z] + searchTextList[z] + "))";
    } else {
      regex += searchTextList[z] + "(?![\\s\\S]*?" + boundaryRegexList[z] + searchTextList[z] + ")";
    }
    regex += "[\\s\\S]*))";
  }
  var re = new RegExp(regex, "gi");
  AdfLogger.LOGGER.config("The regex used for filtering is ", re);
  return re;
};
AdfDhtmlInputSearchPeer._getStartsWithFilterRegex = function(searchText) {
  searchText = AdfInputSearchUtils.escapeRegexChars(searchText);
  var searchTextList = AdfInputSearchUtils.splitAndSort(searchText);
  var boundaryRegexList = AdfDhtmlInputSearchPeer._getBoundaryRegexList(searchTextList);
  var preSearchTextMatcher = "(?\x3d[\\s\\S]*?";
  var regex = "^";
  for (var z = 0, lenz = searchTextList.length;z < lenz;z++) {
    regex = regex + preSearchTextMatcher + boundaryRegexList[z] + "(";
    if (z != 0) {
      regex += "?!";
      for (var y = 1;y <= z;y++) {
        regex += "\\" + y + "$|";
      }
      regex = regex.substr(0, regex.length - 1) + ")(";
    }
    regex += searchTextList[z] + "[\\s\\S]*))";
  }
  var re = new RegExp(regex, "gi");
  AdfLogger.LOGGER.config("The regex used for filtering is ", re);
  return re;
};
AdfDhtmlInputSearchPeer._concatenateFilterAttributeValues = function(filterAttributes, suggestionItem) {
  var filterStr = "";
  for (var j = 0, lenj = filterAttributes.length;j < lenj;j++) {
    var filterKey = filterAttributes[j];
    var value = suggestionItem[filterKey];
    if (value) {
      filterStr += value + " ";
    }
  }
  return filterStr;
};
AdfDhtmlInputSearchPeer._containsFilter = function(component, searchText, data) {
  var searchText = searchText;
  var re = AdfDhtmlInputSearchPeer._getContainsFilterRegex(searchText);
  var filterAttributes = component.getFilterAttributes();
  var scoredCollection = new Array(searchText.split(" ").length + 1);
  for (var i = 0, len = scoredCollection.length;i < len;i++) {
    scoredCollection[i] = [];
  }
  var filterFunc = function(item, key, index, suggestionObj) {
    var filterStr = AdfDhtmlInputSearchPeer._concatenateFilterAttributeValues(filterAttributes, item);
    var matchProps = re.exec(filterStr);
    unicode_regex = /[^\u0000-\u00ff]/;
    if (unicode_regex.test(searchText)) {
      score = 0;
      if (filterStr.indexOf(searchText) != -1) {
        scoredCollection[score].push(suggestionObj);
      }
    } else {
      if (matchProps != null) {
        var score = 0;
        for (var k = 1, len = matchProps.length;k < len;k += 2) {
          if (matchProps[k] == "") {
            score++;
          }
        }
        scoredCollection[score].push(suggestionObj);
      }
      re.lastIndex = 0;
    }
  };
  data.forEach(filterFunc);
  var scoredOrderedSuggestions = [];
  for (var i = scoredCollection.length - 1;i >= 0;i--) {
    scoredOrderedSuggestions = scoredOrderedSuggestions.concat(scoredCollection[i]);
  }
  return new AdfSuggestionMap(scoredOrderedSuggestions, data);
};
AdfDhtmlInputSearchPeer._startsWithFilter = function(component, searchText, data) {
  var re = AdfDhtmlInputSearchPeer._getStartsWithFilterRegex(searchText);
  var filterAttributes = component.getFilterAttributes();
  var filterFunc = function(item) {
    var filterStr = AdfDhtmlInputSearchPeer._concatenateFilterAttributeValues(filterAttributes, item);
    var hasMatched = re.test(filterStr);
    re.lastIndex = 0;
    return hasMatched;
  };
  return data.filter(filterFunc);
};
AdfDhtmlInputSearchPeer.prototype._filterSuggestions = function(component) {
  var page = AdfPage.PAGE;
  var time = 70;
  if (this._fastKeyInputTimer) {
    page.rescheduleTimer(this._fastKeyInputTimer, time);
  } else {
    this._fastKeyInputTimer = page.scheduleTimer(this, this._filterSuggestionsCallback, component, time, {"isSynchronized":true});
  }
  if (this._serverFilterTimer) {
    AdfPage.PAGE.cancelTimer(this._serverFilterTimer);
    this._serverFilterTimer = null;
  }
};
AdfDhtmlInputSearchPeer.prototype._filterSuggestionsCallback = function(component) {
  this._fastKeyInputTimer = null;
  this._filterSuggestionsImpl(component);
};
AdfDhtmlInputSearchPeer.prototype._filterSuggestionsImpl = function(component, knownPartialListCase, forceFiltering) {
  var searchText = AdfDhtmlEditableValuePeer.getContentNode(component, this.getDomElement()).value.trim();
  this._lastValue = searchText;
  if (!forceFiltering && this._isFilteredResultsDisplayed(component, searchText)) {
    return;
  }
  var renderingContext = {};
  renderingContext.shouldHighlight = !!searchText;
  if (knownPartialListCase) {
    renderingContext.isPartialList = true;
  } else {
    this.ShowSuggestionsPopup(component, "filtering");
  }
  var list = this.GetCachedServerSuggestionsList(searchText);
  if (!list) {
    list = this._getCachedPartialSuggestionsList(searchText);
    renderingContext.isPartialList = true;
    if (!list) {
      return;
    }
  }
  var criteria = component.getCriteria();
  if (!searchText) {
    this.GetSuggestionsPanel().render(component, list, renderingContext);
  } else {
    if (criteria == AdfRichInputSearch.CRITERIA_CONTAINS) {
      var suggestions = AdfDhtmlInputSearchPeer._containsFilter(component, searchText, list);
      this.GetSuggestionsPanel().render(component, suggestions, renderingContext);
    } else {
      if (criteria == AdfRichInputSearch.CRITERIA_ATTRIBUTE_STARTS_WITH) {
        var suggestions = AdfDhtmlInputSearchPeer._attributeStartsWithFilter(component, searchText, list);
        this.GetSuggestionsPanel().render(component, suggestions, renderingContext);
      } else {
        var suggestions = AdfDhtmlInputSearchPeer._startsWithFilter(component, searchText, list);
        this.GetSuggestionsPanel().render(component, suggestions, renderingContext);
      }
    }
  }
  this._lastFilteredText = searchText;
};
AdfDhtmlInputSearchPeer.prototype._getPrefetchListComprehensive = function(component) {
  AdfAssert.assert(this._isPrefetchListComprehensive !== undefined, "This method should not be invoked before prefetchOrUpdate is invoked");
  if (this._isPrefetchListComprehensive === null) {
    var ss = component.getSearchSections()[AdfDhtmlInputSearchPeer.__SEARCH_SECTION_TYPE_DEFAULT];
    this._isPrefetchListComprehensive = !ss.getFilterParameters();
  }
  return this._isPrefetchListComprehensive;
};
AdfDhtmlInputSearchPeer.prototype._hasValueChanged = function(contentNodeValue) {
  if (contentNodeValue != this._lastValue) {
    this._lastValue = contentNodeValue;
    return true;
  }
  return false;
};
AdfDhtmlInputSearchPeer._createHiddenValueElement = function(component, contentContainer) {
  var hiddenValueElem = document.createElement("input");
  hiddenValueElem.setAttribute("type", "hidden");
  hiddenValueElem.setAttribute("name", component.getClientId());
  contentContainer.appendChild(hiddenValueElem);
  return hiddenValueElem;
};
AdfDhtmlInputSearchPeer._getHiddenValueElements = function(component, domElement) {
  if (!domElement) {
    domElement = component.getDomElement();
  }
  var attributeName = component.getReadOnly() ? AdfDhtmlInputSearchPeer._CUSTOM_NAME_EXPANDO : "name";
  return domElement.querySelectorAll("[" + attributeName + "\x3d'" + component.getClientId() + "']");
};
AdfDhtmlInputSearchPeer.prototype._setHiddenValueElementsValue = function(component, domElement, newValues, oldValues) {
  var hiddenValueElems = AdfDhtmlInputSearchPeer._getHiddenValueElements(component, domElement);
  var contentContainer = AdfInputSearchUtils.getContentContainer(component);
  var i = 0;
  for (var length = newValues.length;i < length;i++) {
    var hiddenValueElem = hiddenValueElems[i];
    if (!hiddenValueElem) {
      hiddenValueElem = AdfDhtmlInputSearchPeer._createHiddenValueElement(component, contentContainer);
    }
    hiddenValueElem.value = newValues[i];
  }
  for (var length = hiddenValueElems.length;i < length;i++) {
    contentContainer.removeChild(hiddenValueElems[i]);
  }
};
AdfDhtmlInputSearchPeer._setIdOnLabelElement = function(component, contentNode) {
  var labelElement = AdfDhtmlEditableValuePeer.GetLabelElement(contentNode);
  if (labelElement) {
    labelElement.setAttribute("id", AdfInputSearchUtils.getLabelId(component));
  } else {
    AdfLogger.LOGGER.severe("Label not defined or for attribute not set for inputSearch ", contentNode.id);
  }
};
AdfDhtmlInputSearchPeer.prototype._getSuggestionsPopupDomElement = function(component) {
  var clientId = component.getClientId();
  var suggestionsPopupId = AdfRichUIPeer.createSubId(clientId, AdfDhtmlInputSearchPeer._SUGGESTIONS_POPUP_SUB_ID);
  var suggestionsPopup = document.getElementById(suggestionsPopupId);
  if (suggestionsPopup) {
    return suggestionsPopup;
  }
  suggestionsPopup = document.createElement("div");
  suggestionsPopup.setAttribute("id", suggestionsPopupId);
  if (component.getStyleClass()) {
    suggestionsPopup.setAttribute("class", component.getStyleClass());
  }
  return suggestionsPopup;
};
AdfDhtmlInputSearchPeer.prototype.IsSelectionsShown = function(component) {
  var popupWindow = this.__getSuggestionPopupWindow(component);
  return popupWindow && popupWindow._isSelections;
};
AdfDhtmlInputSearchPeer.prototype.__getSuggestionPopupWindow = function(component) {
  return this.getPopupWindow(component, AdfDhtmlInputSearchPeer._SUGGESTIONS_POPUP_SUB_ID);
};
AdfDhtmlInputSearchPeer.prototype.IsSuggestionPopupVisible = function(component) {
  return this.isPopupVisible(component, AdfDhtmlInputSearchPeer._SUGGESTIONS_POPUP_SUB_ID);
};
AdfDhtmlInputSearchPeer.prototype.HideSuggestionPopup = function(component) {
  this.hidePopup(component, AdfDhtmlInputSearchPeer._SUGGESTIONS_POPUP_SUB_ID);
};
AdfDhtmlInputSearchPeer.prototype._getSuggestionsPopupHints = function(component) {
  var clientId = component.getClientId();
  var hints = {};
  hints[AdfDhtmlPopupHints.TYPE] = AdfDhtmlPopupHints.TYPE_MENU;
  hints[AdfDhtmlPopupHints.AUTODISMISS] = AdfDhtmlPopupHints.AUTODISMISS_MENU;
  hints[AdfDhtmlPopupHints.CLOSE_ON_ESCAPE] = true;
  hints[AdfDhtmlPopupHints.CLOSE_HANDLER] = this.createCallback(this._handleSuggestionsPopupClosed);
  hints[AdfDhtmlPopupHints.CLOSE_HANDLER_PARAM] = component;
  hints[AdfDhtmlPopupHints.OPENED_HANDLER] = this.createCallback(this._handleSuggestionsPopupOpening);
  hints[AdfDhtmlPopupHints.OPENED_HANDLER_PARAM] = component;
  hints[AdfRichPopup.HINT_ALIGN_ID] = AdfDhtmlEditableValuePeer.GetContentNodeId(component);
  hints[AdfRichPopup.HINT_ALIGN] = AdfRichPopup.ALIGN_AFTER_START;
  hints[AdfRichPopup.HINT_LAUNCH_ID] = clientId;
  hints[AdfDhtmlPopupHints.ANIMATE] = AdfRichPopup.ANIMATE_FALSE;
  hints[AdfDhtmlPopupHints.FOCUS] = false;
  if (window.AdfSafariMobileAgent && AdfAgent.AGENT instanceof AdfSafariMobileAgent) {
    this.preventNextValueSubmission();
  }
  hints[AdfDhtmlPopupHints.COMPONENT_EVENTS_ENABLED] = true;
  return hints;
};
AdfDhtmlInputSearchPeer.prototype.ShowSuggestionsPopup = function(component, state) {
  var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component, this.getDomElement());
  var popupWindow = this.__getSuggestionPopupWindow(component);
  if (popupWindow) {
    popupWindow._isSelections = false;
    this._suggestionsContainer.reset(component, contentNode, this.GetSuggestionsPanel());
  } else {
    if (state != "filtering") {
      this.ToggleDisplayValueToFiltering(contentNode);
    }
    var suggestionsPopup = this._getSuggestionsPopupDomElement(component);
    this._toolbarPanel.attach(component, suggestionsPopup);
    this._suggestionsContainer.attach(component, suggestionsPopup);
    var popupHints = this._getSuggestionsPopupHints(component);
    this.showPopup(component, suggestionsPopup, popupHints, AdfDhtmlInputSearchPeer._SUGGESTIONS_POPUP_SUB_ID);
  }
  this._showSuggestions(component, state, contentNode);
};
AdfDhtmlInputSearchPeer.prototype._showSuggestions = function(component, state, contentNode) {
  if (state == "selections") {
    this.__getSuggestionPopupWindow(component)._isSelections = true;
    this.RenderSelections(component);
  } else {
    if (state == "initial") {
      AdfPage.PAGE.__perfTimings(true, true, true, "inputSearch: user click: show suggestions: id\x3d", component.getClientId());
      this._fetchAll(component);
    } else {
      var searchText = contentNode.value.trim();
      AdfPage.PAGE.__perfTimings(true, true, true, "inputSearch: user click: filter values: id\x3d", component.getClientId(), ", terms\x3d", searchText);
      this._fetchSuggestionsIfNeeded(component, searchText);
    }
  }
};
AdfDhtmlInputSearchPeer.prototype._fetchSuggestionsIfNeeded = function(component, searchText) {
  var data = this.GetCachedServerSuggestionsList(searchText);
  if (!data) {
    if (this._getPrefetchListComprehensive(component)) {
      var options = {};
      options._isClientFiltering = true;
      this._fetch(component, options);
    } else {
      var time = AdfDhtmlInputSearchPeer._getServerFilterDelay(searchText.length);
      var page = AdfPage.PAGE;
      if (this._serverFilterTimer) {
        page.rescheduleTimer(this._serverFilterTimer, time);
      } else {
        this._serverFilterTimer = page.scheduleTimer(this, this._serverFiltering, component, time, {"isSynchronized":true});
      }
    }
  }
};
AdfDhtmlInputSearchPeer.prototype._serverFiltering = function(component) {
  this._serverFilterTimer = null;
  var options = {};
  options._isServerFiltering = true;
  this._fetch(component, options);
};
AdfDhtmlInputSearchPeer._getServerFilterDelay = function(searchTermsLength) {
  switch(searchTermsLength) {
    case 0:
      return 500;
    case 1:
      return 1E3;
    case 2:
      return 700;
    case 3:
      return 500;
    default:
      return 300;
  }
};
