'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-58ea899e.js');
const requiredFieldRule = require('./required-field-rule-d73c1d8c.js');
const component = require('./component-1e352960.js');
const typeGuard = require('./type-guard-2e97fc56.js');
const globalSlimmerRegistry = require('./global-slimmer-registry-b3bce7e0.js');
const componentUsageRuntimeMetrics = require('./component-usage-runtime-metrics-4572c5b7.js');
const formFieldControllerSlimmer = require('./form-field-controller-slimmer-595f4138.js');
const childNodesEventPreventSlimmer = require('./child-nodes-event-prevent-slimmer-f3979a03.js');
const eventEmitSlimmer = require('./event-emit-slimmer-8ba00d00.js');
const vegaEventId = require('./vega-event-id-d9994eb3.js');
const staticSubjectTitle = require('./static-subject-title-5829a298.js');
const changeManager = require('./change-manager-a297e4d2.js');
const accessibility = require('./accessibility-a5ef2038.js');
const domNodeSubjectObserverFactory = require('./dom-node-subject-observer-factory-ba6a95f3.js');
const vegaInternalEventId = require('./vega-internal-event-id-87014e4f.js');
const index$1 = require('./index-592b4052.js');
const keyboardManagerSlimmer = require('./keyboard-manager-slimmer-3824781d.js');
const ui = require('./ui-3727d685.js');
const mutationObserverSlimmer = require('./mutation-observer-slimmer-749d5020.js');
const mutationObserverFilters = require('./mutation-observer-filters-38cebc6d.js');
require('./internal-form-field-validation-rule.abstract-07cdff46.js');
require('./breakpoints-ebde4837.js');
require('./ui-32120990.js');
require('./typography-4560e7f1.js');
require('./internal-translation-controller-8360a89c.js');
require('./string-39438062.js');
require('./observer-f49483e8.js');
require('./misc-3d30df91.js');
require('./dynamic-slimmer-f31fdfd7.js');
require('./page-resize-observer-slimmer-273d62ef.js');
require('./breakpoints-1cc2c4c6.js');
require('./try-get-document-c0ebd39a.js');
require('./array-249289f2.js');
require('./number-4816603d.js');
require('./sub-state-observer-slimmer-ec5ac913.js');
require('./internal-vega-event-manager-7e0d966d.js');
require('./vega-env-manager-23b8b23c.js');
require('./feature-flag-controller-9129ef52.js');
require('./index-f054eb5d.js');
require('./keyboard-manager-d3cc662c.js');

const VegaComboBoxRuntimeMetricsPayloadDefinition = [
  {
    payloadKey: 'AUTO_VALIDATION_IS_TRUE',
    payloadDescription: 'Determines whether automatic validation should be implemented when a value is edited in the combo box',
    /**
     * The function checks if the `autoValidation` property of the `host` element is equal to 'true'.
     * If it is, the function will return `true`.
     *
     * @param {HTMLElement} host - The element to check
     * @returns {boolean} A boolean value
     */
    payloadValue: (host) => host.autoValidation === true,
  },
  {
    payloadKey: 'AUTO_VALIDATION_IS_FALSE',
    payloadDescription: 'Determines whether automatic validation should be implemented when a value is edited in the combo box',
    /**
     * The function checks if the `autoValidation` property of the `host` element is equal to 'false'.
     * If it is, the function will return `true`.
     *
     * @param {HTMLElement} host - The element to check
     * @returns {boolean} A boolean value
     */
    payloadValue: (host) => host.autoValidation === false,
  },
];

var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
class VegaComboBoxDropdownRenderer extends globalSlimmerRegistry.VegaSlimmer {
  constructor() {
    super(...arguments);
    this.onItemClick = async () => {
      this.valueController.setValue((await this.dropdownRef.getSelection()));
      await this.clearInput();
    };
    this.onDropdownHide = async () => {
      await this.clearInput();
    };
    this.onDropdownCreate = async (searchString) => {
      this.createEventEmit.emit(searchString);
      await this.clearInput();
    };
    /**
     * The below method is e2e-test covered in
     * @see{module:vega-combo-box-search-input}
     * @see{module:vega-combo-box-vega-search-event-e2e}
     */
    /* istanbul ignore next */
    this.onInputChange = async (e) => {
      const value = e.target.value;
      if (this.useDefaultFilter || this.vegaDropdownProps.dynamicOption) {
        await this.dropdownRef.show();
        await this.dropdownRef.search(value);
      }
      if (this.isTemplateMode || !this.useDefaultFilter) {
        this.searchEventEmit.emit(value);
      }
    };
  }
  connectedCallback() {
    this.isTemplateMode = this.host.querySelector('[slot=items]') !== null;
  }
  getDropdownRef() {
    return this.dropdownRef;
  }
  getSearchInputRef() {
    return this.searchInputRef;
  }
  /**
   * The below method is e2e-test covered in
   * @see{module:vega-combo-box-focus-by-label-e2e}
   */
  /* istanbul ignore next */
  focusInput() {
    this.searchInputRef.focus();
  }
  async hide() {
    await this.dropdownRef.hide();
  }
  async show() {
    await this.dropdownRef.show();
  }
  replaceItemsSlot(itemsSlot) {
    if (itemsSlot && this.itemsSlotRef) {
      this.itemsSlotRef.remove();
      this.dropdownRef.append(itemsSlot);
    }
  }
  renderDropdown() {
    return (index.h("vega-dropdown", Object.assign({ trigger: this.disabled ? 'none' : 'click', source: this.source, selectType: "multiple", selectedSourceKey: this.value, matchTargetWidth: true, useDefaultFilter: this.useDefaultFilter }, this.vegaDropdownProps, { ref: (ref) => {
        this.dropdownRef = ref;
        domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, vegaEventId.VegaCreate, async (payload) => {
          await this.onDropdownCreate(payload.detail);
        });
        domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, vegaEventId.VegaDropdownHide, async () => {
          await this.onDropdownHide();
        });
        domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, vegaEventId.VegaDropdownClick, async () => {
          await this.onItemClick();
        });
        domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, vegaInternalEventId.VegaInternalDropdownTemplateItemsChange, 
        /*
         * The below method is e2e-test covered in
         * @see{module:vega-combo-box-template-select-e2e}
         */
        /* istanbul ignore next */
        (payload) => {
          const addedItems = Array.from(payload)
            .filter((item) => !this.source.find((sourceItem) => sourceItem.key === item.itemKey))
            .map((item) => ({
            key: item.itemKey,
            label: item.label,
          }));
          this.sourceController.setSource([...this.source, ...addedItems]);
        });
      } }),
      this.renderContainer(),
      this.renderItemsSlot()));
  }
  renderContainer() {
    return (index.h("div", { class: {
        'vega-combo-box-container': true,
        [`vega-combo-box-size-${this.size}`]: true,
      } },
      this.renderSelectedContainer(),
      this.renderInputContainer()));
  }
  renderItemsSlot() {
    return (this.isTemplateMode && (index.h("div", { slot: "items", ref: (ref) => {
        this.itemsSlotRef = ref;
      } })));
  }
  renderSelectedContainer() {
    const selected = this.value
      .map((key) => this.source.find((item) => item.key === key))
      .filter((item) => item);
    return (index.h(index.Fragment, null, selected.map((item) => {
      return this.renderSelectedChip(item);
    })));
  }
  renderSelectedChip(item) {
    return (index.h("vega-chip", { 
      //TODO: the key property test will add in https://gethired.atlassian.net/browse/VD-883
      key: item.key, text: index$1.htmlSanitizer.sanitize(item.label, index$1.labelSanitizeStrategy), variant: "outlined", showCloseIcon: !this.disabled, size: "small", ref: (ref) => {
        domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, vegaEventId.VegaClose, async () => {
          await this.onChipClose(item.key);
        });
      } }));
  }
  renderInputContainer() {
    return (index.h("div", { class: "vega-combo-box-input-container" },
      index.h("input", { onInput: this.onInputChange, "aria-label": this.label || 'No label defined', placeholder: this.value.length === 0 ? this.placeholder : '', ref: (e) => (this.searchInputRef = e), onKeyDown: accessibility.createEnterKeyHandlerToTriggerClick(), disabled: this.disabled })));
  }
  async onChipClose(key) {
    this.valueController.setValue([...this.value.filter((value) => value !== key)]);
    await this.dropdownRef.hide();
  }
  async clearInput() {
    this.searchInputRef.value = '';
    await this.dropdownRef.search('');
  }
}
__decorate$6([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "host", void 0);
__decorate$6([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "value", void 0);
__decorate$6([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "source", void 0);
__decorate$6([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "disabled", void 0);
__decorate$6([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "size", void 0);
__decorate$6([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "vegaDropdownProps", void 0);
__decorate$6([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "label", void 0);
__decorate$6([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "placeholder", void 0);
__decorate$6([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "useDefaultFilter", void 0);
__decorate$6([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "createEventEmit", void 0);
__decorate$6([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "searchEventEmit", void 0);
__decorate$6([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "valueController", void 0);
__decorate$6([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxDropdownRenderer.prototype, "sourceController", void 0);
__decorate$6([
  globalSlimmerRegistry.MapToComponentMethod('connectedCallback')
], VegaComboBoxDropdownRenderer.prototype, "connectedCallback", null);

var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**
 * The value controller of `VegaComboBox` component.
 */
class VegaComboBoxValueController extends globalSlimmerRegistry.VegaSlimmer {
  /**
   * The function `setValue` sets the value of a VegaComboBox component.
   *
   * @param {string[]} value - value
   */
  setValue(value) {
    this.value = value;
  }
}
__decorate$5([
  globalSlimmerRegistry.MapToComponentField({ writable: true })
], VegaComboBoxValueController.prototype, "value", void 0);

var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
class VegaComboBoxRenderer extends globalSlimmerRegistry.VegaSlimmer {
  constructor() {
    super(...arguments);
    /**
     * The below method is e2e-test covered in
     * @see{module:vega-combo-box-focus-by-label-e2e}
     */
    /* istanbul ignore next */
    this.onLabelClick = () => {
      this.dropdownRenderer.focusInput();
    };
  }
  render() {
    return (index.h(index.Host, { class: {
        'vega-combo-box-disabled': this.disabled,
      } },
      this.renderLabel(),
      this.dropdownRenderer.renderDropdown(),
      this.renderHint()));
  }
  renderLabel() {
    return (index.h("vega-field-label", { onClick: this.onLabelClick, "is-field-required": this.required, disabled: this.disabled, label: this.label }));
  }
  renderHint() {
    return index.h("div", { class: "vega-combo-box-hint" }, this.hint);
  }
}
__decorate$4([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxRenderer.prototype, "required", void 0);
__decorate$4([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxRenderer.prototype, "hint", void 0);
__decorate$4([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxRenderer.prototype, "disabled", void 0);
__decorate$4([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxRenderer.prototype, "dropdownRenderer", void 0);
__decorate$4([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxRenderer.prototype, "label", void 0);

var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**
 * Keyboard controller for vega-combo-box
 */
class VegaComboBoxKeyboardController extends keyboardManagerSlimmer.KeyboardManagerSlimmer {
  /** The function sets up the functionality of key board control */
  constructor() {
    super((target) => [
      {
        keyCode: 'Backspace',
        activeElementInScope: [target.dropdownRenderer.getSearchInputRef()],
        eventName: 'keydown',
        callback: target.deleteLastSelectedItem,
      },
      {
        keyCode: 'ArrowLeft',
        activeElementInScope: [target.host],
        callback: 
        /* istanbul ignore next */
        /* eslint-disable jsdoc/require-jsdoc */
        () => target.controlDirectionByKeyboard('ArrowLeft'),
      },
      {
        keyCode: 'ArrowRight',
        activeElementInScope: [target.host],
        callback: 
        /* istanbul ignore next */
        /* eslint-disable jsdoc/require-jsdoc */
        () => target.controlDirectionByKeyboard('ArrowRight'),
      },
    ]);
    /*
     * The below method is e2e-test covered in
     * @see{module:vega-combo-box-keyboard-control-e2e}
     * @see{module:vega-combo-box-keyboard-control-for-selected-items-e2e}
     */
    /* istanbul ignore next */
    /**
     * Delete last item when press `Backspace` key
     */
    this.deleteLastSelectedItem = () => {
      if (this.dropdownRenderer.getSearchInputRef().value === '') {
        this.value.pop();
        this.valueController.setValue([...this.value]);
      }
    };
  }
  /*
   * The below method is e2e-test covered in
   * @see{module:vega-combo-box-keyboard-control-e2e}
   * @see{module:vega-combo-box-keyboard-control-for-selected-items-e2e}
   */
  /* istanbul ignore next */
  /**
   * Handles keyboard input to navigate between elements, focusing on the previous or next element based on the key pressed.
   *
   * @param {KeyboardCodeType} code - code
   */
  controlDirectionByKeyboard(code) {
    const activeElement = component.getActiveElement();
    if (activeElement && activeElement.classList.contains('vega-chip-close-icon')) {
      const currentChip = ui.findParent(activeElement, 'vega-chip');
      if (code === 'ArrowLeft')
        this.focusItemByKeyboard(currentChip.previousSibling);
      if (code === 'ArrowRight')
        this.focusItemByKeyboard(currentChip.nextSibling);
    }
    else if (code === 'ArrowLeft' && this.dropdownRenderer.getSearchInputRef().selectionStart === 0) {
      this.focusItemByKeyboard(this.host.shadowRoot.querySelector('vega-chip:last-of-type'));
    }
  }
  /*
   * The below method is e2e-test covered in
   * @see{module:vega-combo-box-keyboard-control-e2e}
   * @see{module:vega-combo-box-keyboard-control-for-selected-items-e2e}
   */
  /* istanbul ignore next */
  /**
   * The function is used to focus on a specific element based on its class name.
   *
   * @param {HTMLElement} item - item
   */
  focusItemByKeyboard(item) {
    if (item) {
      if (item.classList.contains('vega-combo-box-input-container')) {
        item.querySelector('input').focus();
      }
      else {
        item.shadowRoot.querySelector('.vega-chip-close-icon').focus();
      }
    }
  }
}
__decorate$3([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxKeyboardController.prototype, "host", void 0);
__decorate$3([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxKeyboardController.prototype, "value", void 0);
__decorate$3([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxKeyboardController.prototype, "dropdownRenderer", void 0);
__decorate$3([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxKeyboardController.prototype, "valueController", void 0);

var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**
 * The class `VegaInputSelectItemsSlotController` extends `VegaSlimmer` and manages
 * appending host items to a dropdown element.
 */
class VegaComboBoxItemsSlotController extends globalSlimmerRegistry.VegaSlimmer {
  constructor() {
    super(...arguments);
    this.mutationObserver = new mutationObserverSlimmer.MutationObserverSlimmer({
      mutationFilter: mutationObserverFilters.TagNameMutationFilter('VEGA-DROPDOWN-ITEM'),
      options: {
        childList: true,
        subtree: true,
      },
      callback: 
      /*
       * The below method is e2e-test covered in
       * @see{module:vega-combo-box-template-slot-change-e2e}
       */
      /* istanbul ignore next */
      // eslint-disable-next-line jsdoc/require-jsdoc
      () => this.appendHostItemsToDropdown(),
    });
  }
  /**
   * Component lifecycle - [componentDidLoad]
   */
  componentDidLoad() {
    this.appendHostItemsToDropdown();
  }
  /**
   * The function appends host items to a dropdown element.
   */
  appendHostItemsToDropdown() {
    this.dropdownRenderer.replaceItemsSlot(this.host.querySelector('[slot=items]'));
  }
}
__decorate$2([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaComboBoxItemsSlotController.prototype, "mutationObserver", void 0);
__decorate$2([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxItemsSlotController.prototype, "host", void 0);
__decorate$2([
  globalSlimmerRegistry.MapToComponentField()
], VegaComboBoxItemsSlotController.prototype, "dropdownRenderer", void 0);
__decorate$2([
  globalSlimmerRegistry.MapToComponentMethod('componentDidLoad')
], VegaComboBoxItemsSlotController.prototype, "componentDidLoad", null);

var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**
 * The source controller of `VegaComboBox` component.
 */
class VegaComboBoxSourceController extends globalSlimmerRegistry.VegaSlimmer {
  /**
   * The function `setSource` sets the source of a VegaComboBox component.
   *
   * @param {string[]} source - source
   */
  setSource(source) {
    this.source = source;
  }
}
__decorate$1([
  globalSlimmerRegistry.MapToComponentField({ writable: true })
], VegaComboBoxSourceController.prototype, "source", void 0);

const vegaComboBoxCss = ":host{display:inline-block;width:100%;min-width:0px;text-align:left;line-height:normal}.vega-combo-box-container{border:1px solid rgba(var(--v-border-input-field, 171, 198, 216, 1));background-color:rgba(var(--v-bg-primary, 252, 252, 252, 1));padding-left:16px;padding-right:16px;padding-top:12px;padding-bottom:12px;border-radius:8px;gap:8px;display:block;display:flex;flex-wrap:wrap;align-items:center;cursor:pointer}.vega-combo-box-container:hover{border:1px solid rgba(var(--v-border-input-field-hover, 115, 160, 190, 1))}.vega-combo-box-container:focus-within{border:1px solid rgba(var(--v-border-input-field-focus, 19, 98, 226, 1));outline:2px solid rgba(var(--v-border-color-action, 19, 98, 226, 1));outline-offset:2px}.vega-combo-box-container .vega-combo-box-input-container{width:-webkit-min-content;width:-moz-min-content;width:min-content;flex-grow:1}.vega-combo-box-container input{border-style:none;background-color:rgba(var(--v-bg-transparent, 0, 0, 0, 0));font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px;color:rgba(var(--v-text-primary, 32, 54, 69, 1));width:100%}@media screen and (min-width: 768px) and (max-width: 1023px){.vega-combo-box-container input{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){.vega-combo-box-container input{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){.vega-combo-box-container input{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}.vega-combo-box-container input:focus{outline:2px solid transparent;outline-offset:2px}.vega-combo-box-size-medium{padding-left:12px;padding-right:12px;padding-top:11px;padding-bottom:11px}.vega-combo-box-size-small{padding-left:12px;padding-right:12px;padding-top:7px;padding-bottom:7px}.vega-combo-box-container:focus{outline:none}vega-field-label{margin-bottom:8px}.error .vega-combo-box-container{border:1px solid rgba(var(--v-border-input-field-danger, 230, 50, 87, 1))}.error .vega-combo-box-container:hover{border:1px solid rgba(var(--v-border-input-field-danger-hover, 255, 87, 114, 1))}.error .vega-combo-box-container:focus-within{border:1px solid rgba(var(--v-border-input-field-danger-focus, 233, 71, 104, 1));outline:2px solid rgba(var(--v-border-color-danger, 230, 50, 87, 1));outline-offset:2px}:host(.vega-combo-box-disabled) .vega-combo-box-container{border:1px solid rgba(var(--v-border-input-field-disabled, 222, 225, 227, 1));background-color:rgba(var(--v-bg-secondary, 245, 247, 247, 1));--tw-shadow:0 0 #0000;box-shadow:rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px}:host(.vega-combo-box-disabled) .vega-combo-box-container:hover{border:1px solid rgba(var(--v-border-input-field-disabled, 222, 225, 227, 1))}:host(.vega-combo-box-disabled) vega-icon{color:rgba(var(--v-text-disabled, 176, 180, 181, 1))}.vega-combo-box-container input::placeholder{color:rgba(var(--v-text-input-placeholder, 176, 180, 181, 1))}.vega-error{display:inline-block;padding-left:8px;padding-right:8px;padding-top:8px;font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px;color:rgba(var(--v-text-error, 189, 41, 71, 1))}@media screen and (min-width: 768px) and (max-width: 1023px){.vega-error{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){.vega-error{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){.vega-error{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}.vega-hidden{display:none}.vega-combo-box-hint{padding-left:8px;padding-right:8px;font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px;color:rgba(var(--v-text-secondary, 107, 116, 125, 1));padding-top:8px}@media screen and (min-width: 768px) and (max-width: 1023px){.vega-combo-box-hint{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){.vega-combo-box-hint{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){.vega-combo-box-hint{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}.vega-error:not(.vega-hidden)+.vega-combo-box-hint{padding-top:4px}vega-dropdown{display:block}";

var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
    r = Reflect.decorate(decorators, target, key, desc);
  else
    for (var i = decorators.length - 1; i >= 0; i--)
      if (d = decorators[i])
        r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const VegaComboBox = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.vegaChange = index.createEvent(this, "vegaChange", 7);
    this.change = index.createEvent(this, "change", 7);
    this.vegaCreate = index.createEvent(this, "vegaCreate", 7);
    this.create = index.createEvent(this, "create", 7);
    this.vegaSearch = index.createEvent(this, "vegaSearch", 7);
    this.search = index.createEvent(this, "search", 7);
    this.globalSlimmers = {};
    this.itemsSlotController = new VegaComboBoxItemsSlotController();
    this.keyboardController = new VegaComboBoxKeyboardController();
    this.valueController = new VegaComboBoxValueController();
    this.sourceController = new VegaComboBoxSourceController();
    this.renderer = new VegaComboBoxRenderer();
    this.dropdownRenderer = new VegaComboBoxDropdownRenderer();
    this.formFieldController = new formFieldControllerSlimmer.FormFieldControllerSlimmer({
      propertyRules: [
        {
          propertyName: 'required',
          ruleFactory: (isRequired) => (isRequired ? new requiredFieldRule.RequiredFieldRule() : null),
        },
      ],
      validationRulesName: 'validationRules',
      defaultValue: [],
      attributeGetter: (propertyName) => this[propertyName],
      inputContainerGetter: () => this.dropdownRenderer.getDropdownRef(),
      touchableAreaGetter: () => [this.dropdownRenderer.getSearchInputRef()],
    });
    this.changeEventEmit = eventEmitSlimmer.createEventEmitSlimmer(VegaComboBox, vegaEventId.VegaChange);
    this.createEventEmit = eventEmitSlimmer.createEventEmitSlimmer(VegaComboBox, vegaEventId.VegaCreate);
    this.searchEventEmit = eventEmitSlimmer.createEventEmitSlimmer(VegaComboBox, vegaEventId.VegaSearch);
    this.dropdownEventPrevent = new childNodesEventPreventSlimmer.ChildNodesEventPreventSlimmer([vegaEventId.VegaCreate, vegaEventId.VegaSearch], () => this.dropdownRenderer.getDropdownRef(), {
      customPreventHandle: (e) => {
        e.stopImmediatePropagation();
      },
    });
    this.vegaComponentUsageRuntimeMetricsSlimmer = new componentUsageRuntimeMetrics.VegaComponentUsageRuntimeMetricsSlimmer(VegaComboBoxRuntimeMetricsPayloadDefinition);
    /**
     * Specifies the label or title for the combo box.
     *
     * It provides descriptive text that helps identify the
     *    purpose or content expected in the combo box.
     *
     * @vegaVersion 1.11.0
     */
    this.label = '';
    /**
     * Specifies whether a value must be entered for the
     *    combo box to pass form validation.
     *
     * @vegaVersion 1.11.0
     */
    this.required = false;
    /**
     * Specifies the source data used to populate the
     *    dropdown menu associated with the combo box.
     *
     * @vegaVersion 1.11.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.source = [];
    /**
     * Sets the initial or preset values of the combo box.
     *
     * It should be an array of strings representing the selected values.
     *
     * @vegaVersion 1.11.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.value = [];
    /**
     * Specifies the validation status of the combo box component.
     *
     * @vegaVersion 1.11.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.isValid = null;
    /**
     * Determines whether automatic validation should be implemented
     *    when a value is edited in the combo box.
     *
     * @vegaVersion 1.11.0
     */
    this.autoValidation = true;
    /**
     * Specifies custom validation rules for the combo box.
     *
     * @vegaVersion 1.11.0
     */
    this.validationRules = [];
    /**
     * Specifies whether the combo box element is disabled.
     *
     * @vegaVersion 1.11.0
     */
    this.disabled = false;
    /**
     * Sets a placeholder string that provides a temporary hint
     *    or example inside the combo box input field.
     *
     * It indicates the expected format or pattern of the input.
     *
     * @vegaVersion 1.11.0
     */
    this.placeholder = '';
    /**
     * Provides a supplementary prompt message that is displayed
     *    alongside the combo box input field.
     *
     * @vegaVersion 1.11.0
     */
    this.hint = '';
    /**
     * Specifies the size of the combo box.
     *
     * @vegaVersion 1.11.0
     */
    this.size = 'medium';
    /**
     * Specifies partial properties of the `vega-dropdown` component
     *    that are used to configure the dropdown menu
     *    associated with the combo box.
     *
     * @vegaVersion 1.11.0
     */
    this.vegaDropdownProps = {};
    /**
     * Determines whether to display the associated dropdown menu and
     *    filter its options based on the text entered into the combo box.
     *
     * Setting this property to `false` enables custom text input handling
     *    by listening for the `vegaSearch` event.
     *
     * @vegaVersion 1.24.0
     */
    this.useDefaultFilter = true;
  }
  watchSource() {
    this.source = typeGuard.isArrayOfType(this.source, typeGuard.isDropdownSourceItemType)
      ? this.source
      : [];
  }
  watchValue() {
    this.changeEventEmit.emit(this.value);
    changeManager.ChangeManager.notify(staticSubjectTitle.FORM_ELEMENT_VALUE_CHANGE, {
      host: this.host,
      detail: this.value,
    });
  }
  watchValidationRules() {
  }
  /**
   * Invoke this method to close the dropdown menu associated with the combo box.
   *
   * @vegaVersion 1.11.0
   */
  async close() {
    if (!this.disabled) {
      await this.dropdownRenderer.hide();
    }
  }
  /**
   * Invoke this method to open the dropdown menu associated with the combo box.
   *
   * @vegaVersion 1.11.0
   */
  async open() {
    if (!this.disabled) {
      await this.dropdownRenderer.show();
    }
  }
  render() {
    return component.sanitizeVegaComponent(this.renderer.render(), this.host);
  }
  get host() { return index.getElement(this); }
  static get watchers() { return {
    "source": ["watchSource"],
    "value": ["watchValue"],
    "validationRules": ["watchValidationRules"]
  }; }
};
__decorate([
  componentUsageRuntimeMetrics.InjectVegaGlobalSlimmer()
], VegaComboBox.prototype, "globalSlimmers", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaComboBox.prototype, "itemsSlotController", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaComboBox.prototype, "keyboardController", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaComboBox.prototype, "valueController", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaComboBox.prototype, "sourceController", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaComboBox.prototype, "renderer", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaComboBox.prototype, "dropdownRenderer", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaComboBox.prototype, "formFieldController", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaComboBox.prototype, "changeEventEmit", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaComboBox.prototype, "createEventEmit", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaComboBox.prototype, "searchEventEmit", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaComboBox.prototype, "dropdownEventPrevent", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaComboBox.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaComboBox.style = vegaComboBoxCss;

exports.vega_combo_box = VegaComboBox;
