import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
import { ElementIDUtils } from '@sankhyalabs/core';
import { F as FilterItemType } from './filter-item-type.enum.js';

const SnkFilterMultiSelect$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    this.valueChanged = createEvent(this, "valueChanged", 7);
    this.value = undefined;
    this.config = undefined;
    this.errorMessage = undefined;
  }
  /**
   * Emitido quando acontece a alteração de valor do componente snk-filter-multi-select
   */
  ezChangeListener(evt) {
    var _a;
    this.errorMessage = undefined;
    this.value = (_a = evt.detail) === null || _a === void 0 ? void 0 : _a.value;
    this.valueChanged.emit(this.value);
  }
  /**
   * Define o foco no componente snk-filter-multi-select.
   */
  async setFocus() {
    this._comboElement.setFocus();
  }
  /**
   * Limpa o valor do componente restaurando o valor original da configuração.
   */
  async clearValue() {
    this.value = this.config.value;
    if (this._comboElement) {
      this._comboElement.value = this.config.value;
    }
  }
  componentDidLoad() {
    if (this._element) {
      ElementIDUtils.addIDInfo(this._element, 'filterContentEditor');
    }
  }
  render() {
    if (!this.config || this.config.type !== FilterItemType.MULTI_SELECT) {
      return undefined;
    }
    return (h("ez-tooltip", { active: this.config.enabled === false, message: this.config.disabledMessage, type: 'warning' }, h("ez-combo-box", { id: this.config.id, ref: ref => this._comboElement = ref, label: this.config.label, value: this.config.value, options: this.config.props.options, enabled: this.config.enabled, errorMessage: this.errorMessage, onEzVisibilityChange: (event) => {
        event.stopPropagation();
      } })));
  }
  get _element() { return this; }
}, [0, "snk-filter-multi-select", {
    "value": [1544],
    "config": [16],
    "errorMessage": [1537, "error-message"],
    "setFocus": [64],
    "clearValue": [64]
  }, [[0, "ezChange", "ezChangeListener"]]]);
function defineCustomElement$1() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["snk-filter-multi-select"];
  components.forEach(tagName => { switch (tagName) {
    case "snk-filter-multi-select":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, SnkFilterMultiSelect$1);
      }
      break;
  } });
}

const SnkFilterMultiSelect = SnkFilterMultiSelect$1;
const defineCustomElement = defineCustomElement$1;

export { SnkFilterMultiSelect, defineCustomElement };
