import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-090d31ca.js';
import { c as createEnterKeyHandlerToTriggerClick } from './accessibility-524cabd2.js';
import { s as sanitizeVegaComponent } from './component-7d906393.js';
import { C as ChangeManager } from './change-manager-6a7eb88c.js';
import { R as RADIO_VALUE_CHANGE, h as RADIO_GROUP_DISABLED_CHANGE, F as FORM_ELEMENT_VALUE_CHANGE } from './static-subject-title-52f93124.js';
import { O as Observer } from './observer-3959f9dd.js';
import { f as findParent } from './ui-64815a12.js';
import { c as MapToComponentField, M as MapToComponentMethod, V as VegaSlimmer, I as InjectVegaSlimmer } from './global-slimmer-registry-17c4efd4.js';
import { V as VegaComponentUsageRuntimeMetricsSlimmer, I as InjectVegaGlobalSlimmer } from './component-usage-runtime-metrics-46020a03.js';
import { c as createEventEmitSlimmer } from './event-emit-slimmer-697ad0b7.js';
import { i as VegaChange, H as VegaFocus, I as VegaBlur } from './vega-event-id-578c6c6d.js';
import { h as VegaInternalFieldErrorStateChange } from './vega-internal-event-id-913e8be6.js';
import { d as domNodeSubjectFactory } from './dom-node-subject-observer-factory-3897e95b.js';
import { R as RequiredFieldRule } from './required-field-rule-ab4bdc47.js';
import { C as ComponentLoadRequired } from './component-load-required-db42032a.js';
import { F as FormFieldControllerSlimmer } from './form-field-controller-slimmer-9e70a18d.js';
import { C as ChildNodesNotifyObserverSlimmer } from './child-nodes-notify-observer-slimmer-8822d0d0.js';
import { C as ChildNodesEventPreventSlimmer } from './child-nodes-event-prevent-slimmer-2fcba81b.js';
import { K as KeyboardManagerSlimmer } from './keyboard-manager-slimmer-012a9a9b.js';
import { M as MutationObserverSlimmer } from './mutation-observer-slimmer-58ebc13c.js';
import { T as TagNameMutationFilter } from './mutation-observer-filters-1a054fb0.js';
import './dynamic-slimmer-90b8af32.js';
import './internal-vega-event-manager-1ac5ee9a.js';
import './try-get-document-bef0f526.js';
import './internal-form-field-validation-rule.abstract-f5b6bdbf.js';
import './string-a953eafc.js';
import './misc-9fdbcfbb.js';
import './internal-translation-controller-d8217d93.js';
import './index-3b327f29.js';
import './page-resize-observer-slimmer-e24d36c5.js';
import './breakpoints-332702ed.js';
import './ui-93922c59.js';
import './breakpoints-d9faf11c.js';
import './array-7888f339.js';
import './number-4398f2e1.js';
import './sub-state-observer-slimmer-81538a8c.js';
import './vega-env-manager-8f8dc473.js';
import './feature-flag-controller-30f7b625.js';
import './index-bfc6dfa2.js';
import './keyboard-manager-26e2fc32.js';
import './type-guard-ed1004cc.js';
import './typography-396de03f.js';

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 radio show error controller slimmer */
class VegaRadioShowErrorController extends VegaSlimmer {
  /**
   * Component lifecycle - [connectedCallback]{@link VegaRadio.connectedCallback}
   */
  connectedCallback() {
    this.radioGroup =
      findParent(this.host, 'vega-radio-group') || findParent(this.host, 'vega-selection-tile-group');
    if (this.radioGroup) {
      this.fieldErrorObserver = new Observer(this.canAcceptFieldErrorObserver.bind(this), this.fieldErrorObserverListener.bind(this));
      ChangeManager.register(domNodeSubjectFactory.getSubject(this.radioGroup, VegaInternalFieldErrorStateChange), this.fieldErrorObserver);
    }
  }
  /**
   * Component lifecycle - [disconnectedCallback]{@link VegaRadio.disconnectedCallback}
   */
  disconnectedCallback() {
    if (this.radioGroup) {
      ChangeManager.unregister(domNodeSubjectFactory.getSubject(this.radioGroup, VegaInternalFieldErrorStateChange), this.fieldErrorObserver);
    }
  }
  /**
   * The function checks whether the current host is radio group.
   *
   * @param {FieldErrorPayload} payload - The payload parameter is of type FieldErrorPayload, which is an object containing information about field.
   * @returns {boolean} a boolean value, which indicates the current host is radio group.
   */
  canAcceptFieldErrorObserver(payload) {
    return ((payload.host.tagName === 'VEGA-RADIO-GROUP' ||
      payload.host.tagName === 'VEGA-SELECTION-TILE-GROUP') &&
      this.radioGroup === payload.host);
  }
  /**
   * 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 })
], VegaRadioShowErrorController.prototype, "showError", void 0);
__decorate$5([
  MapToComponentField()
], VegaRadioShowErrorController.prototype, "host", void 0);
__decorate$5([
  MapToComponentMethod('connectedCallback')
], VegaRadioShowErrorController.prototype, "connectedCallback", null);
__decorate$5([
  MapToComponentMethod('disconnectedCallback')
], VegaRadioShowErrorController.prototype, "disconnectedCallback", null);

const vegaRadioCss = ":host{display:inline-block;box-sizing:border-box;height:24px}.vega-radio-container{position:relative;display:inline-flex;gap:8px;cursor:not-allowed}.vega-radio-container:not(.vega-radio-disabled){cursor:pointer}.vega-radio-container input{position:absolute;left:0px;top:0px;opacity:0}.vega-radio-icon{display:inline-block;box-sizing:border-box;border-style:solid;border-radius:9999px;position:relative;left:0px;flex-shrink:0;border:1px solid rgba(var(--v-border-input-field, 171, 198, 216, 1));background-color:rgba(var(--v-bg-primary, 252, 252, 252, 1))}.vega-radio-icon:hover{border:1px solid rgba(var(--v-border-input-field-hover, 115, 160, 190, 1))}.vega-radio-container.default .vega-radio-icon{width:24px;height:24px;padding:5px}.vega-radio-container.small .vega-radio-icon{width:16px;height:16px;padding:4px}.vega-radio-checked:hover .vega-radio-circle{background-color:rgba(var(--v-bg-action-hover, 4, 112, 236, 1))}.vega-radio-container input[type=radio]:focus-visible+.vega-radio-icon{outline:2px solid rgba(var(--v-border-color-action, 19, 98, 226, 1));outline-offset:3px}.vega-radio-container:not(.vega-radio-disabled):active .vega-radio-icon{border-width:1px;border-style:solid;border-color:rgba(var(--v-border-color-action-active, 29, 65, 195, 1))}.vega-radio-checked:active .vega-radio-circle{background-color:rgba(var(--v-bg-action-active, 29, 65, 195, 1))}.vega-radio-checked .vega-radio-circle{display:block;width:100%;height:100%;border-radius:9999px;background-color:rgba(var(--v-bg-action, 19, 98, 226, 1))}.vega-radio-disabled .vega-radio-icon{background-color:rgba(var(--v-bg-secondary, 245, 247, 247, 1));border:1px solid rgba(var(--v-border-input-field-disabled, 222, 225, 227, 1))}.vega-radio-disabled .vega-radio-circle{background-color:rgba(var(--v-bg-disabled, 176, 180, 181, 1))}.vega-radio-disabled:hover .vega-radio-circle{background-color:rgba(var(--v-bg-disabled, 176, 180, 181, 1))}.vega-radio-container .vega-radio-label{display:inline-block;color:rgba(var(--v-text-primary, 32, 54, 69, 1))}.vega-radio-container .vega-radio-label.vega-hidden{display:none}.vega-radio-container.default .vega-radio-label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}@media screen and (min-width: 768px) and (max-width: 1023px){.vega-radio-container.default .vega-radio-label{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-radio-container.default .vega-radio-label{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-radio-container.default .vega-radio-label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}}.vega-radio-container.small .vega-radio-label{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px}@media screen and (min-width: 768px) and (max-width: 1023px){.vega-radio-container.small .vega-radio-label{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px}}@media screen and (min-width: 1024px) and (max-width: 1439px){.vega-radio-container.small .vega-radio-label{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px}}@media screen and (min-width: 1440px) and (max-width: 9999px){.vega-radio-container.small .vega-radio-label{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px}}.vega-radio-disabled .vega-radio-label{color:rgba(var(--v-text-disabled, 176, 180, 181, 1))}label{-webkit-tap-highlight-color:transparent}.vega-radio-container.error .vega-radio-icon{border:1px solid rgba(var(--v-border-input-field-danger, 230, 50, 87, 1))}.vega-radio-container.error:hover .vega-radio-icon{border:1px solid rgba(var(--v-border-input-field-danger-hover, 255, 87, 114, 1))}.vega-radio-container.error input[type=radio]:focus-visible+.vega-radio-icon{outline:2px solid rgba(var(--v-border-color-danger, 230, 50, 87, 1));outline-offset:3px}.vega-radio-container.error:active .vega-radio-icon{outline:2px solid rgba(var(--v-border-color-danger, 230, 50, 87, 1));outline-offset:3px}.vega-radio-checked.error .vega-radio-circle{background-color:rgba(var(--v-bg-danger, 189, 41, 71, 1))}.vega-radio-checked.error:hover .vega-radio-circle{background-color:rgba(var(--v-bg-danger-hover, 233, 71, 104, 1))}.vega-radio-checked.error:active .vega-radio-circle{background-color:rgba(var(--v-bg-danger-active, 230, 50, 87, 1))}";

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 VegaRadio = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.vegaFocus = createEvent(this, "vegaFocus", 7);
    this.focus = createEvent(this, "focus", 7);
    this.vegaBlur = createEvent(this, "vegaBlur", 7);
    this.blur = createEvent(this, "blur", 7);
    this.vegaChange = createEvent(this, "vegaChange", 7);
    this.change = createEvent(this, "change", 7);
    this.globalSlimmers = {};
    this.changeEventEmitter = createEventEmitSlimmer(VegaRadio, VegaChange);
    this.focusEventEmitter = createEventEmitSlimmer(VegaRadio, VegaFocus);
    this.blurEventEmitter = createEventEmitSlimmer(VegaRadio, VegaBlur);
    this.vegaRadioShowErrorController = new VegaRadioShowErrorController();
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    /**
     * Indicates whether the parent radio group is disabled.
     */
    this.groupDisabled = false;
    /**
     * Indicates whether the parent radio group show error message.
     */
    this.showError = false;
    /**
     * Represents the value associated with the radio button
     *    that is currently selected or checked.
     *
     * @vegaVersion 1.0.7
     */
    this.value = '';
    /**
     * Determines if the radio button is selected or checked.
     *
     * @vegaVersion 1.0.7
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.checked = false;
    /**
     * Determines if the radio button is disabled.
     *
     * @vegaVersion 1.3.0
     */
    this.disabled = false;
    /**
     * Specifies the size of the Radio Button component.
     *
     * The size should be selected based on the context and
     *    design requirements of the specific form.
     *
     * @vegaVersion 1.9.2
     */
    this.size = 'default';
    /**
     * The below method is e2e-test covered in
     * @see{module:vega-radio-change-e2e}
     */
    /* istanbul ignore next */
    this.updateValue = (e) => {
      const currentTarget = e.currentTarget;
      this.checked = currentTarget.checked;
      e.stopPropagation();
    };
    /**
     * The below method is e2e-test covered in
     * @see{module:vega-radio-focus-e2e}
     */
    /* istanbul ignore next */
    this.handleFocus = (e) => {
      this.focusEventEmitter.emit(e, e);
    };
    /**
     * The below method is e2e-test covered in
     * @see{module:vega-radio-blur-e2e}
     */
    /* istanbul ignore next */
    this.handleBlur = (e) => {
      this.blurEventEmitter.emit(e, e);
    };
    this.handleClick = (e) => {
      e.stopPropagation();
    };
  }
  watchCheckedChange() {
    this.changeEventEmitter.emit(this.checked);
    ChangeManager.notify(RADIO_VALUE_CHANGE, { host: this.host, detail: this.checked });
  }
  connectedCallback() {
    this.ariaLabel = this.host.textContent;
    if (this.ariaLabel == '') {
      this.ariaLabel = this.value;
    }
  }
  disconnectedCallback() {
    this.unRegisterGroupDisabledObserver();
  }
  componentDidLoad() {
    if (this.host.textContent === '') {
      this.labelElement.classList.add('vega-hidden');
    }
    this.initAndRegisterGroupDisabledObserver();
  }
  render() {
    var _a;
    /* istanbul ignore next */
    const isInsideRadioGroup = ((_a = this.host.parentElement) === null || _a === void 0 ? void 0 : _a.nodeName) == 'VEGA-RADIO-GROUP';
    return sanitizeVegaComponent(h(Host, { class: {
        'vega-flex-shrink-0 v-min-w-min': isInsideRadioGroup,
      } }, h("label", { class: {
        'vega-radio-container': true,
        [this.size]: true,
        'vega-radio-checked': this.checked,
        'vega-radio-disabled': this.isDisabled(),
        'error': this.showError,
      } }, h("input", { type: "radio", name: this.name, checked: this.checked, value: this.value, onFocus: this.handleFocus, onBlur: this.handleBlur, onClick: this.handleClick, onChange: this.updateValue, "aria-label": this.ariaLabel || 'No label defined', disabled: this.isDisabled(), tabIndex: this.isDisabled() ? -1 : 0, onKeyDown: createEnterKeyHandlerToTriggerClick() }), h("span", { class: "vega-radio-icon" }, h("span", { class: "vega-radio-circle" })), h("div", { class: "vega-radio-label", ref: (ref) => (this.labelElement = ref) }, h("slot", null)))), this.host);
  }
  /**
   * indicating whether the component is disabled or not, single radio will take the self disabled value and the radio in group will take the self disabled and group disabled value
   *
   * @returns {boolean} the radio disabled or not
   */
  isDisabled() {
    return this.disabled || this.groupDisabled;
  }
  /**
   * The function checks if a radio button element can accept a disabled state from a group.
   *
   * @param {GroupDisabledPayload} input - The input parameter is of type GroupDisabledPayload, which is an object containing information about a disabled radio button group.
   * @returns {boolean} a boolean value, which indicates whether the input element (this.host) is present in a group  of radio buttons (vega-radio) or not.
   */
  canAcceptGroupDisabledObserver(input) {
    return findParent(this.host, 'vega-radio-group') === input.host;
  }
  /**
   * This function listens for changes in the disabled state of a group and updates the `groupDisabled` variable accordingly.
   *
   * @param {GroupDisabledPayload} input - The input parameter is of type GroupDisabledPayload, which is likely an object containing information about a disabled group.
   */
  groupDisabledObserverListener(input) {
    this.groupDisabled = input.host.disabled;
  }
  /**
   * This function initializes an observer for changes in the disabled state of a radio group.
   */
  initAndRegisterGroupDisabledObserver() {
    if (findParent(this.host, 'vega-radio-group')) {
      this.groupDisabledObserver = new Observer(this.canAcceptGroupDisabledObserver.bind(this), this.groupDisabledObserverListener.bind(this));
      ChangeManager.register(RADIO_GROUP_DISABLED_CHANGE, this.groupDisabledObserver);
    }
  }
  /**
   * This function unregister a group disabled observer if it exists.
   */
  unRegisterGroupDisabledObserver() {
    if (this.groupDisabledObserver) {
      ChangeManager.unregister(RADIO_GROUP_DISABLED_CHANGE, this.groupDisabledObserver);
    }
  }
  get host() { return getElement(this); }
  static get watchers() { return {
    "checked": ["watchCheckedChange"]
  }; }
};
__decorate$4([
  InjectVegaGlobalSlimmer()
], VegaRadio.prototype, "globalSlimmers", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaRadio.prototype, "changeEventEmitter", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaRadio.prototype, "focusEventEmitter", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaRadio.prototype, "blurEventEmitter", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaRadio.prototype, "vegaRadioShowErrorController", void 0);
__decorate$4([
  InjectVegaSlimmer()
], VegaRadio.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaRadio.style = vegaRadioCss;

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;
};
/** Provides keyboard control functionality for vega-radio. */
class VegaRadioGroupKeyboardController extends KeyboardManagerSlimmer {
  /**
   * The constructor function sets up keyboard event listeners for a radio component.
   */
  constructor() {
    /* istanbul ignore next */
    super((target) => {
      target.setRadioArrayTabIndex();
      return [
        {
          keyCode: ['ArrowUp', 'ArrowDown'],
          activeElementInScope: [target.host],
          /**
           * switch the element focus when keyboard press
           *
           * @param {KeyboardEvent} event event object
           */
          callback: /* istanbul ignore next */ (event) => {
            this.updateRadioFocusStates(event);
          },
        },
      ];
    });
  }
  /*
   * The below method is e2e-test covered in
   * @see{module:vega-radio-group-keyboard-control-e2e}
   */
  /* istanbul ignore next */
  /**
   * It dynamically sets the value of the element tabIndex.
   */
  setRadioArrayTabIndex() {
    const radioArray = this.getNotDisabledRadioArray();
    if (radioArray) {
      const checkedItemIndex = radioArray.findIndex((radio) => radio.checked);
      const defaultFocusIndex = checkedItemIndex > -1 ? checkedItemIndex : 0;
      radioArray.forEach((radio, index) => {
        const tabIndex = index === defaultFocusIndex ? '0' : '-1';
        radio.shadowRoot.querySelector('input').setAttribute('tabIndex', tabIndex);
      });
    }
  }
  /*
   * The below method is e2e-test covered in
   * @see{module:vega-radio-group-keyboard-up-down-control-e2e}
   */
  /* istanbul ignore next */
  /**
   *  It is used to switch the focus between different elements based on the arrow key pressed.
   *
   * @param {KeyboardEvent} event key code up or down
   */
  updateRadioFocusStates(event) {
    const keyCode = event.key;
    const radioArray = this.getNotDisabledRadioArray();
    if (!radioArray || radioArray.length === 0)
      return;
    radioArray.forEach((item) => item.shadowRoot.querySelector('input').setAttribute('tabIndex', '-1'));
    const activeIndex = radioArray.findIndex((radio) => radio === event.target);
    let nextActiveElement;
    if (keyCode === 'ArrowDown') {
      nextActiveElement =
        activeIndex === radioArray.length - 1 ? radioArray[0] : radioArray[activeIndex + 1];
    }
    else if (keyCode === 'ArrowUp') {
      nextActiveElement =
        activeIndex === 0 ? radioArray[radioArray.length - 1] : radioArray[activeIndex - 1];
    }
    if (nextActiveElement) {
      nextActiveElement.shadowRoot.querySelector('input').focus();
      nextActiveElement.checked = true;
      nextActiveElement.shadowRoot.querySelector('input').tabIndex = 0;
    }
  }
  /**
   * filter out disabled elements.
   *
   * @returns {Nullable<HTMLVegaRadioElement[]> } radios element
   */
  getNotDisabledRadioArray() {
    const radios = Array.from(this.host.querySelectorAll('vega-radio'));
    if (radios.length > 0) {
      return radios.filter((item) => !item.disabled);
    }
  }
}
__decorate$3([
  MapToComponentField()
], VegaRadioGroupKeyboardController.prototype, "host", 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 `VegaRadioGroupValueController` class in TypeScript manages the value and change events for a radio group component. */
class VegaRadioGroupValueController extends VegaSlimmer {
  /**
   * The function syncs radio items status, emits an event with the new value, and notifies a change manager.
   *
   * @param {string} newValue - newValue is a string value that represents the new value to be set for the radio items.
   */
  emitEventAndNotifyValueChangeSubject(newValue) {
    this.changeEventEmitter.emit(newValue);
    ChangeManager.notify(FORM_ELEMENT_VALUE_CHANGE, {
      host: this.host,
      detail: newValue,
    });
  }
  /**
   * The function `setValue` in TypeScript sets a new value for a variable.
   *
   * @param {string} newValue - new value that will be assigned to the `value` property
   */
  setValue(newValue) {
    this.value = newValue;
  }
}
__decorate$2([
  MapToComponentField()
], VegaRadioGroupValueController.prototype, "host", void 0);
__decorate$2([
  MapToComponentField({ writable: true })
], VegaRadioGroupValueController.prototype, "value", void 0);
__decorate$2([
  MapToComponentField()
], VegaRadioGroupValueController.prototype, "changeEventEmitter", void 0);
__decorate$2([
  MapToComponentField()
], VegaRadioGroupValueController.prototype, "radioItemsController", void 0);
__decorate$2([
  MapToComponentMethod('watchValue')
], VegaRadioGroupValueController.prototype, "emitEventAndNotifyValueChangeSubject", 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 class `VegaRadioGroupRadioItemsController` manages a group of radio items within a VegaRadioGroup component in TypeScript. */
class VegaRadioGroupRadioItemsController extends VegaSlimmer {
  constructor() {
    super(...arguments);
    this.vegaRadioArray = [];
  }
  /**
   * The function `queryRadioItemsAndSetValue` retrieves all `vega-radio` elements and sets the default value based on the checked item.
   */
  componentWillLoad() {
    this.syncRadioArrayAndValue();
  }
  /**
   * The function `setRadioItemName` assigns a name to each radio item in the `vegaRadioArray` based on the component's `name` property or the `name` attribute of the radio item.
   */
  setRadioItemName() {
    this.vegaRadioArray.forEach((vegaRadio) => {
      if (this.name) {
        vegaRadio.name = this.name;
      }
      else {
        vegaRadio.name = vegaRadio.getAttribute('name');
      }
    });
  }
  /**
   * The function sets the checked property of a radio item in an array based on a specified value.
   *
   * @param {string} newValue - The `newValue` parameter in the `setRadioItemCheckedByValue` method is a
   * string value that represents the value of the radio item that you want to set as checked in a group
   * of radio items. The method iterates over an array of radio elements (`vegaRadioArray`) and sets
   */
  setRadioItemCheckedByValue(newValue) {
    this.vegaRadioArray.forEach((vegaRadio) => {
      vegaRadio.checked = vegaRadio.value === newValue;
    });
  }
  /**
   * The function syncs the status of radio items based on a specified value.
   */
  syncRadioItemsStatus() {
    this.setRadioItemCheckedByValue(this.value);
    this.setRadioItemName();
  }
  /**
   * The function returns an array of HTMLVegaRadioElement objects.
   *
   * @returns {HTMLVegaRadioElement[]} An array of HTMLVegaRadioElement objects is being returned.
   */
  getRadioItemsArray() {
    return this.vegaRadioArray;
  }
  /**
   * The function collect radio items and sync the radio group value.
   */
  syncRadioArrayAndValue() {
    this.vegaRadioArray = Array.from(this.host.querySelectorAll('vega-radio'));
    this.vegaRadioArray.forEach((vegaRadio) => {
      if (vegaRadio.checked) {
        this.valueController.setValue(vegaRadio.value);
      }
    });
  }
}
__decorate$1([
  MapToComponentField()
], VegaRadioGroupRadioItemsController.prototype, "host", void 0);
__decorate$1([
  MapToComponentField()
], VegaRadioGroupRadioItemsController.prototype, "value", void 0);
__decorate$1([
  MapToComponentField()
], VegaRadioGroupRadioItemsController.prototype, "name", void 0);
__decorate$1([
  MapToComponentField()
], VegaRadioGroupRadioItemsController.prototype, "valueController", void 0);
__decorate$1([
  MapToComponentMethod('componentWillLoad')
], VegaRadioGroupRadioItemsController.prototype, "componentWillLoad", null);
__decorate$1([
  MapToComponentMethod('watchName')
], VegaRadioGroupRadioItemsController.prototype, "setRadioItemName", null);
__decorate$1([
  MapToComponentMethod('watchValue')
], VegaRadioGroupRadioItemsController.prototype, "setRadioItemCheckedByValue", null);
__decorate$1([
  MapToComponentMethod('componentDidLoad')
], VegaRadioGroupRadioItemsController.prototype, "syncRadioItemsStatus", null);

const vegaRadioGroupCss = ":host{display:block;text-align:left;line-height:normal}.vega-error{display:block;margin-top:12px;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-label{margin-bottom:16px}.vega-label label{font-family:\"Inter\", sans-serif;font-size:18px;font-weight:500;line-height:30px;letter-spacing:0px;color:rgba(var(--v-text-primary, 32, 54, 69, 1))}@media screen and (min-width: 768px) and (max-width: 1023px){.vega-label label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:28px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){.vega-label label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:28px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){.vega-label label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:28px;letter-spacing:0px}}.vega-require{color:rgba(var(--v-text-error, 189, 41, 71, 1));margin-left:4px}.vega-hint{padding-top:12px}.vega-hint>label{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))}@media screen and (min-width: 768px) and (max-width: 1023px){.vega-hint>label{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-hint>label{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-hint>label{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:18px;letter-spacing:0px}}";

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 VegaRadioGroup = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.vegaChange = createEvent(this, "vegaChange", 7);
    this.change = createEvent(this, "change", 7);
    this.globalSlimmers = {};
    this.formFieldController = new FormFieldControllerSlimmer({
      propertyRules: [
        {
          propertyName: 'required',
          ruleFactory: (isRequired) => (isRequired ? new RequiredFieldRule() : null),
        },
      ],
      inputContainerGetter: () => this.inputContainerRef,
      touchableAreaGetter: () => this.radioItemsController
        .getRadioItemsArray()
        .map((vegaRadio) => vegaRadio.shadowRoot.querySelector('input')),
      defaultValue: '',
      attributeGetter: (propertyName) => this[propertyName],
      validationRulesName: 'validationRules',
    });
    this.radioValueChangeObserver = new ChildNodesNotifyObserverSlimmer(RADIO_VALUE_CHANGE, (payload) => this.childRadioValueChange(payload));
    this.radioEventPrevent = new ChildNodesEventPreventSlimmer([VegaChange], () => this.vegaFlexElement);
    this.slotMutationObserver = new MutationObserverSlimmer({
      options: { childList: true },
      mutationFilter: TagNameMutationFilter('VEGA-RADIO'),
      callback: 
      /*
       * The below method is e2e-test covered in
       * @see{module:vega-radio-group-slot-change-e2e}
       */
      /* istanbul ignore next */
      () => this.radioItemsController.syncRadioArrayAndValue(),
    });
    this.changeEventEmitter = createEventEmitSlimmer(VegaRadioGroup, VegaChange);
    this.keyboardController = new VegaRadioGroupKeyboardController();
    this.radioItemsController = new VegaRadioGroupRadioItemsController();
    this.valueController = new VegaRadioGroupValueController();
    this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
    /**
     * Specifies the label or title of the radio group.
     *
     * @vegaVersion 1.3.0
     */
    this.label = '';
    /**
     * Represents the value associated with the radio button.
     *
     * @vegaVersion 1.0.7
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.value = '';
    /**
     * Specifies all the properties of the `vega-flex` component
     *    in the radio group.
     *
     * @vegaVersion 1.3.0
     */
    this.vegaFlexProp = {};
    /**
     * Specifies whether the radio button within the radio group
     *    must be checked to pass form validation.
     *
     * @vegaVersion 1.3.0
     */
    this.required = false;
    /**
     * Provides a supplementary prompt message that assists users
     *    in selecting the appropriate value for the radio group.
     *
     * @vegaVersion 1.3.0
     */
    this.hint = '';
    /**
     * Sets the validation status for the radio group.
     *
     * @vegaVersion 1.3.0
     */
    /* eslint-disable-next-line @stencil/strict-mutable */
    this.isValid = null;
    /**
     * Determines whether the radio group is disabled.
     *
     * @vegaVersion 1.8.0
     */
    this.disabled = false;
    /**
     * Determines whether automatic validation should be implemented for
     *    the radio group upon selection.
     *
     * @vegaVersion 2.6.0
     */
    this.autoValidation = true;
    /**
     * Defines custom validation rules for the radio group.
     *
     * @vegaVersion 2.6.0
     */
    this.validationRules = [];
    /**
     * Update radio group value when child radio is changed.
     */
    this.childRadioValueChange = (payload) => {
      if (payload.detail) {
        this.valueController.setValue(payload.host.value);
      }
    };
  }
  async watchValue(newValue) {
  }
  watchName() {
  }
  watchVegaFlexProp() {
    this.setVegaFlexProperty();
  }
  async watchDisabled() {
    this.notifyGroupDisabledChange();
  }
  watchValidationRules() {
  }
  componentWillLoad() {
  }
  componentDidLoad() {
    this.setVegaFlexProperty();
    if (this.disabled) {
      this.notifyGroupDisabledChange();
    }
  }
  render() {
    return sanitizeVegaComponent(h(Host, { role: "radiogroup" }, this.renderLabelDom(), h("div", { class: "vega-radio-container", ref: (e) => (this.inputContainerRef = e) }, h("vega-flex", { ref: (el) => {
        this.vegaFlexElement = el;
      } }, h("slot", null))), this.renderHintDom()), this.host);
  }
  renderLabelDom() {
    return (this.label && (h("div", { class: "vega-label" }, h("label", { "aria-label": this.label }, this.label, this.renderRequireDom()))));
  }
  renderRequireDom() {
    return this.required ? h("span", { class: "vega-require" }, "*") : null;
  }
  renderHintDom() {
    return (this.hint && (h("div", { class: "vega-hint" }, h("label", null, this.hint))));
  }
  setVegaFlexProperty() {
    if (this.vegaFlexProp) {
      Object.assign(this.vegaFlexElement, {
        gap: 'size-16',
        direction: 'col',
      }, this.vegaFlexProp);
    }
  }
  /**
   * This function notifies a change in the disabled state of a radio group component.
   */
  notifyGroupDisabledChange() {
    ChangeManager.notify(RADIO_GROUP_DISABLED_CHANGE, { host: this.host });
  }
  get host() { return getElement(this); }
  static get watchers() { return {
    "value": ["watchValue"],
    "name": ["watchName"],
    "vegaFlexProp": ["watchVegaFlexProp"],
    "disabled": ["watchDisabled"],
    "validationRules": ["watchValidationRules"]
  }; }
};
__decorate([
  InjectVegaGlobalSlimmer()
], VegaRadioGroup.prototype, "globalSlimmers", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRadioGroup.prototype, "formFieldController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRadioGroup.prototype, "radioValueChangeObserver", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRadioGroup.prototype, "radioEventPrevent", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRadioGroup.prototype, "slotMutationObserver", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRadioGroup.prototype, "changeEventEmitter", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRadioGroup.prototype, "keyboardController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRadioGroup.prototype, "radioItemsController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRadioGroup.prototype, "valueController", void 0);
__decorate([
  InjectVegaSlimmer()
], VegaRadioGroup.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
__decorate([
  ComponentLoadRequired()
], VegaRadioGroup.prototype, "watchVegaFlexProp", null);
VegaRadioGroup.style = vegaRadioGroupCss;

export { VegaRadio as vega_radio, VegaRadioGroup as vega_radio_group };
