import { setComponentTemplate } from '@ember/component';
import { precompileTemplate } from '@ember/template-compilation';
import Component from '@glimmer/component';
import { on } from '@ember/modifier';
import optional from 'ember-composable-helpers/helpers/optional';
import argOrDefault from '../helpers/arg-or-default.js';
import classNames from '../helpers/class-names.js';
import EuiButtonEmpty from './eui-button-empty.js';

function euiCardSelectableColor(color, isSelected) {
  let calculatedColor;
  if (color) {
    calculatedColor = color;
  } else if (isSelected) {
    calculatedColor = 'success';
  } else {
    calculatedColor = 'text';
  }
  return calculatedColor;
}
class EuiCardSelectComponent extends Component {
  get selectColorClass() {
    return `euiCardSelect--${euiCardSelectableColor(this.args.color, this.args.isSelected)}`;
  }
}
setComponentTemplate(precompileTemplate(`
    <EuiButtonEmpty
      class={{classNames this.selectColorClass componentName="EuiCardSelect"}}
      id={{@buttonId}}
      @color={{argOrDefault @color "text"}}
      @size="xs"
      @isDisabled={{@isDisabled}}
      @iconType={{if @isSelected "check" undefined}}
      @isLoading={{@isLoading}}
      @href={{@href}}
      @iconSide={{@iconSide}}
      @flush={{@flush}}
      @type={{@type}}
      role="switch"
      aria-checked={{@isSelected}}
      {{on "click" (optional @onClick)}}
      ...attributes
    >
      {{#if (has-block)}}
        {{yield}}
      {{else if @isSelected}}
        Selected
      {{else if @isDisabled}}
        Unavailable
      {{else}}
        Select
      {{/if}}
    </EuiButtonEmpty>
  `, {
  strictMode: true,
  scope: () => ({
    EuiButtonEmpty,
    classNames,
    argOrDefault,
    on,
    optional
  })
}), EuiCardSelectComponent);

export { EuiCardSelectComponent as default, euiCardSelectableColor };
//# sourceMappingURL=eui-card-select.js.map
