import templateOnly from '@ember/component/template-only';
import { setComponentTemplate } from '@ember/component';
import { precompileTemplate } from '@ember/template-compilation';
import { on } from '@ember/modifier';
import { eq, or, and } from 'ember-truth-helpers';
import argOrDefault from '../helpers/arg-or-default.js';
import EuiFormControlLayoutClearButton from './eui-form-control-layout-clear-button.js';
import EuiFormControlLayoutCustomIcon from './eui-form-control-layout-custom-icon.js';
import EuiLoadingSpinner from './eui-loading-spinner.js';

const ICON_SIDES = ['left', 'right'];
const EuiFormControlLayoutIcons = setComponentTemplate(precompileTemplate(`
    {{#let (argOrDefault @iconSide "left") as |iconSide|}}
      {{#if (eq iconSide "left")}}
        <div class="euiFormControlLayoutIcons">
          {{#if @icon}}
            <EuiFormControlLayoutCustomIcon
              @size={{if @compressed "s" "m"}}
              @type={{@icon}}
              ...attributes
            />
          {{/if}}
        </div>
      {{/if}}
      {{#if (or @clear @isLoading (and @icon (eq iconSide "right")))}}
        <div class="euiFormControlLayoutIcons euiFormControlLayoutIcons--right">
          {{#if @clear}}
            <EuiFormControlLayoutClearButton
              @size={{if @compressed "s" "m"}}
              {{on "click" @clear}}
              ...attributes
            />
          {{/if}}
          {{#if @isLoading}}
            <EuiLoadingSpinner @size="m" />
          {{/if}}
          {{#if (eq iconSide "right")}}
            {{#if @icon}}
              <EuiFormControlLayoutCustomIcon
                @size={{if @compressed "s" "m"}}
                @type={{@icon}}
                ...attributes
              />
            {{/if}}
          {{/if}}
        </div>
      {{/if}}
    {{/let}}
  `, {
  strictMode: true,
  scope: () => ({
    argOrDefault,
    eq,
    EuiFormControlLayoutCustomIcon,
    or,
    and,
    EuiFormControlLayoutClearButton,
    on,
    EuiLoadingSpinner
  })
}), templateOnly("eui-form-control-layout-icons", "EuiFormControlLayoutIcons"));

export { ICON_SIDES, EuiFormControlLayoutIcons as default };
//# sourceMappingURL=eui-form-control-layout-icons.js.map
