{{! @glint-nocheck }}
{{!-- template-lint-disable no-invalid-interactive --}}
<div
  class="{{if (macroCondition (macroGetOwnConfig "isNotBS5")) "form-group"}} {{if (macroCondition (macroGetOwnConfig "isBS5")) (if (bs-eq @formLayout "vertical") "mb-3")}} {{if (bs-eq @formLayout "horizontal") (if (macroCondition (macroGetOwnConfig "isBS5")) "row mb-3" "row")}}"
  ...attributes
  {{create-ref "mainNode"}}
  {{on "focusout" this.showValidationOnHandler}}
  {{on "change" this.showValidationOnHandler}}
  {{on "input" this.showValidationOnHandler}}
  {{did-update this.handleShowAllValidationsChange this.showAllValidations}}
>
  {{#component
    (ensure-safe-component
      (bs-default
        @layoutComponent
        (if
          (bs-contains (array "checkbox" "switch") this.controlType)
          (if
            (bs-eq @formLayout "inline")
            (component "bs-form/element/layout/inline/checkbox" controlType=this.controlType)
            (if
              (bs-eq @formLayout "horizontal")
              (component "bs-form/element/layout/horizontal/checkbox" controlType=this.controlType)
              (component "bs-form/element/layout/vertical/checkbox" controlType=this.controlType)
            )
          )
          (if
            (bs-eq @formLayout "inline")
            (component "bs-form/element/layout/inline")
            (if
              (bs-eq @formLayout "horizontal")
              (component "bs-form/element/layout/horizontal")
              (component "bs-form/element/layout/vertical")
            )
          )
        )
      )
    )
    hasLabel=(if @label true false)
    formElementId=this.formElementId
    horizontalLabelGridClass=@horizontalLabelGridClass
    errorsComponent=(component (ensure-safe-component (bs-default @errorsComponent (component "bs-form/element/errors")))
      messages=this.validationMessages
      show=this.showValidationMessages
      showMultipleErrors=this.showMultipleErrors
    )
    feedbackIconComponent=(component (ensure-safe-component (bs-default @feedbackIconComponent (component "bs-form/element/feedback-icon")))
      iconName=@iconName
      show=this.hasFeedback
    )
    labelComponent=(component
      (ensure-safe-component
        (bs-default
          @labelComponent
          (if
            (bs-eq this.controlType "radio")
            (component "bs-form/element/legend")
            (component "bs-form/element/label")
          )
        )
      )
      label=@label
      invisibleLabel=@invisibleLabel
      formElementId=this.formElementId
      controlType=this.controlType
      formLayout=@formLayout
      size=@size
    )
    helpTextComponent=(if @helpText
      (component (ensure-safe-component (bs-default @helpTextComponent (component "bs-form/element/help-text")))
        text=@helpText
        id=this.ariaDescribedBy
      )
    )
  }}
    {{!
      Ember does not allow to access a variable with `@` in template if its name start with an underscore.
      `@_disabled` and `@_readonly` are affected by this. As a work-a-round we access them on `this.args`.
    }}
    {{!-- template-lint-disable no-args-paths --}}
    {{#let
      (component
        (ensure-safe-component
          (bs-default
            @controlComponent
            this.controlComponent
          )
        )
        value=this.value
        id=this.formElementId
        type=this.controlType
        label=@label
        disabled=this.args._disabled
        readonly=this.args._readonly
        required=@required
        options=@options
        optionLabelPath=@optionLabelPath
        ariaDescribedBy=(if @helpText this.ariaDescribedBy)
        onChange=this.doChange
        validationType=this.validation
        size=@size
    ) as |Control|}}
    {{!-- template-lint-enable no-args-paths --}}
      {{#if (has-block)}}
        {{yield
          (hash
            value=this.value
            setValue=this.doChange
            id=this.formElementId
            validation=this.validation
            control=Control
          )
        }}
      {{else}}
        <Control />
      {{/if}}
    {{/let}}
  {{/component}}
</div>
