import { _ as _applyDecoratedDescriptor, a as _initializerDefineProperty } from '../_rollupPluginBabelHelpers-9wjJaosZ.js';
import { setComponentTemplate } from '@ember/component';
import { precompileTemplate } from '@ember/template-compilation';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { concat } from '@ember/helper';
import { action } from '@ember/object';
import didInsert from '@ember/render-modifiers/modifiers/did-insert';
import { and, not } from 'ember-truth-helpers';
import argOrDefault from '../helpers/arg-or-default.js';
import classNames from '../helpers/class-names.js';
import EuiIcon from './eui-icon.js';
import EuiLoadingSpinner from './eui-loading-spinner.js';

var _class, _descriptor;
let EuiContextMenuItemComponent = setComponentTemplate(precompileTemplate(`
    {{#let
      (classNames
        "euiContextMenuItem"
        componentName="EuiContextMenuItem"
        disabled=@disabled
        layoutAlign=(argOrDefault @layoutAlign "center")
        size=@size
      )
      as |classes|
    }}
      {{#if (and @href (not @disabled))}}
        <a
          class={{classes}}
          href={{@href}}
          target={{@target}}
          {{didInsert this.registerLink}}
          ...attributes
        />

      {{else}}
        <button
          class={{classes}}
          disabled={{@disabled}}
          type="button"
          {{didInsert this.registerLink}}
          ...attributes
        />
      {{/if}}
    {{/let}}

    {{! shared code that will be rendered inside the button or anchor }}
    {{#if this.link}}
      {{#in-element this.link}}
        <span
          class={{classNames
            "euiContextMenu__itemLayout"
            componentName="EuiContextMenuItem"
            layoutAlign=(argOrDefault @layoutAlign "center")
          }}
        >
          {{#if @isLoading}}
            {{! spinner is not part of eui spec }}
            <EuiLoadingSpinner class="euiContextMenu__icon" />
          {{else}}
            <EuiIcon
              @iconClasses={{concat "euiContextMenu__icon " @iconClasses}}
              @type={{@icon}}
              @size="m"
              @color="inherit"
            />
          {{/if}}
          <span class="euiContextMenuItem__text">
            {{yield}}
          </span>
          {{#if @hasPanel}}
            <EuiIcon
              @type="arrowRight"
              @size="m"
              class="euiContextMenu__arrow"
            />
          {{/if}}
        </span>
      {{/in-element}}
    {{/if}}
  `, {
  strictMode: true,
  scope: () => ({
    classNames,
    argOrDefault,
    and,
    not,
    didInsert,
    EuiLoadingSpinner,
    EuiIcon,
    concat
  })
}), (_class = class EuiContextMenuItemComponent extends Component {
  constructor(...args) {
    super(...args);
    _initializerDefineProperty(this, "link", _descriptor, this);
  }
  registerLink(e) {
    this.link = e;
  }
  willDestroy() {
    super.willDestroy();
    this.link = null;
  }
}, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "link", [tracked], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: function () {
    return null;
  }
}), _applyDecoratedDescriptor(_class.prototype, "registerLink", [action], Object.getOwnPropertyDescriptor(_class.prototype, "registerLink"), _class.prototype)), _class));

export { EuiContextMenuItemComponent as default };
//# sourceMappingURL=eui-context-menu-item.js.map
