'use strict';

var React = require('react');
var neptuneTokens = require('@transferwise/neptune-tokens');
var clsx = require('clsx');
var Body = require('../../body/Body.js');
var Button_resolver = require('../../button/Button.resolver.js');
require('../../common/theme.js');
require('../../common/direction.js');
require('../../common/propsValues/control.js');
require('../../common/propsValues/size.js');
var typography = require('../../common/propsValues/typography.js');
require('../../common/propsValues/width.js');
require('../../common/propsValues/type.js');
require('../../common/propsValues/dateMode.js');
require('../../common/propsValues/monthFormat.js');
require('../../common/propsValues/position.js');
require('../../common/propsValues/layouts.js');
require('../../common/propsValues/status.js');
require('../../common/propsValues/sentiment.js');
require('../../common/propsValues/profileType.js');
require('../../common/propsValues/variant.js');
require('../../common/propsValues/scroll.js');
require('../../common/propsValues/markdownNodeType.js');
require('../../common/fileType.js');
require('@transferwise/formatting');
require('@transferwise/icons');
require('react-intl');
require('../../common/closeButton/CloseButton.messages.js');
var jsxRuntime = require('react/jsx-runtime');
var PrimitivePrompt = require('../PrimitivePrompt/PrimitivePrompt.js');
var useScreenSize = require('../../common/hooks/useScreenSize.js');
var promptMedia = require('../helpers/promptMedia.js');

const ActionPrompt = ({
  sentiment = 'neutral',
  title,
  description,
  onDismiss,
  media = {},
  action,
  actionSecondary,
  id,
  className,
  'data-testid': testId,
  'aria-label': ariaLabel
}) => {
  const isMobile = !useScreenSize.useScreenSize(neptuneTokens.Breakpoint.SMALL);
  const mediaId = React.useId();
  const titleId = React.useId();
  const descId = React.useId();
  const ariaLabelledByIds = [media['aria-hidden'] ? undefined : mediaId, ariaLabel ? undefined : titleId].filter(Boolean).join(' ');
  const renderMedia = () => promptMedia.renderPromptMedia({
    media,
    sentiment,
    mediaId,
    imgClassName: 'wds-action-prompt--media-image'
  });
  return /*#__PURE__*/jsxRuntime.jsx(PrimitivePrompt.PrimitivePrompt, {
    id: id,
    sentiment: sentiment,
    "data-testid": testId,
    className: clsx.clsx('wds-action-prompt', {
      'wds-action-prompt--with-two-actions': !!actionSecondary
    }, className),
    media: renderMedia(),
    actions: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
      children: [actionSecondary &&
      /*#__PURE__*/
      // @ts-expect-error onClick type mismatch
      jsxRuntime.jsx(Button_resolver.default, {
        v2: true,
        size: "md",
        priority: "secondary",
        href: actionSecondary.href,
        block: isMobile,
        onClick: actionSecondary?.onClick,
        children: actionSecondary.label
      }), /*#__PURE__*/jsxRuntime.jsx(Button_resolver.default, {
        v2: true,
        size: "md",
        priority: "primary",
        href: action.href,
        block: isMobile,
        onClick: action.onClick,
        children: action.label
      })]
    }),
    role: "region",
    onDismiss: onDismiss,
    ...(ariaLabel ? {
      'aria-label': ariaLabel
    } : {
      'aria-labelledby': ariaLabelledByIds,
      'aria-describedby': descId
    }),
    children: /*#__PURE__*/jsxRuntime.jsxs("div", {
      className: clsx.clsx('d-flex', 'flex-column', 'justify-content-center'),
      children: [/*#__PURE__*/jsxRuntime.jsx(Body.default, {
        id: titleId,
        type: typography.Typography.BODY_LARGE_BOLD,
        className: "wds-action-prompt__content",
        children: title
      }), description && /*#__PURE__*/jsxRuntime.jsx(Body.default, {
        id: descId,
        className: "wds-action-prompt__content",
        children: description
      })]
    })
  });
};

exports.ActionPrompt = ActionPrompt;
//# sourceMappingURL=ActionPrompt.js.map
