import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-baa5e267.js';
import { C as CSSVarsUtils } from './CSSVarsUtils-acba92d7.js';
import { ObjectUtils, StringUtils, ElementIDUtils } from '@sankhyalabs/core';
import { A as ApplicationUtils } from './ApplicationUtils-1569f757.js';
import './DialogType-54a62731.js';
import './CheckMode-bdb2ec19.js';
import { i as initI18n } from './index-41363fa6.js';
import './FormLayout-071d324c.js';
import { r as replaceQuotes, a as replaceHighlight } from './searchFormatters-8229207e.js';

const ezSearchCss = ":host{--ez-search--height:42px;--ez-search--width:100%;--ez-search__icon--width:48px;--ez-search--border-radius:var(--border--radius-medium, 12px);--ez-search--border-radius-small:var(--border--radius-small, 6px);--ez-search--font-size:var(--text--medium, 14px);--ez-search--font-family:var(--font-pattern, Arial);--ez-search--font-weight--large:var(--text-weight--large, 500);--ez-search--font-weight--medium:var(--text-weight--medium, 400);--ez-search--background-color--xlight:var(--background--xlight, #fff);--ez-search--background-medium:var(--background--medium, #f0f3f7);--ez-search--line-height:calc(var(--text--medium, 14px) + 4px);--ez-search__input--background-color:var(--background--medium, #e0e0e0);--ez-search__input--border:var(--border--medium, 2px solid);--ez-search__input--border-color:var(--ez-search__input--background-color);--ez-search__input--focus--border-color:var(--color--primary, #008561);--ez-search__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-search__input--disabled--color:var(--text--disable, #AFB6C0);--ez-search__input--error--border-color:#CC2936;--ez-search__btn--color:var(--title--primary, #2B3A54);--ez-search__btn-disabled--color:var(--text--disable, #AFB6C0);--ez-search__btn-hover--color:var(--color--primary, #4e4e4e);--ez-search__label--color:var(--title--primary, #2B3A54);--ez-search--space--medium:var(--space--medium, 12px);--ez-search--space--small:var(--space--small, 6px);display:flex;flex-wrap:wrap;position:relative;width:var(--ez-search--width)}ez-icon{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.suppressed-search-input{--ez-text-input__input--border-color:var(--color--strokes, #dce0e8);--ez-text-input__input--disabled--background-color:var(--background--xlight, #fff);--ez-text-input__input--disabled--color:var(--title--primary, #2B3A54)}.btn{outline:none;border:none;background:none;cursor:pointer;color:var(--ez-search__btn--color)}.btn:disabled{cursor:not-allowed;color:var(--ez-search__btn-disabled--color)}.btn:disabled:hover{cursor:not-allowed;color:var(--ez-search__btn-disabled--color)}.btn:hover{color:var(--ez-search__btn-hover--color)}.btn__close{visibility:hidden}ez-text-input:hover .btn__close,ez-text-input:focus .btn__close{visibility:visible}";

const EzSearch = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.ezChange = createEvent(this, "ezChange", 7);
    this._changeDeboucingTimeout = null;
    this._limitCharsToSearch = 3;
    this._deboucingTime = 300;
    this._maxWidthValue = 0;
    this._tabPressed = false;
    this._startHighlightTag = "<span class='card-item__highlight'>";
    this._endHighlightTag = "</span>";
    this._preSelection = undefined;
    this._visibleOptions = undefined;
    this._startLoading = false;
    this._showLoading = true;
    this._showLoadingDescription = false;
    this._criteria = undefined;
    this.value = undefined;
    this.label = undefined;
    this.enabled = true;
    this.errorMessage = undefined;
    this.optionLoader = undefined;
    this.contextProperties = undefined;
    this.showSelectedValue = true;
    this.showOptionValue = true;
    this.suppressEmptyOption = false;
    this.stopPropagateEnterKeyEvent = false;
    this.mode = "regular";
    this.canShowError = true;
    this.hideErrorOnFocusOut = true;
    this.listOptionsPosition = undefined;
    this.isTextSearch = false;
    this.ignoreLimitCharsToSearch = false;
    this.options = undefined;
    this.suppressSearch = false;
    this.ensureClearButtonVisible = false;
    this.suppressPreLoad = true;
    this.autoFocus = false;
    this.alternativePlaceholder = undefined;
  }
  observeErrorMessage() {
    var _a;
    if (this._textInput) {
      this._textInput.errorMessage = this.errorMessage;
      if (!((_a = this.errorMessage) === null || _a === void 0 ? void 0 : _a.trim()) && this.errorMessage) {
        this.setInputValue();
      }
    }
  }
  getValue(val) {
    return typeof val === 'object' ? val === null || val === void 0 ? void 0 : val.value : val;
  }
  validateNewValue(newValue, oldValue) {
    const parsedNewValue = this.getValue(newValue);
    const parsedOldValue = this.getValue(oldValue);
    const newValueIsValid = parsedNewValue !== "[object Object]";
    const valuesIsDifferent = parsedNewValue !== parsedOldValue;
    if (newValueIsValid && valuesIsDifferent) {
      return true;
    }
    return false;
  }
  async observeValue(newValue, oldValue) {
    if (this._textInput && this.validateNewValue(newValue, oldValue)) {
      if (typeof newValue === "string") {
        await this.handleValueAsString(newValue);
        return;
      }
      const newValueSelected = this.getSelectedOption(newValue);
      const currentValue = this.getSelectedOption(this._currentValue);
      if (this.isDifferentValues(currentValue, newValueSelected)) {
        this._currentValue = newValueSelected;
        this.setInputValue();
        const valueEmitted = newValueSelected !== null && newValueSelected !== void 0 ? newValueSelected : undefined;
        this.ezChange.emit(valueEmitted);
      }
      this.resetOptions();
    }
  }
  observeOptions(newOptions, oldOptions) {
    if (!newOptions.length && this.suppressPreLoad)
      return;
    if ((newOptions === null || newOptions === void 0 ? void 0 : newOptions.join('')) === (oldOptions === null || oldOptions === void 0 ? void 0 : oldOptions.join('')))
      return;
    this.loadOptions(SearchMode.PRELOAD);
  }
  /*
  * Retorna uma promise com o valor da opção selecionada,
  * que será resolvida quando o backend devolver este dado.
  */
  async getValueAsync() {
    if (!this._showLoading) {
      return new Promise(resolve => resolve(this.value));
    }
    return new Promise(resolve => {
      let id = setInterval(() => {
        if (!this._showLoading) {
          clearInterval(id);
          resolve(this.value);
        }
      }, 100);
    });
  }
  /**
   * Aplica o foco no campo.
   */
  async setFocus(options) {
    if (this._textInput) {
      this._textInput.setFocus(options);
    }
  }
  /**
   * Remove o foco do campo.
   */
  async setBlur() {
    if (this._textInput) {
      this._textInput.setBlur();
    }
  }
  /**
   * Retorna se o conteúdo é inválido.
   */
  async isInvalid() {
    return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
  }
  /**
   * Limpa o valor do campo de pesquisa
   */
  async clearValue() {
    this.clearSearch();
  }
  async handleValueAsString(value) {
    if (this.getSelectedOption(value)) {
      this.setInputValue();
      return;
    }
    await this.loadDescriptionValue(value);
    if (!this._currentValue) {
      return;
    }
    this.setInputValue();
    this.ezChange.emit(this.value);
    this._currentValue = this.value;
  }
  isDifferentValues(firstValue, secondValue) {
    return ObjectUtils.objectToString(firstValue || {}) !== ObjectUtils.objectToString(secondValue || {});
  }
  getFormattedText(currentValue) {
    if (currentValue == undefined) {
      return;
    }
    let text = (!this.showSelectedValue || currentValue.value == undefined) ? currentValue.label : currentValue.label ? `${currentValue.value} - ${currentValue.label}` : currentValue.value;
    text = text === null || text === void 0 ? void 0 : text.replace(new RegExp(this._startHighlightTag, 'g'), '').replace(new RegExp(this._endHighlightTag, 'g'), '');
    return text;
  }
  getText() {
    const currentValue = this.getSelectedOption(this._currentValue);
    const text = this.getFormattedText(currentValue);
    return replaceQuotes(text);
  }
  getSelectedOption(value) {
    if (typeof value === "string" || value instanceof String) {
      return this._visibleOptions.find(o => o.value === value);
    }
    if (value) {
      return Object.assign(Object.assign({}, value), { value: replaceHighlight(value === null || value === void 0 ? void 0 : value.value), label: replaceHighlight(value === null || value === void 0 ? void 0 : value.label) });
    }
    return value;
  }
  updateVisibleOptions() {
    let opts = this._source || [];
    if (this.suppressEmptyOption) {
      this._visibleOptions = opts;
    }
    else {
      this._visibleOptions = [{ value: undefined, label: "" }].concat(opts);
    }
    this._maxWidthValue = this.getMaxWidthValue();
  }
  getMaxWidthValue() {
    var _a;
    const arrValues = [];
    (_a = this._visibleOptions) === null || _a === void 0 ? void 0 : _a.forEach(opt => {
      const widthValue = this.getWidthValue(opt.value);
      if (!arrValues.includes(widthValue)) {
        arrValues.push(widthValue);
      }
    });
    return arrValues.length > 1 ? Math.max(...arrValues) : 0;
  }
  getWidthValue(value) {
    if (this._itemValueBasis != undefined) {
      const span = this._itemValueBasis;
      if (value != undefined) {
        span.innerHTML = value;
        return span.clientWidth > 0 ? (span.clientWidth + 2) : 0;
      }
      else {
        span.innerHTML = "";
      }
    }
    return 0;
  }
  showOptions() {
    if (!this.enabled)
      return;
    if (this.isOptionsVisible()) {
      return;
    }
    this._ezPopOverPlusElement.showUnder(this._textInput);
  }
  hideOptions() {
    this._ezPopOverPlusElement.hide();
  }
  isOptionsVisible() {
    return this._ezPopOverPlusElement.opened;
  }
  selectCurrentOption(focusOnInput = true) {
    if (this._preSelection !== undefined) {
      this.selectOption(this._visibleOptions[this._preSelection], focusOnInput);
      this._preSelection = undefined;
    }
    else {
      this.controlListWithOnlyOne();
    }
  }
  updateSource(source) {
    this._startLoading = false;
    if (source instanceof Promise) {
      this._showLoading = true;
      this._showLoadingDescription = true;
      source.then(result => {
        this.updateSource(result);
      }).finally(() => {
        this._showLoading = false;
        this._showLoadingDescription = false;
      });
      this.updateVisibleOptions();
    }
    else {
      this._showLoading = false;
      if (Array.isArray(source)) {
        this._source = source;
        this.updateVisibleOptions();
        if (this._tabPressed) {
          this._tabPressed = false;
          this.controlEmptySearch(false);
        }
      }
      else {
        this.selectOption(source);
      }
    }
  }
  clearSource() {
    this._source = [];
    this.updateVisibleOptions();
  }
  selectOption(newOption, focusOnInput = true) {
    var _a, _b;
    const currentValue = this.getSelectedOption(this.value);
    const newOptionsReplaced = Object.assign(Object.assign({}, newOption), { value: replaceHighlight(newOption === null || newOption === void 0 ? void 0 : newOption.value), label: replaceHighlight(newOption === null || newOption === void 0 ? void 0 : newOption.label) });
    const newOptionsFormatted = Object.assign(Object.assign({}, newOptionsReplaced), { value: replaceQuotes(newOptionsReplaced === null || newOptionsReplaced === void 0 ? void 0 : newOptionsReplaced.value), label: replaceQuotes(newOptionsReplaced === null || newOptionsReplaced === void 0 ? void 0 : newOptionsReplaced.label) });
    if ((((_a = currentValue === null || currentValue === void 0 ? void 0 : currentValue.value) === null || _a === void 0 ? void 0 : _a.toString()) !== ((_b = newOptionsFormatted === null || newOptionsFormatted === void 0 ? void 0 : newOptionsFormatted.value) === null || _b === void 0 ? void 0 : _b.toString()))
      || (currentValue == undefined && newOptionsFormatted != undefined && "value" in newOptionsFormatted)) {
      const adjustedOpt = !(newOptionsFormatted === null || newOptionsFormatted === void 0 ? void 0 : newOptionsFormatted.value) ? undefined : newOptionsFormatted;
      this.value = adjustedOpt;
      this._currentValue = adjustedOpt;
    }
    else {
      this.setInputValue();
      this.resetOptions();
    }
    this._visibleOptions = [];
    this.clearSource();
    if (focusOnInput) {
      setTimeout(() => {
        this.setFocus();
      }, 0);
    }
  }
  loadOptions(mode, argument = "") {
    this._criteria = argument;
    this._startLoading = true;
    if (this.optionLoader) {
      const searchArgument = { mode, argument };
      this.updateSource(this.optionLoader(searchArgument, this.contextProperties));
    }
    else {
      this.updateSource(this.options);
    }
  }
  cancelPreselection() {
    if (!this._textInput.value && this._currentValue && this._source.length > 0) {
      this.selectOption(undefined);
    }
    else {
      window.setTimeout(() => {
        this.setInputValue();
      }, this._deboucingTime);
    }
    this.resetOptions();
  }
  setInputValue(clearError = true) {
    const textValue = this.getText();
    if ((this._textInput.value || '') !== textValue) {
      this._textInput.value = textValue;
      if (clearError) {
        this.errorMessage = null;
      }
    }
  }
  clearSearch() {
    this.value = null;
    this._currentValue = null;
  }
  controlListWithOnlyOne(focusOnInput = true) {
    var _a, _b;
    const source = (_a = this._visibleOptions) === null || _a === void 0 ? void 0 : _a.filter((opt) => opt.label !== "" && opt.value != undefined);
    if ((source === null || source === void 0 ? void 0 : source.length) > 0) {
      const startHighlight = new RegExp(this._startHighlightTag, 'g');
      const endHighlight = new RegExp(this._endHighlightTag, 'g');
      let title = StringUtils.decodeHtmlEntities(source[0].label);
      const option = {
        value: (_b = source[0].value) === null || _b === void 0 ? void 0 : _b.replace(startHighlight, '').replace(endHighlight, ''),
        label: title === null || title === void 0 ? void 0 : title.replace(startHighlight, '').replace(endHighlight, '')
      };
      this.selectOption(option, focusOnInput);
    }
  }
  controlEmptySearch(focusOnInput = true) {
    var _a;
    if (!((_a = this._visibleOptions) === null || _a === void 0 ? void 0 : _a.length)) {
      this.clearSearch();
      ApplicationUtils.info(this.i18n("ez-search.emptyList"));
    }
    else {
      this.controlListWithOnlyOne(focusOnInput);
    }
  }
  async loadDescriptionValue(argument) {
    var _a, _b;
    if (argument == undefined) {
      return;
    }
    if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.length) > 0) {
      this.loadOptionValue(argument);
      return;
    }
    const searchArgument = {
      mode: SearchMode.PREDICTIVE,
      argument
    };
    const source = await ((_b = this.optionLoader) === null || _b === void 0 ? void 0 : _b.call(this, searchArgument, this.contextProperties));
    if (source == undefined) {
      return;
    }
    if (source instanceof Promise) {
      source.then((result) => {
        this.setDescriptionValue(result);
      });
    }
    else {
      this.setDescriptionValue(source);
    }
  }
  setDescriptionValue(source) {
    const value = (source === null || source === void 0 ? void 0 : source[0]) || source;
    if (value == undefined || !Object.keys(value).length) {
      this.showNoResultMessage();
      return;
    }
    this._currentValue = value ? Object.assign(Object.assign({}, value), { value: replaceHighlight(value.value), label: replaceHighlight(value.label) }) : value;
    this.value = this._currentValue;
    this.setTextInputValue();
  }
  setTextInputValue() {
    if (this._textInput && (this._textInput.value === null || this._textInput.value === undefined)) {
      if (this.value === undefined || this.value === null)
        return;
      const textValue = (typeof this.value === 'string') ? this.value : this.getFormattedText(this.value);
      this._textInput.value = replaceQuotes(textValue);
    }
  }
  loadOptionValue(argument) {
    var _a;
    const source = (_a = this.options) === null || _a === void 0 ? void 0 : _a.find((opt) => opt.value === argument);
    if (source != undefined) {
      this.selectOption(source);
    }
    else {
      this.showNoResultMessage();
    }
  }
  async showNoResultMessage() {
    this.clearSearch();
    ApplicationUtils.info(this.i18n("ez-search.emptySearch", { field: this.getFieldLabel() }));
  }
  getFieldLabel() {
    var _a;
    return (_a = this.label) === null || _a === void 0 ? void 0 : _a.replace(this.i18n("app.requiredInfo"), "").toUpperCase();
  }
  resetOptions() {
    this.hideOptions();
    this._criteria = undefined;
    this._preSelection = undefined;
    this.updateVisibleOptions();
  }
  async handleInitialValue() {
    const valueIsValid = !!this.getValue(this.value);
    if (!valueIsValid) {
      return;
    }
    if (typeof this.value === "string") {
      await this.handleValueAsString(this.value);
      return;
    }
    let text = this.getFormattedText(this.value);
    text = replaceQuotes(text);
    this._textInput.value = text;
  }
  //---------------------------------------------
  // Lifecycle web component
  //---------------------------------------------
  async componentWillLoad() {
    this.i18n = await initI18n();
    if (this.options === undefined) {
      this.options = [];
      const optionsTags = this.el.querySelectorAll("option");
      if (optionsTags) {
        optionsTags.forEach(e => {
          let label = e.innerText;
          let value = e.getAttribute("value");
          let details = e.getAttribute("details");
          if (!value) {
            value = label;
          }
          this.options.push({ label, value, details });
          e.hidden = true;
        });
      }
    }
    this.updateSource([]);
  }
  componentDidRender() {
    var _a;
    (_a = this._optionsList) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".item").forEach((elem) => {
      ElementIDUtils.addIDInfoIfNotExists(elem, "itemSearch");
    });
  }
  async componentDidLoad() {
    this._currentValue = this.value;
    CSSVarsUtils.applyVarsTextInput(this.el, this._textInput);
    this._resizeObserver = new ResizeObserver((entries) => {
      window.requestAnimationFrame(() => {
        if (!Array.isArray(entries) || !entries.length)
          return;
      });
    });
    this._intersectionObserver = new IntersectionObserver((entries) => {
      entries.forEach(entry => {
        if (!entry.isIntersecting && this._ezPopOverPlusElement) {
          this._ezPopOverPlusElement.hide();
        }
      });
    }, { threshold: 0.1 });
    if (this._textInput) {
      this._intersectionObserver.observe(this._textInput);
    }
    await this.handleInitialValue();
    if (this.autoFocus) {
      requestAnimationFrame(() => {
        this.setFocus({ selectText: true });
      });
    }
  }
  disconnectedCallback() {
    var _a, _b;
    (_a = this._resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
    (_b = this._intersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
  }
  //---------------------------------------------
  // Event handlers
  //---------------------------------------------
  handlerIconClick() {
    this.loadOptions(SearchMode.ADVANCED);
  }
  buildNumberArgument(argument) {
    if (this.isTextSearch) {
      return NaN;
    }
    return Number(argument || undefined);
  }
  onTextInputChangeHandler(event) {
    var _a;
    this.clearDeboucingTimeout();
    if (this._startLoading) {
      this._changeDeboucingTimeout = window.setTimeout(() => {
        this.onTextInputChangeHandler(event);
      }, this._deboucingTime);
      return;
    }
    const argument = (_a = event.target.value) === null || _a === void 0 ? void 0 : _a.trim();
    const argumentNumber = this.buildNumberArgument(argument);
    if (!this._criteria) {
      this._textInput.value = event.data || argument;
    }
    this._criteria = argument;
    if (argument) {
      this._showLoading = false;
      this.clearSource();
      if (this.ignoreLimitCharsToSearch || !isNaN(argumentNumber) || argument.length >= this._limitCharsToSearch) {
        this._showLoading = true;
        this._changeDeboucingTimeout = window.setTimeout(() => {
          this.loadOptions(SearchMode.PREDICTIVE, isNaN(argumentNumber) ? argument : argumentNumber.toString());
        }, this._deboucingTime);
        this.showOptions();
      }
      else {
        this.hideOptions();
      }
    }
    else {
      this.hideOptions();
      this._showLoading = false;
      this.clearSource();
    }
  }
  clearDeboucingTimeout() {
    if (this._changeDeboucingTimeout) {
      window.clearTimeout(this._changeDeboucingTimeout);
      this._changeDeboucingTimeout = null;
    }
  }
  async keyDownHandler(event) {
    this._tabPressed = false;
    if (event.ctrlKey) {
      if (event.key === "f" || event.key === "F") {
        this.loadOptions(SearchMode.ADVANCED);
        //ATENÇÃO: Ctrl + F tem ação específica nos browsers
        //nesse caso, como vamos abrir o popup de busca avançada,
        //não é interessante deixar o evento propagar;
        event.stopPropagation();
        event.stopImmediatePropagation();
        event.preventDefault();
      }
    }
    switch (event.key) {
      case "ArrowDown":
        event.stopPropagation();
        if (this.canShowListOptions()) {
          event.preventDefault();
        }
        if (!this.isOptionsVisible()) {
          this.showOptions();
        }
        await this._searchList.nextOption();
        break;
      case "ArrowUp":
        event.stopPropagation();
        if (this.canShowListOptions()) {
          event.preventDefault();
        }
        await this._searchList.previousOption();
        break;
      case "Enter":
        this.handleEventPropagation(event);
        this.selectCurrentOption();
        break;
      case "Escape":
        this.cancelPreselection();
        break;
      case "Tab":
        this._tabPressed = true;
        this.selectCurrentOption(false);
        break;
    }
    //ATENÇÃO: Existe a necessidade de propagar o evento de teclado.
    //Por exemplo, quando o usuário dá um Enter, além de selecionar
    //um valor, também significa que a ateração finalizou,
    //e o contexto pode reagir (fechar um popup por exemplo).
    //event.stopPropagation();
  }
  //O evento deve ter sua propagação interrompida, apenas se a lista de opções estiver sendo exibida.
  handleEventPropagation(event) {
    if (this._ezPopOverPlusElement.opened && this.stopPropagateEnterKeyEvent) {
      event.stopPropagation();
    }
  }
  onTextInputFocusOutHandler() {
    if (this.hideErrorOnFocusOut)
      this.cancelPreselection();
  }
  canShowListOptions() {
    return !this._showLoading && this._visibleOptions.length > 0;
  }
  canShowLoadSpinDescription() {
    return this._showLoadingDescription && !this._ezPopOverPlusElement.opened;
  }
  onChangePreSelection(value) {
    this._preSelection = value;
  }
  render() {
    var _a;
    ElementIDUtils.addIDInfoIfNotExists(this.el, 'input');
    return (h(Host, null, h("ez-text-input", { "data-element-id": ElementIDUtils.getInternalIDInfo("textInput"), class: this.suppressSearch ? "suppressed-search-input" : "", ref: elem => this._textInput = elem, "data-slave-mode": "true", enabled: this.enabled && !this.suppressSearch, onInput: event => this.onTextInputChangeHandler(event), onFocusout: () => this.onTextInputFocusOutHandler(), onKeyDown: event => this.keyDownHandler(event), label: this.label, canShowError: this.canShowError, errorMessage: this.errorMessage, mode: this.mode, alternativePlaceholder: this.alternativePlaceholder }, h("button", { class: "btn", slot: "leftIcon", disabled: !this.enabled, tabindex: -1, onClick: () => this.handlerIconClick() }, this.canShowLoadSpinDescription() ? h("div", { class: "message__loading" }) : h("ez-icon", { iconName: "search" })), (((_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value) && (this._criteria || this.value) || this.ensureClearButtonVisible)
      ? h("button", { class: "btn btn__close", slot: "rightIcon", disabled: !this.enabled, tabindex: -1, onClick: () => this.clearSearch() }, h("ez-icon", { iconName: "close" }))
      : undefined), h("ez-popover-plus", { ref: elem => this._ezPopOverPlusElement = elem, autoClose: false, overlayType: "none", useAnchorSize: true, anchorElement: [this._textInput, this.el], "data-element-id": this.el.getAttribute("data-element-id"), onEzVisibilityChange: (event) => event.stopPropagation() }, h("search-list", { ref: (ref) => this._searchList = ref, showLoading: this._showLoading, visibleOptions: this._visibleOptions, textEmptyList: this.i18n("ez-search.emptyList"), canShowListOptions: this.canShowListOptions(), value: this.value, showOptionValue: this.showOptionValue, preSelection: this._preSelection, onChangeValue: ({ detail }) => this.selectOption(detail), onChangePreSelection: ({ detail }) => this.onChangePreSelection(detail) }))));
  }
  get el() { return getElement(this); }
  static get watchers() { return {
    "errorMessage": ["observeErrorMessage"],
    "value": ["observeValue"],
    "options": ["observeOptions"]
  }; }
};
var SearchMode;
(function (SearchMode) {
  SearchMode["ADVANCED"] = "ADVANCED";
  SearchMode["PRELOAD"] = "PRELOAD";
  SearchMode["PREDICTIVE"] = "PREDICTIVE";
})(SearchMode || (SearchMode = {}));
EzSearch.style = ezSearchCss;

export { EzSearch as ez_search };
