import templateOnly from '@ember/component/template-only';
import { setComponentTemplate } from '@ember/component';
import { precompileTemplate } from '@ember/template-compilation';
import { and, not, or } from 'ember-truth-helpers';
import argOrDefault from '../helpers/arg-or-default.js';
import classNames from '../helpers/class-names.js';
import GetEuiConfig from '../helpers/get-eui-config.js';
import EuiIcon from './eui-icon.js';

const EuiButtonIcon = setComponentTemplate(precompileTemplate(`
  {{#let (getEuiConfig "euiButtonIcon.size") as |buttonSizeConfig|}}
    {{#if (and @href (not @isDisabled))}}
      <a
        class={{classNames
          (if @isDisabled "euiButtonIcon-isDisabled")
          componentName="EuiButtonIcon"
          display=(argOrDefault @display "empty")
          color=(argOrDefault @color "primary")
          size=(argOrDefault @size (if buttonSizeConfig buttonSizeConfig "xs"))
        }}
        href={{@href}}
        target={{@target}}
        ...attributes
      >
        {{#if @iconType}}
          <EuiIcon
            @iconClasses="euiButtonIcon__icon {{@iconClasses}}"
            @type={{@iconType}}
            @size={{argOrDefault @iconSize "m"}}
            @useSvg={{@useSvg}}
            @useComponent={{@useComponent}}
            @color="inherit"
            aria-hidden="true"
          />
        {{/if}}
      </a>
    {{else}}
      <button
        class={{classNames
          (if @isDisabled "euiButtonIcon-isDisabled")
          componentName="EuiButtonIcon"
          display=(argOrDefault @display "empty")
          color=(argOrDefault @color "primary")
          size=(argOrDefault @size (if buttonSizeConfig buttonSizeConfig "xs"))
        }}
        disabled={{or @isDisabled @disabled}}
        aria-pressed={{if @isSelected "true" "false"}}
        type={{if @type @type "button"}}
        ...attributes
      >
        {{#if @iconType}}
          <EuiIcon
            @iconClasses="euiButtonIcon__icon {{@iconClasses}}"
            @type={{@iconType}}
            @size={{argOrDefault @iconSize "m"}}
            @useSvg={{@useSvg}}
            @color="inherit"
            @useComponent={{@useComponent}}
            aria-hidden="true"
          />
        {{/if}}
      </button>
    {{/if}}
  {{/let}}
`, {
  strictMode: true,
  scope: () => ({
    getEuiConfig: GetEuiConfig,
    and,
    not,
    classNames,
    argOrDefault,
    EuiIcon,
    or
  })
}), templateOnly("eui-button-icon", "EuiButtonIcon"));

export { EuiButtonIcon as default };
//# sourceMappingURL=eui-button-icon.js.map
