import templateOnly from '@ember/component/template-only';
import { setComponentTemplate } from '@ember/component';
import { precompileTemplate } from '@ember/template-compilation';
import { concat, get, fn } from '@ember/helper';
import { on } from '@ember/modifier';
import { eq, or } from 'ember-truth-helpers';
import argOrDefault from '../helpers/arg-or-default.js';
import EuiFormFieldset from './eui-form-fieldset.js';
import EuiRadio from './eui-radio.js';

const EuiRadioGroup = setComponentTemplate(precompileTemplate(`
  {{#let
    (argOrDefault @valueKey "id") (argOrDefault @labelKey "label")
    as |valueKey labelKey|
  }}
    {{#if @legend}}
      <EuiFormFieldset @legend={{@legend}} @compressed={{@compressed}}>
        {{#each @options key="id" as |option|}}
          <EuiRadio
            class={{concat "euiRadioGroup__item" option.className}}
            form={{@formId}}
            @checked={{eq @idSelected (get option valueKey)}}
            @disabled={{or @disabled option.disabled}}
            @compressed={{@compressed}}
            {{!@glint-expect-error}}
            @label={{get option labelKey}}
            {{!@glint-expect-error}}
            {{on "change" (fn @onChange (get option valueKey) option.value)}}
          />
        {{/each}}
      </EuiFormFieldset>
    {{else}}
      <div ...attributes>
        {{#each @options key="id" as |option|}}
          <EuiRadio
            class={{concat "euiRadioGroup__item" option.className}}
            form={{@formId}}
            @name={{@name}}
            @checked={{eq @idSelected (get option valueKey)}}
            @disabled={{or @disabled option.disabled}}
            @compressed={{@compressed}}
            {{!@glint-expect-error}}
            @label={{get option labelKey}}
            {{!@glint-expect-error}}
            {{on "change" (fn @onChange (get option valueKey) option.value)}}
          />
        {{/each}}
      </div>
    {{/if}}
  {{/let}}
`, {
  strictMode: true,
  scope: () => ({
    argOrDefault,
    EuiFormFieldset,
    EuiRadio,
    concat,
    eq,
    get,
    or,
    on,
    fn
  })
}), templateOnly("eui-radio-group", "EuiRadioGroup"));

export { EuiRadioGroup as default };
//# sourceMappingURL=eui-radio-group.js.map
