'use strict';

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

const index = require('./index-58ea899e.js');
const accessibility = require('./accessibility-a5ef2038.js');
const component = require('./component-1e352960.js');
const changeManager = require('./change-manager-a297e4d2.js');
const staticSubjectTitle = require('./static-subject-title-5829a298.js');
const observer = require('./observer-f49483e8.js');
const ui = require('./ui-3727d685.js');
const globalSlimmerRegistry = require('./global-slimmer-registry-b3bce7e0.js');
const componentUsageRuntimeMetrics = require('./component-usage-runtime-metrics-4572c5b7.js');
const eventEmitSlimmer = require('./event-emit-slimmer-8ba00d00.js');
const vegaEventId = require('./vega-event-id-d9994eb3.js');
const vegaInternalEventId = require('./vega-internal-event-id-87014e4f.js');
const domNodeSubjectObserverFactory = require('./dom-node-subject-observer-factory-ba6a95f3.js');
const requiredFieldRule = require('./required-field-rule-d73c1d8c.js');
const componentLoadRequired = require('./component-load-required-6cc74719.js');
const formFieldControllerSlimmer = require('./form-field-controller-slimmer-595f4138.js');
const childNodesNotifyObserverSlimmer = require('./child-nodes-notify-observer-slimmer-34a606b3.js');
const childNodesEventPreventSlimmer = require('./child-nodes-event-prevent-slimmer-f3979a03.js');
const keyboardManagerSlimmer = require('./keyboard-manager-slimmer-3824781d.js');
const mutationObserverSlimmer = require('./mutation-observer-slimmer-749d5020.js');
const mutationObserverFilters = require('./mutation-observer-filters-38cebc6d.js');
require('./dynamic-slimmer-f31fdfd7.js');
require('./internal-vega-event-manager-7e0d966d.js');
require('./try-get-document-c0ebd39a.js');
require('./internal-form-field-validation-rule.abstract-07cdff46.js');
require('./string-39438062.js');
require('./misc-3d30df91.js');
require('./internal-translation-controller-8360a89c.js');
require('./index-592b4052.js');
require('./page-resize-observer-slimmer-273d62ef.js');
require('./breakpoints-1cc2c4c6.js');
require('./ui-32120990.js');
require('./breakpoints-ebde4837.js');
require('./array-249289f2.js');
require('./number-4816603d.js');
require('./sub-state-observer-slimmer-ec5ac913.js');
require('./vega-env-manager-23b8b23c.js');
require('./feature-flag-controller-9129ef52.js');
require('./index-f054eb5d.js');
require('./keyboard-manager-d3cc662c.js');
require('./type-guard-2e97fc56.js');
require('./typography-4560e7f1.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 globalSlimmerRegistry.VegaSlimmer {
  /**
   * Component lifecycle - [connectedCallback]{@link VegaRadio.connectedCallback}
   */
  connectedCallback() {
    this.radioGroup =
      ui.findParent(this.host, 'vega-radio-group') || ui.findParent(this.host, 'vega-selection-tile-group');
    if (this.radioGroup) {
      this.fieldErrorObserver = new observer.Observer(this.canAcceptFieldErrorObserver.bind(this), this.fieldErrorObserverListener.bind(this));
      changeManager.ChangeManager.register(domNodeSubjectObserverFactory.domNodeSubjectFactory.getSubject(this.radioGroup, vegaInternalEventId.VegaInternalFieldErrorStateChange), this.fieldErrorObserver);
    }
  }
  /**
   * Component lifecycle - [disconnectedCallback]{@link VegaRadio.disconnectedCallback}
   */
  disconnectedCallback() {
    if (this.radioGroup) {
      changeManager.ChangeManager.unregister(domNodeSubjectObserverFactory.domNodeSubjectFactory.getSubject(this.radioGroup, vegaInternalEventId.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([
  globalSlimmerRegistry.MapToComponentField({ writable: true })
], VegaRadioShowErrorController.prototype, "showError", void 0);
__decorate$5([
  globalSlimmerRegistry.MapToComponentField()
], VegaRadioShowErrorController.prototype, "host", void 0);
__decorate$5([
  globalSlimmerRegistry.MapToComponentMethod('connectedCallback')
], VegaRadioShowErrorController.prototype, "connectedCallback", null);
__decorate$5([
  globalSlimmerRegistry.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) {
    index.registerInstance(this, hostRef);
    this.vegaFocus = index.createEvent(this, "vegaFocus", 7);
    this.focus = index.createEvent(this, "focus", 7);
    this.vegaBlur = index.createEvent(this, "vegaBlur", 7);
    this.blur = index.createEvent(this, "blur", 7);
    this.vegaChange = index.createEvent(this, "vegaChange", 7);
    this.change = index.createEvent(this, "change", 7);
    this.globalSlimmers = {};
    this.changeEventEmitter = eventEmitSlimmer.createEventEmitSlimmer(VegaRadio, vegaEventId.VegaChange);
    this.focusEventEmitter = eventEmitSlimmer.createEventEmitSlimmer(VegaRadio, vegaEventId.VegaFocus);
    this.blurEventEmitter = eventEmitSlimmer.createEventEmitSlimmer(VegaRadio, vegaEventId.VegaBlur);
    this.vegaRadioShowErrorController = new VegaRadioShowErrorController();
    this.vegaComponentUsageRuntimeMetricsSlimmer = new componentUsageRuntimeMetrics.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.ChangeManager.notify(staticSubjectTitle.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 component.sanitizeVegaComponent(index.h(index.Host, { class: {
        'vega-flex-shrink-0 v-min-w-min': isInsideRadioGroup,
      } }, index.h("label", { class: {
        'vega-radio-container': true,
        [this.size]: true,
        'vega-radio-checked': this.checked,
        'vega-radio-disabled': this.isDisabled(),
        'error': this.showError,
      } }, index.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: accessibility.createEnterKeyHandlerToTriggerClick() }), index.h("span", { class: "vega-radio-icon" }, index.h("span", { class: "vega-radio-circle" })), index.h("div", { class: "vega-radio-label", ref: (ref) => (this.labelElement = ref) }, index.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 ui.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 (ui.findParent(this.host, 'vega-radio-group')) {
      this.groupDisabledObserver = new observer.Observer(this.canAcceptGroupDisabledObserver.bind(this), this.groupDisabledObserverListener.bind(this));
      changeManager.ChangeManager.register(staticSubjectTitle.RADIO_GROUP_DISABLED_CHANGE, this.groupDisabledObserver);
    }
  }
  /**
   * This function unregister a group disabled observer if it exists.
   */
  unRegisterGroupDisabledObserver() {
    if (this.groupDisabledObserver) {
      changeManager.ChangeManager.unregister(staticSubjectTitle.RADIO_GROUP_DISABLED_CHANGE, this.groupDisabledObserver);
    }
  }
  get host() { return index.getElement(this); }
  static get watchers() { return {
    "checked": ["watchCheckedChange"]
  }; }
};
__decorate$4([
  componentUsageRuntimeMetrics.InjectVegaGlobalSlimmer()
], VegaRadio.prototype, "globalSlimmers", void 0);
__decorate$4([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaRadio.prototype, "changeEventEmitter", void 0);
__decorate$4([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaRadio.prototype, "focusEventEmitter", void 0);
__decorate$4([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaRadio.prototype, "blurEventEmitter", void 0);
__decorate$4([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaRadio.prototype, "vegaRadioShowErrorController", void 0);
__decorate$4([
  globalSlimmerRegistry.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.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([
  globalSlimmerRegistry.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 globalSlimmerRegistry.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.ChangeManager.notify(staticSubjectTitle.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([
  globalSlimmerRegistry.MapToComponentField()
], VegaRadioGroupValueController.prototype, "host", void 0);
__decorate$2([
  globalSlimmerRegistry.MapToComponentField({ writable: true })
], VegaRadioGroupValueController.prototype, "value", void 0);
__decorate$2([
  globalSlimmerRegistry.MapToComponentField()
], VegaRadioGroupValueController.prototype, "changeEventEmitter", void 0);
__decorate$2([
  globalSlimmerRegistry.MapToComponentField()
], VegaRadioGroupValueController.prototype, "radioItemsController", void 0);
__decorate$2([
  globalSlimmerRegistry.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 globalSlimmerRegistry.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([
  globalSlimmerRegistry.MapToComponentField()
], VegaRadioGroupRadioItemsController.prototype, "host", void 0);
__decorate$1([
  globalSlimmerRegistry.MapToComponentField()
], VegaRadioGroupRadioItemsController.prototype, "value", void 0);
__decorate$1([
  globalSlimmerRegistry.MapToComponentField()
], VegaRadioGroupRadioItemsController.prototype, "name", void 0);
__decorate$1([
  globalSlimmerRegistry.MapToComponentField()
], VegaRadioGroupRadioItemsController.prototype, "valueController", void 0);
__decorate$1([
  globalSlimmerRegistry.MapToComponentMethod('componentWillLoad')
], VegaRadioGroupRadioItemsController.prototype, "componentWillLoad", null);
__decorate$1([
  globalSlimmerRegistry.MapToComponentMethod('watchName')
], VegaRadioGroupRadioItemsController.prototype, "setRadioItemName", null);
__decorate$1([
  globalSlimmerRegistry.MapToComponentMethod('watchValue')
], VegaRadioGroupRadioItemsController.prototype, "setRadioItemCheckedByValue", null);
__decorate$1([
  globalSlimmerRegistry.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) {
    index.registerInstance(this, hostRef);
    this.vegaChange = index.createEvent(this, "vegaChange", 7);
    this.change = index.createEvent(this, "change", 7);
    this.globalSlimmers = {};
    this.formFieldController = new formFieldControllerSlimmer.FormFieldControllerSlimmer({
      propertyRules: [
        {
          propertyName: 'required',
          ruleFactory: (isRequired) => (isRequired ? new requiredFieldRule.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.ChildNodesNotifyObserverSlimmer(staticSubjectTitle.RADIO_VALUE_CHANGE, (payload) => this.childRadioValueChange(payload));
    this.radioEventPrevent = new childNodesEventPreventSlimmer.ChildNodesEventPreventSlimmer([vegaEventId.VegaChange], () => this.vegaFlexElement);
    this.slotMutationObserver = new mutationObserverSlimmer.MutationObserverSlimmer({
      options: { childList: true },
      mutationFilter: mutationObserverFilters.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 = eventEmitSlimmer.createEventEmitSlimmer(VegaRadioGroup, vegaEventId.VegaChange);
    this.keyboardController = new VegaRadioGroupKeyboardController();
    this.radioItemsController = new VegaRadioGroupRadioItemsController();
    this.valueController = new VegaRadioGroupValueController();
    this.vegaComponentUsageRuntimeMetricsSlimmer = new componentUsageRuntimeMetrics.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 component.sanitizeVegaComponent(index.h(index.Host, { role: "radiogroup" }, this.renderLabelDom(), index.h("div", { class: "vega-radio-container", ref: (e) => (this.inputContainerRef = e) }, index.h("vega-flex", { ref: (el) => {
        this.vegaFlexElement = el;
      } }, index.h("slot", null))), this.renderHintDom()), this.host);
  }
  renderLabelDom() {
    return (this.label && (index.h("div", { class: "vega-label" }, index.h("label", { "aria-label": this.label }, this.label, this.renderRequireDom()))));
  }
  renderRequireDom() {
    return this.required ? index.h("span", { class: "vega-require" }, "*") : null;
  }
  renderHintDom() {
    return (this.hint && (index.h("div", { class: "vega-hint" }, index.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.ChangeManager.notify(staticSubjectTitle.RADIO_GROUP_DISABLED_CHANGE, { host: this.host });
  }
  get host() { return index.getElement(this); }
  static get watchers() { return {
    "value": ["watchValue"],
    "name": ["watchName"],
    "vegaFlexProp": ["watchVegaFlexProp"],
    "disabled": ["watchDisabled"],
    "validationRules": ["watchValidationRules"]
  }; }
};
__decorate([
  componentUsageRuntimeMetrics.InjectVegaGlobalSlimmer()
], VegaRadioGroup.prototype, "globalSlimmers", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaRadioGroup.prototype, "formFieldController", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaRadioGroup.prototype, "radioValueChangeObserver", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaRadioGroup.prototype, "radioEventPrevent", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaRadioGroup.prototype, "slotMutationObserver", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaRadioGroup.prototype, "changeEventEmitter", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaRadioGroup.prototype, "keyboardController", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaRadioGroup.prototype, "radioItemsController", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaRadioGroup.prototype, "valueController", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaRadioGroup.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
__decorate([
  componentLoadRequired.ComponentLoadRequired()
], VegaRadioGroup.prototype, "watchVegaFlexProp", null);
VegaRadioGroup.style = vegaRadioGroupCss;

exports.vega_radio = VegaRadio;
exports.vega_radio_group = VegaRadioGroup;
