import { h, H as Host, r as registerInstance, c as createEvent, g as getElement } from './index-090d31ca.js';
import { s as sanitizeVegaComponent } from './component-d58ca1d0.js';
import { c as MapToComponentField, M as MapToComponentMethod, V as VegaSlimmer, L as LogUtility } from './global-slimmer-registry-0a7aa308.js';
import { I as InjectVegaSlimmer } from './inject-vega-slimmer-caffc2aa.js';
import { V as VegaComponentUsageRuntimeMetricsSlimmer, I as InjectVegaGlobalSlimmer } from './component-usage-runtime-metrics-4202784a.js';
import { R as ResponsiveFormatFacade } from './responsive-format-facade-d32134a3.js';
import { c as createEnterKeyHandlerToTriggerClick } from './accessibility-e5fd0fab.js';
import { S as SubStateObserverSlimmer } from './sub-state-observer-slimmer-884e6f43.js';
import { O as Observer } from './observer-3959f9dd.js';
import { d as domNodeSubjectFactory } from './dom-node-subject-factory-6894df15.js';
import { h as VegaInternalFieldErrorStateChange } from './vega-internal-event-id-a2d4c714.js';
import { f as findParent } from './ui-6dd51115.js';
import { C as ChangeManager } from './change-manager-ecbd3a2a.js';
import { P as PageResizeObserverSlimmer } from './page-resize-observer-slimmer-558308bc.js';
import { g as getCurrentBreakpoint } from './breakpoints-332702ed.js';
import { h as VegaChange } from './vega-event-id-1b737ae8.js';
import { c as createEventEmitSlimmer } from './event-emit-slimmer-50d423c0.js';
import { F as FORM_ELEMENT_VALUE_CHANGE } from './static-subject-title-52f93124.js';
import { M as MutationObserverSlimmer } from './mutation-observer-slimmer-f6fcd32a.js';
import { a as TagNameAndAttributeMutationFilter } from './mutation-observer-filters-1a054fb0.js';
import { i as isArrayEqual } from './array-7888f339.js';
import { c as createSubStateNotifySlimmer } from './sub-state-notify-slimmer-d9e93bd6.js';
import { C as ChildNodesEventPreventSlimmer } from './child-nodes-event-prevent-slimmer-08e29cdd.js';
import { F as FormFieldControllerSlimmer } from './form-field-controller-slimmer-1ff66f6c.js';
import { R as RequiredFieldRule } from './required-field-rule-ab4bdc47.js';
import './type-guard-5e7bf13e.js';
import './breakpoints-d9faf11c.js';
import './ui-93922c59.js';
import './regex-13ca296a.js';
import './typography-396de03f.js';
import './internal-translation-controller-0776fa78.js';
import './number-4398f2e1.js';
import './pixel-f32c07ce.js';
import './feature-flag-controller-b7e7da75.js';
import './index-bfc6dfa2.js';
import './try-get-document-bef0f526.js';
import './dynamic-slimmer-60d5da5a.js';
import './dom-node-subject-observer-factory-61fda003.js';
import './internal-vega-event-manager-a19d633d.js';
import './vega-env-manager-8f8dc473.js';
import './string-a953eafc.js';
import './misc-9fdbcfbb.js';
import './index-3b327f29.js';
import './internal-form-field-validation-rule.abstract-f5b6bdbf.js';

var __decorate$8 = (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 VegaSelectionChipRenderer extends VegaSlimmer {
  componentWillRender() {
    this.currentSize = ResponsiveFormatFacade.formatCustom(this.size);
  }
  render() {
    return (h(Host, { class: {
        block: this.block,
      } }, this.renderTooltip()));
  }
  renderTooltip() {
    return (h("vega-tooltip", Object.assign({ trigger: this.disabled && this.disabledTooltip ? 'hover' : 'none', alignment: "center" }, this.disabledTooltip), this.renderSelectionChip()));
  }
  renderSelectionChip() {
    return (h("vega-box", { corners: "rounded-full", class: {
        'vega-selection-chip': true,
        [`size-${this.currentSize}`]: true,
        [`variant-${this.variant || 'text'}`]: true,
        'checked': this.checked,
        'error': this.showError,
        'disabled': this.disabled,
      }, "aria-label": this.label || 'No label defined', 
      /* eslint-disable-next-line react/jsx-no-bind */
      onClick: () => {
        if (!(this.selectType === 'radio' && this.checked)) {
          this.checkedController.onCheck(!this.checked);
        }
      }, onKeyDown: createEnterKeyHandlerToTriggerClick(), tabIndex: this.disabled ? -1 : 0 }, this.renderContent()));
  }
  renderContent() {
    return (h("vega-flex", { gap: VegaSelectionChipRenderer.gapSizeMap[this.currentSize], "align-items": "center", "justify-content": this.variant === 'text' ? `center` : `start` },
      this.variant === 'swatch' && this.renderSwatch(),
      this.renderLabel()));
  }
  renderLabel() {
    return (h("vega-font", { color: "text-primary", class: "label vega-flex-grow", variant: VegaSelectionChipRenderer.labelFontMap[this.currentSize] }, this.label));
  }
  renderSwatch() {
    return (h("vega-box", { "background-color": "bg-primary", corners: "rounded-full", class: "swatch vega-flex-shrink-0" },
      h("vega-box", { "background-color": this.swatchColor, corners: "rounded-full" })));
  }
}
VegaSelectionChipRenderer.gapSizeMap = {
  'extra-small': 'size-4',
  'small': 'size-4',
  'medium': 'size-8',
  'large': 'size-8',
};
VegaSelectionChipRenderer.labelFontMap = {
  'extra-small': 'font-field-label-xs',
  'small': 'font-field-label-sm',
  'medium': 'font-field-label',
  'large': 'font-field-label-lg',
};
__decorate$8([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "host", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "label", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "block", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "size", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "variant", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "swatchColor", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "disabledTooltip", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "disabled", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "selectType", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "checked", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "checkedController", void 0);
__decorate$8([
  MapToComponentField()
], VegaSelectionChipRenderer.prototype, "showError", void 0);
__decorate$8([
  MapToComponentMethod('componentWillRender')
], VegaSelectionChipRenderer.prototype, "componentWillRender", null);

var __decorate$7 = (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;
};
/**
 * Manager the check status in vegaSelectionChip.
 */
class VegaSelectionChipCheckedController extends VegaSlimmer {
  /**
   * Set checked value.
   *
   * @param {boolean} checked - checked
   */
  setChecked(checked) {
    this.checked = checked;
  }
  /**
   * Listen selection chip click to set checked value.
   *
   * @param {boolean} checked - checked.
   */
  onCheck(checked) {
    const value = checked ? this.value : '';
    this.setChecked(checked);
    this.changeEventEmitter.emit(value);
  }
}
__decorate$7([
  MapToComponentField()
], VegaSelectionChipCheckedController.prototype, "host", void 0);
__decorate$7([
  MapToComponentField({ writable: true })
], VegaSelectionChipCheckedController.prototype, "checked", void 0);
__decorate$7([
  MapToComponentField()
], VegaSelectionChipCheckedController.prototype, "changeEventEmitter", void 0);
__decorate$7([
  MapToComponentField()
], VegaSelectionChipCheckedController.prototype, "value", void 0);

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;
};
/**
 * Sync the property value from parent group.
 */
class VegaSelectionChipStateController extends SubStateObserverSlimmer {
  // eslint-disable-next-line jsdoc/require-jsdoc
  constructor() {
    super({
      parent: 'vega-selection-chip-group',
      subStates: [
        {
          subStateName: 'disabled',
          parentStateName: 'disabled',
          /**
           * If group defined disabled property we should synchronize this value,
           * 		otherwise keep the disabled value in selection chip unchanged.
           *
           * @param {Nullable<boolean>} groupDisabled - Disabled value in parent selection chip group.
           */
          callback: (groupDisabled) => {
            if (typeof groupDisabled === 'boolean') {
              this.disabled = groupDisabled;
            }
          },
        },
        {
          subStateName: 'selectType',
          parentStateName: 'selectType',
          /**
           * If group defined selectType property we should synchronize this value.
           *
           * @param {VegaSelectionChipGroupSelectType} selectType - SelectType value in parent selection chip group.
           */
          callback: (selectType) => {
            this.selectType = selectType === 'checkbox' ? 'checkbox' : 'radio';
          },
        },
        {
          subStateName: 'checked',
          parentStateName: 'value',
          /**
           * Synchronize checked status according by the value from parent selection chip group.
           *
           * @param {string | string[]} groupValue - The value from parent selection chip group.
           */
          callback: (groupValue) => {
            this.checkedController.setChecked(Array.isArray(groupValue)
              ? groupValue.includes(this.value)
              : groupValue === this.value);
          },
        },
      ],
    });
  }
}
__decorate$6([
  MapToComponentField()
], VegaSelectionChipStateController.prototype, "host", void 0);
__decorate$6([
  MapToComponentField({ writable: true })
], VegaSelectionChipStateController.prototype, "disabled", void 0);
__decorate$6([
  MapToComponentField({ writable: true })
], VegaSelectionChipStateController.prototype, "selectType", void 0);
__decorate$6([
  MapToComponentField()
], VegaSelectionChipStateController.prototype, "value", void 0);
__decorate$6([
  MapToComponentField()
], VegaSelectionChipStateController.prototype, "checkedController", void 0);

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;
};
/**
 * Manager the showError state status in vegaSelectionChip, the value is depend on the parent group validate
 */
class VegaSelectionChipShowErrorController extends VegaSlimmer {
  /**
   * Component lifecycle - [connectedCallback]
   */
  connectedCallback() {
    this.selectionChipGroup = findParent(this.host, 'vega-selection-chip-group');
    if (!this.selectionChipGroup)
      return;
    this.fieldErrorObserver = new Observer(this.canAcceptFieldErrorObserver.bind(this), this.fieldErrorObserverListener.bind(this));
    ChangeManager.register(domNodeSubjectFactory.getSubject(this.selectionChipGroup, VegaInternalFieldErrorStateChange), this.fieldErrorObserver);
  }
  /**
   * Component lifecycle - [disconnectedCallback]
   */
  disconnectedCallback() {
    if (!this.selectionChipGroup)
      return;
    ChangeManager.unregister(domNodeSubjectFactory.getSubject(this.selectionChipGroup, VegaInternalFieldErrorStateChange), this.fieldErrorObserver);
  }
  /**
   * The function `canAcceptFieldErrorObserver` always returns `true`.
   *
   * @returns {boolean} a boolean value, which indicates the current host is a checkbox or checkbox group.
   */
  canAcceptFieldErrorObserver() {
    return true;
  }
  /**
   * The function listens to the showError property of the returned object.
   *
   * @param {FieldErrorPayload} payload - The payload parameter is of type FieldErrorPayload, which is an object containing information about field.
   */
  fieldErrorObserverListener(payload) {
    this.showError = payload.showError;
  }
}
__decorate$5([
  MapToComponentField({ writable: true })
], VegaSelectionChipShowErrorController.prototype, "showError", void 0);
__decorate$5([
  MapToComponentField()
], VegaSelectionChipShowErrorController.prototype, "host", void 0);
__decorate$5([
  MapToComponentMethod('connectedCallback')
], VegaSelectionChipShowErrorController.prototype, "connectedCallback", null);
__decorate$5([
  MapToComponentMethod('disconnectedCallback')
], VegaSelectionChipShowErrorController.prototype, "disconnectedCallback", null);

const vegaSelectionChipCss = ":host(.block){display:block}:host(.block) vega-tooltip{display:block}:host{max-width:100%;display:inline-block;vertical-align:middle;line-height:0}:host vega-tooltip{max-width:100%}:host .swatch{margin:2px;padding:1px;box-sizing:border-box}:host .swatch vega-box{width:100%;height:100%}:host .label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .vega-selection-chip{background-color:rgba(var(--v-bg-tile, 252, 252, 252, 1));cursor:pointer;margin:1px}:host .variant-text .label{text-align:center}:host .size-extra-small.variant-swatch.vega-selection-chip{padding-top:2px;padding-bottom:2px;padding-left:2px;padding-right:12px}:host .size-extra-small.variant-text.vega-selection-chip{padding-left:12px;padding-right:12px;padding-top:2px;padding-bottom:2px}:host .size-extra-small vega-flex{height:16px}:host .size-extra-small .swatch{width:12px;height:12px}:host .size-small.variant-swatch.vega-selection-chip{padding-top:4px;padding-bottom:4px;padding-left:4px;padding-right:12px}:host .size-small.variant-text.vega-selection-chip{padding-left:12px;padding-right:12px;padding-top:4px;padding-bottom:4px}:host .size-small vega-flex{height:24px}:host .size-small .swatch{width:20px;height:20px}:host .size-medium.variant-swatch.vega-selection-chip{padding-top:4px;padding-bottom:4px;padding-left:4px;padding-right:16px}:host .size-medium.variant-text.vega-selection-chip{padding-left:16px;padding-right:16px;padding-top:4px;padding-bottom:4px}:host .size-medium vega-flex{height:32px}:host .size-medium .swatch{width:28px;height:28px}:host .size-large.variant-swatch.vega-selection-chip{padding-top:4px;padding-bottom:4px;padding-left:4px;padding-right:20px}:host .size-large.variant-text.vega-selection-chip{padding-left:20px;padding-right:20px;padding-top:4px;padding-bottom:4px}:host .size-large vega-flex{height:40px}:host .size-large .swatch{width:36px;height:36px}:host .vega-selection-chip:not(.disabled){background-color:rgba(var(--v-bg-tile, 252, 252, 252, 1));border:1px solid rgba(var(--v-border-tile, 171, 198, 216, 1))}:host .vega-selection-chip:not(.disabled):hover{background-color:rgba(var(--v-bg-tile-hover, 245, 247, 247, 1));border:1px solid rgba(var(--v-border-tile-hover, 115, 160, 190, 1))}:host .vega-selection-chip:not(.disabled):focus-visible{background-color:rgba(var(--v-bg-tile, 252, 252, 252, 1));outline:2px solid rgba(var(--v-border-color-action, 19, 98, 226, 1));outline-offset:2px;border:1px solid rgba(var(--v-border-tile-focus, 19, 98, 226, 1))}:host .vega-selection-chip:not(.disabled).checked{background-color:rgba(var(--v-bg-tile-selected, 242, 247, 255, 1));border:2px solid rgba(var(--v-border-tile-selected, 19, 98, 226, 1));margin:0px}:host .vega-selection-chip:not(.disabled).checked:hover{background-color:rgba(var(--v-bg-tile-selected-hover, 229, 239, 255, 1));border:2px solid rgba(var(--v-border-tile-selected-hover, 4, 112, 236, 1))}:host .vega-selection-chip:not(.disabled).checked:focus-visible{background-color:rgba(var(--v-bg-tile-selected, 242, 247, 255, 1));border:2px solid rgba(var(--v-border-tile-selected-focus, 19, 98, 226, 1))}:host .vega-selection-chip:not(.disabled).error{background-color:rgba(var(--v-bg-tile, 252, 252, 252, 1));border:1px solid rgba(var(--v-border-input-field-danger, 230, 50, 87, 1))}:host .vega-selection-chip:not(.disabled).error:hover{background-color:rgba(var(--v-bg-tile-hover, 245, 247, 247, 1));border:1px solid rgba(var(--v-border-input-field-danger-hover, 255, 87, 114, 1))}:host .vega-selection-chip:not(.disabled).error:focus-visible{background-color:rgba(var(--v-bg-tile, 252, 252, 252, 1));outline:2px solid rgba(var(--v-border-color-danger, 230, 50, 87, 1));outline-offset:2px;border:1px solid rgba(var(--v-border-input-field-danger-focus, 233, 71, 104, 1))}:host .vega-selection-chip.disabled{background-color:rgba(var(--v-bg-tile, 252, 252, 252, 1));border:1px solid rgba(var(--v-border-input-field-disabled, 222, 225, 227, 1));pointer-events:none;color:rgba(var(--v-text-disabled, 176, 180, 181, 1))}:host .vega-selection-chip.disabled:focus-visible{outline:none}:host .vega-selection-chip.disabled vega-font{color:rgba(var(--v-text-disabled, 176, 180, 181, 1))}:host .vega-selection-chip.disabled .swatch{opacity:0.5}";

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;
};
const VegaSelectionChip = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.vegaChange = createEvent(this, "vegaChange", 7);
    this.change = createEvent(this, "change", 7);
    this.globalSlimmers = {};
    this.renderer = new VegaSelectionChipRenderer();
    this.checkedController = new VegaSelectionChipCheckedController();
    this.stateController = new VegaSelectionChipStateController();
    this.showErrorController = new VegaSelectionChipShowErrorController();
    this.pageResizeObserverSlimmer = new PageResizeObserverSlimmer();
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    this.changeEventEmitter = createEventEmitSlimmer(VegaSelectionChip, VegaChange);
    /**
     * Indicates whether the parent selection chip group shows error message.
     */
    this.showError = false;
    this.currentBreakpoint = getCurrentBreakpoint();
    /**
     * Specifies the label or title for the selection chip.
     * It provides descriptive text that helps identify
     *    the purpose of the selection chip.
     *
     * @vegaVersion 2.22.0
     */
    this.label = '';
    /**
     * Specifies the size of the selection chip.
     *
     * @vegaVersion 2.22.0
     */
    this.size = 'medium';
    /**
     * Determines the rendering style for the selection chip.
     *
     * @vegaVersion 2.22.0
     */
    this.variant = 'text';
    /**
     * Indicates if the selection chip is disabled.
     *
     * @vegaVersion 2.22.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.disabled = false;
    /**
     * Defines the display behavior of the selection chip.
     * This property controls how the chip is presented
     *    in relation to surrounding elements.
     *
     * @vegaVersion 2.22.0
     */
    this.block = false;
    /**
     * Defines the background color of the swatch.
     * It accepts a string value representing a valid
     *    background color token,
     *    which customizes the chip appearance.
     *
     * @vegaVersion 2.22.0
     */
    this.swatchColor = 'bg-status-info';
  }
  watchSize() {
  }
  componentWillRender() {
  }
  render() {
    return sanitizeVegaComponent(this.renderer.render(), this.host);
  }
  get host() { return getElement(this); }
  static get watchers() { return {
    "size": ["watchSize"]
  }; }
};
__decorate$4([
  InjectVegaGlobalSlimmer()
], VegaSelectionChip.prototype, "globalSlimmers", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaSelectionChip.prototype, "renderer", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaSelectionChip.prototype, "checkedController", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaSelectionChip.prototype, "stateController", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaSelectionChip.prototype, "showErrorController", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaSelectionChip.prototype, "pageResizeObserverSlimmer", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaSelectionChip.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaSelectionChip.prototype, "changeEventEmitter", void 0);
VegaSelectionChip.style = vegaSelectionChipCss;

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;
};
class VegaSelectionChipGroupRenderer extends VegaSlimmer {
  getGroupContainerRef() {
    return this.groupContainerRef;
  }
  render() {
    return (h("div", null,
      this.renderLabel(),
      this.renderContainer(),
      this.renderHint()));
  }
  renderLabel() {
    return (h("vega-field-label", { "is-field-required": this.required, disabled: this.disabled, label: this.label }));
  }
  renderContainer() {
    return (h("div", { class: "container", ref: (ref) => (this.groupContainerRef = ref) },
      h("slot", null)));
  }
  renderHint() {
    return (this.hint && (h("div", { class: "vega-hint" },
      h("label", null, this.hint))));
  }
}
__decorate$3([
  MapToComponentField()
], VegaSelectionChipGroupRenderer.prototype, "host", void 0);
__decorate$3([
  MapToComponentField()
], VegaSelectionChipGroupRenderer.prototype, "label", void 0);
__decorate$3([
  MapToComponentField()
], VegaSelectionChipGroupRenderer.prototype, "required", void 0);
__decorate$3([
  MapToComponentField()
], VegaSelectionChipGroupRenderer.prototype, "hint", void 0);
__decorate$3([
  MapToComponentField()
], VegaSelectionChipGroupRenderer.prototype, "disabled", 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;
};
/**
 * Manager the value of vega selection chip group.
 */
class VegaSelectionChipGroupValueController extends VegaSlimmer {
  /**
   * The `watchValue` function emits a change event with the current value and notifies the
   * `ChangeManager` about a form element value change.
   */
  watchValue() {
    this.changeEventEmitter.emit(this.value);
    ChangeManager.notify(FORM_ELEMENT_VALUE_CHANGE, {
      host: this.host,
      detail: this.value,
    });
  }
  /**
   * Set group value.
   *
   * @param {string[] | string} value - value.
   */
  setValue(value) {
    if (this.valueGuard(value)) {
      this.value = value;
    }
  }
  /**
   * The function `valueGuard` checks if the input value is valid based on the select type.
   *
   * @param {string[] | string} value - value.
   * @returns {boolean} is valid value.
   */
  valueGuard(value) {
    switch (this.selectType) {
      case 'radio':
        return typeof value === 'string';
      case 'checkbox':
        return Array.isArray(value) && value.every((item) => typeof item === 'string');
      default:
        LogUtility.warn(`Invalid selection chip group value ${value} for ${this.selectType} mode`);
        return false;
    }
  }
}
__decorate$2([
  MapToComponentField()
], VegaSelectionChipGroupValueController.prototype, "host", void 0);
__decorate$2([
  MapToComponentField({ writable: true })
], VegaSelectionChipGroupValueController.prototype, "value", void 0);
__decorate$2([
  MapToComponentField()
], VegaSelectionChipGroupValueController.prototype, "changeEventEmitter", void 0);
__decorate$2([
  MapToComponentField()
], VegaSelectionChipGroupValueController.prototype, "selectType", void 0);
__decorate$2([
  MapToComponentMethod('watchValue')
], VegaSelectionChipGroupValueController.prototype, "watchValue", 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;
};
/**
 * Observer child items change to update value.
 */
class VegaSelectionChipGroupItemsController extends VegaSlimmer {
  constructor() {
    super(...arguments);
    this.mutationObserver = new MutationObserverSlimmer({
      // eslint-disable-next-line jsdoc/require-jsdoc
      target: () => this.host,
      options: {
        childList: true,
        subtree: true,
        attributes: true,
        attributeFilter: ['checked'],
      },
      mutationFilter: TagNameAndAttributeMutationFilter('VEGA-SELECTION-CHIP'),
      /*
       * The below method is e2e-test covered in
       * @see{module:vega-selection-chip-group-radio-slot-change-e2e}
       * @see{module:vega-selection-chip-group-checkbox-slot-change-e2e}
       */
      // eslint-disable-next-line jsdoc/require-jsdoc
      callback: this.syncChipArrayAndValue.bind(this),
    });
    this.selectionChipArray = [];
  }
  /**
   * Component lifecycle - [disconnectedCallback]
   */
  disconnectedCallback() {
  }
  /**
   * Component lifecycle - [componentWillLoad]
   */
  componentWillLoad() {
    if (!this.value || this.value.length === 0) {
      this.syncChipArrayAndValue();
    }
  }
  /**
   * Component lifecycle - [componentDidLoad]
   */
  componentDidLoad() {
  }
  /**
   * watchSelectType
   */
  watchSelectType() {
    this.syncChipArrayAndValue();
  }
  /**
   * The function returns current chip items array.
   *
   * @returns {HTMLVegaSelectionChipElement[]} - current chip items.
   */
  getSelectionChipArray() {
    return this.selectionChipArray;
  }
  /**
   * Synchronizes the selection chip array and the selected value based on the select type.
   *
   * @param {MutationRecord[]} mutations - Mutations record
   */
  syncChipArrayAndValue(mutations) {
    this.selectionChipArray = Array.from(this.host.querySelectorAll('vega-selection-chip'));
    this.selectType === 'checkbox'
      ? this.setValueFromCheckboxItems()
      : this.setValueFromRadioItems(mutations);
  }
  /**
   * Sets the value of an element based on the checked items in a selection chip array.
   */
  setValueFromCheckboxItems() {
    const currentValue = this.selectionChipArray
      .filter((chip) => chip.checked)
      .map((chip) => chip.value);
    // Should skip update the value while same items with different order are in the two value arrays.
    // ticket: https://gethired.atlassian.net/browse/VD-4534
    if (!isArrayEqual(this.value, currentValue, true)) {
      this.valueController.setValue(currentValue);
    }
  }
  /**
   * Sets the value of a radio item based on the checked status of the items.
   *
   * @param {MutationRecord[]} mutations - Mutations record
   */
  setValueFromRadioItems(mutations) {
    const mutation = this.findAttributeMutation(mutations);
    if (mutation) {
      const chip = this.getCurrentChip(mutation);
      if (chip && chip.checked) {
        this.valueController.setValue(chip.value);
      }
    }
    else {
      const chip = this.getFirstCheckedChip();
      this.valueController.setValue(chip ? chip.value : '');
    }
  }
  /**
   * Find the changed attribute mutation record.
   *
   * @param {MutationRecord[]} mutations - Mutations record
   * @returns {Nullable<MutationRecord>} - Changed attribute mutation record..
   */
  findAttributeMutation(mutations) {
    return mutations && mutations.find((mutation) => mutation.attributeName);
  }
  /**
   * Get the current checked chip element from mutation.
   *
   * @param {MutationRecord} mutation - mutation.
   * @returns {Nullable<HTMLVegaSelectionChipElement>} The current checked chip.
   */
  getCurrentChip(mutation) {
    if (mutation &&
      mutation.target.tagName === 'VEGA-SELECTION-CHIP' &&
      mutation.attributeName === 'checked') {
      return mutation.target;
    }
  }
  /**
   * Get the first checked chip element from an array of selection chips.
   *
   * @returns {Nullable<HTMLVegaSelectionChipElement>} The first checked chip.
   */
  getFirstCheckedChip() {
    return this.selectionChipArray.find((chip) => chip.checked);
  }
}
__decorate$1([
  MapToComponentField()
], VegaSelectionChipGroupItemsController.prototype, "host", void 0);
__decorate$1([
  MapToComponentField()
], VegaSelectionChipGroupItemsController.prototype, "selectType", void 0);
__decorate$1([
  MapToComponentField()
], VegaSelectionChipGroupItemsController.prototype, "valueController", void 0);
__decorate$1([
  MapToComponentField()
], VegaSelectionChipGroupItemsController.prototype, "value", void 0);
__decorate$1([
  InjectVegaSlimmer()
], VegaSelectionChipGroupItemsController.prototype, "mutationObserver", void 0);
__decorate$1([
  MapToComponentMethod('disconnectedCallback')
], VegaSelectionChipGroupItemsController.prototype, "disconnectedCallback", null);
__decorate$1([
  MapToComponentMethod('componentWillLoad')
], VegaSelectionChipGroupItemsController.prototype, "componentWillLoad", null);
__decorate$1([
  MapToComponentMethod('componentDidLoad')
], VegaSelectionChipGroupItemsController.prototype, "componentDidLoad", null);
__decorate$1([
  MapToComponentMethod('watchSelectType')
], VegaSelectionChipGroupItemsController.prototype, "watchSelectType", null);

const vegaSelectionChipGroupCss = ":host{display:block}:host vega-field-label{margin-bottom:8px}:host .vega-hint{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:4px;padding-left:8px;padding-right:8px}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-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){:host .vega-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){:host .vega-hint{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}:host .vega-error{display:block;margin-top:12px;margin-left:8px;margin-right: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){:host .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){:host .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){:host .vega-error{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}:host .vega-hidden{display:none}";

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 VegaSelectionChipGroup = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.vegaChange = createEvent(this, "vegaChange", 7);
    this.change = createEvent(this, "change", 7);
    this.globalSlimmers = {};
    this.renderer = new VegaSelectionChipGroupRenderer();
    this.itemsController = new VegaSelectionChipGroupItemsController();
    this.valueController = new VegaSelectionChipGroupValueController();
    this.formFieldController = new FormFieldControllerSlimmer({
      propertyRules: [
        {
          propertyName: 'required',
          ruleFactory: (isRequired) => (isRequired ? new RequiredFieldRule() : null),
        },
      ],
      validationRulesName: 'validationRules',
      inputContainerGetter: () => this.renderer.getGroupContainerRef(),
      touchableAreaGetter: () => this.itemsController.getSelectionChipArray(),
      defaultValue: (target) => (target.selectType === 'checkbox' ? [] : ''),
      attributeGetter: (propertyName) => this[propertyName],
    });
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    this.changeEventEmitter = createEventEmitSlimmer(VegaSelectionChipGroup, VegaChange);
    this.valueNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionChipGroup, 'value', 'watchValue');
    this.disabledNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionChipGroup, 'disabled', 'watchDisabled');
    this.selectTypeNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionChipGroup, 'selectType', 'watchSelectType');
    this.changeEventPrevent = new ChildNodesEventPreventSlimmer([VegaChange], () => this.host, true);
    /**
     * Specifies the label or title for the selection chip group.
     *    It provides descriptive text that helps identify
     *    the purpose of the selection chip group.
     *
     * @vegaVersion 2.22.0
     */
    this.label = '';
    /**
     * Determines the selection method for the chip group.
     *
     * @vegaVersion 2.22.0
     */
    this.selectType = 'radio';
    /**
     * Stores the selected values of the nested selection chips
     *    within the selection chip group.
     *
     * @vegaVersion 2.22.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.value = this.selectType === 'checkbox' ? [] : '';
    /**
     * Defines custom validation rules for the selection chip group field.
     *
     * @vegaVersion 2.22.0
     */
    this.validationRules = [];
    /**
     * Sets the validation status for the selection chip group.
     *
     * @vegaVersion 2.22.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.isValid = null;
  }
  watchSelectType() {
  }
  watchValue() {
  }
  watchDisabled() {
  }
  watchValidationRules() {
  }
  render() {
    return sanitizeVegaComponent(h(Host, null, this.renderer.render()), this.host);
  }
  get host() { return getElement(this); }
  static get watchers() { return {
    "selectType": ["watchSelectType"],
    "value": ["watchValue"],
    "disabled": ["watchDisabled"],
    "validationRules": ["watchValidationRules"]
  }; }
};
__decorate([
  InjectVegaGlobalSlimmer()
], VegaSelectionChipGroup.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionChipGroup.prototype, "renderer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionChipGroup.prototype, "itemsController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionChipGroup.prototype, "valueController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionChipGroup.prototype, "formFieldController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionChipGroup.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionChipGroup.prototype, "changeEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionChipGroup.prototype, "valueNotifySlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionChipGroup.prototype, "disabledNotifySlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionChipGroup.prototype, "selectTypeNotifySlimmer", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaSelectionChipGroup.prototype, "changeEventPrevent", void 0);
VegaSelectionChipGroup.style = vegaSelectionChipGroupCss;

export { VegaSelectionChip as vega_selection_chip, VegaSelectionChipGroup as vega_selection_chip_group };
