import templateOnly from '@ember/component/template-only';
import { setComponentTemplate } from '@ember/component';
import { precompileTemplate } from '@ember/template-compilation';
import didInsert from '@ember/render-modifiers/modifiers/did-insert';
import optional from 'ember-composable-helpers/helpers/optional';
import { and, or } from 'ember-truth-helpers';
import randomId from '../-private/random-id.js';
import argOrDefault from '../helpers/arg-or-default.js';
import classNames from '../helpers/class-names.js';
import validatableControl from '../modifiers/validatable-control.js';
import EuiFormControlLayout from './eui-form-control-layout.js';

const EuiFieldNumber = setComponentTemplate(precompileTemplate(`
    {{#let
      (and (argOrDefault @isPrependProvided true) (has-block "prepend"))
      (and (argOrDefault @isAppendProvided true) (has-block "append"))
      (argOrDefault @id (randomId))
      as |hasPrepend hasAppend inputId|
    }}
      {{#let
        (classNames
          (if @icon "euiFieldNumber--withIcon")
          (if @fullWidth "euiFieldNumber--fullWidth")
          (if @compressed "euiFieldNumber--compressed")
          (if (or hasPrepend hasAppend) "euiFieldNumber--inGroup")
          (if @isLoading "euiFieldNumber--isLoading")
          "euiFieldNumber"
        )
        as |classes|
      }}
        {{#if @controlOnly}}
          <input
            id={{@id}}
            class={{classes}}
            value={{@value}}
            min={{@min}}
            max={{@max}}
            disabled={{@disabled}}
            step={{@step}}
            type="number"
            {{validatableControl @isInvalid}}
            {{didInsert (optional @inputRef)}}
            ...attributes
          />
        {{else}}
          <EuiFormControlLayout
            @icon={{@icon}}
            @clear={{@clear}}
            @fullWidth={{@fullWidth}}
            @isLoading={{@isLoading}}
            @compressed={{@compressed}}
            @readOnly={{@readOnly}}
            @disabled={{@disabled}}
            @useGroup={{or hasPrepend hasAppend}}
          >
            <:prepend as |prependClasses|>
              {{yield prependClasses to="prepend"}}
            </:prepend>
            <:field>
              <input
                id={{inputId}}
                class={{classes}}
                value={{@value}}
                min={{@min}}
                max={{@max}}
                disabled={{@disabled}}
                step={{@step}}
                type="number"
                {{validatableControl @isInvalid}}
                ...attributes
              />
            </:field>
            <:append as |appendClasses|>
              {{yield appendClasses to="append"}}
            </:append>
          </EuiFormControlLayout>
        {{/if}}
      {{/let}}
    {{/let}}
  `, {
  strictMode: true,
  scope: () => ({
    and,
    argOrDefault,
    randomId,
    classNames,
    or,
    validatableControl,
    didInsert,
    optional,
    EuiFormControlLayout
  })
}), templateOnly("eui-field-number", "EuiFieldNumber"));

export { EuiFieldNumber as default };
//# sourceMappingURL=eui-field-number.js.map
