'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var React = require('react');
var styles = require('./styles.js');
var index = require('../../../utils/index.js');
var index$1 = require('../../Button/index.js');
var utils = require('./utils.js');
var ToastIcon = require('./ToastIcon.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

const genericAction = {
    text: '',
    onClick: index.noop,
};
function Toast(props) {
    const appendTestId = index.getId(props['data-testid']);
    const appendTrackId = index.getId(props['data-trackid']);
    const { className, variant = 'neutral', message, action, primaryAction = genericAction, icon, } = props;
    let dismissAction = genericAction;
    if (props.action === 'acknowledge') {
        dismissAction = props.dismissAction;
    }
    return (React__default['default'].createElement(styles.ToastWrapper, { className: className, variant: variant, "data-testid": appendTestId('wrapper'), "data-trackid": appendTrackId('wrapper'), "aria-label": props['aria-label'], role: utils.getAriaRole(variant) },
        React__default['default'].createElement(styles.CompactWrapper, null,
            variant === 'neutral' && icon ? icon : React__default['default'].createElement(ToastIcon['default'], { variant: variant }),
            React__default['default'].createElement(styles.MessageWrapper, null, message)),
        React__default['default'].createElement(styles.ActionWrapper, null,
            action === 'acknowledge' && dismissAction && (React__default['default'].createElement(index$1.Button, { size: "xSmall", variant: "inverse-ghost", onClick: dismissAction.onClick, "data-testid": appendTestId('dismiss-button') }, dismissAction.text)),
            React__default['default'].createElement(index$1.Button, { size: "xSmall", variant: "inverse-ghost", onClick: primaryAction.onClick, "data-testid": appendTestId('action-button') }, primaryAction.text))));
}

exports.Toast = Toast;
