import templateOnly from '@ember/component/template-only';
import { setComponentTemplate } from '@ember/component';
import { precompileTemplate } from '@ember/template-compilation';
import { on } from '@ember/modifier';
import optional from 'ember-composable-helpers/helpers/optional';
import { element } from 'ember-element-helper';
import { and, eq, 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 typeOf from '../helpers/type-of.js';
import EuiLink from './eui-link.js';
import EuiNotificationEventMessages from './eui-notification-event-messages.js';
import EuiNotificationEvent$1 from './eui-notification-event-meta.js';
import EuiNotificationEventReadButton from './eui-notification-event-read-button.js';
import EuiNotificationEventReadIcon from './eui-notification-event-read-icon.js';
import TextBlock from './text-block.js';

const EuiNotificationEvent = setComponentTemplate(precompileTemplate(`
    {{#let
      (randomId)
      (element (argOrDefault @tagName "article"))
      (and (argOrDefault @hasContextMenuBlock true) (has-block "contextMenu"))
      (and
        (argOrDefault @hasPrimaryActionBlock true) (has-block "primaryAction")
      )
      as |id Element hasContextMenuBlock hasPrimaryActionBlock|
    }}
      <Element
        aria-labelledby={{id}}
        key={{@id}}
        class={{classNames
          "euiNotificationEvent"
          (if
            (eq (typeOf @isRead) "boolean")
            "euiNotificationEvent--withReadState"
          )
        }}
        ...attributes
      >

        {{#if (eq (typeOf @isRead) "boolean")}}
          <div class="euiNotificationEvent__readButton">
            {{#if @onRead}}
              <EuiNotificationEventReadButton
                @id={{@id}}
                @isRead={{@isRead}}
                @eventName={{@title}}
                {{on "click" @onRead}}
              />
            {{else}}
              <EuiNotificationEventReadIcon
                @id={{@id}}
                @isRead={{@isRead}}
                @eventName={{@title}}
                @readIconColor={{@readIconColor}}
              />
            {{/if}}
          </div>
        {{/if}}

        <div class="euiNotificationEvent__content">
          <EuiNotificationEventMeta
            @id={{@id}}
            @type={{@type}}
            @severity={{@severity}}
            @badgeColor={{@badgeColor}}
            @iconType={{@iconType}}
            @iconAriaLabel={{@iconAriaLabel}}
            @time={{@time}}
            @onOpenContextMenu={{@onOpenContextMenu}}
            @hasDefaultBlock={{hasContextMenuBlock}}
            @iconColor={{@iconColor}}
          >
            {{yield to="contextMenu"}}
          </EuiNotificationEventMeta>

          {{#let
            (classNames
              "euiNotificationEvent__title"
              (if @isRead "euiNotificationEvent__title--isRead")
            )
            (argOrDefault @headingLevel "h2")
            as |classNames headingLevel|
          }}
            {{#if (or @href @onClickTitle)}}
              <EuiLink
                class={{classNames}}
                id={{id}}
                @href={{@href}}
                {{on "click" (optional @onClickTitle)}}
              >
                <TextBlock @tagName={{headingLevel}}>
                  {{@title}}
                </TextBlock>
              </EuiLink>
            {{else if @title}}
              <TextBlock
                id={{id}}
                class={{classNames}}
                @tagName={{headingLevel}}
              >
                {{@title}}
              </TextBlock>
            {{/if}}
          {{/let}}

          <EuiNotificationEventMessages
            @messages={{@messages}}
            @accordionButtonText={{@accordionButtonText}}
            @accordionHideText={{@accordionHideText}}
          />

          {{#if hasPrimaryActionBlock}}
            <div class="euiNotificationEvent__primaryAction">
              {{yield to="primaryAction"}}
            </div>
          {{/if}}

        </div>

      </Element>
    {{/let}}
  `, {
  strictMode: true,
  scope: () => ({
    randomId,
    element,
    argOrDefault,
    and,
    classNames,
    eq,
    typeOf,
    EuiNotificationEventReadButton,
    on,
    EuiNotificationEventReadIcon,
    EuiNotificationEventMeta: EuiNotificationEvent$1,
    or,
    EuiLink,
    optional,
    TextBlock,
    EuiNotificationEventMessages
  })
}), templateOnly("eui-notification-event", "EuiNotificationEvent"));

export { EuiNotificationEvent as default };
//# sourceMappingURL=eui-notification-event.js.map
