/**
 * @license MIT
 * author: Cube Dev Team
 * @cube-dev/ui-kit v0.0.0-canary-3803e7e
 * Released under the MIT license.
 */

import { jsx as _jsx } from "react/jsx-runtime";
import { useEvent } from '../../../_internal/index.js';
import { tasty } from '../../../tasty/index.js';
import { NotificationCard } from './NotificationCard.js';
// ─── ARIA Helpers ────────────────────────────────────────────────────
function getAriaRole(theme) {
    if (theme === 'danger' || theme === 'warning') {
        return 'alert';
    }
    return 'status';
}
function getAriaLive(theme) {
    if (theme === 'danger' || theme === 'warning') {
        return 'assertive';
    }
    return 'polite';
}
// ─── Styled Wrapper ──────────────────────────────────────────────────
/**
 * Wrapper element for overlay notification items.
 *
 * Accessibility attributes are set as static defaults:
 * - `tabIndex={0}`: Makes the notification focusable via keyboard, allowing
 *   users to Tab to it and press Escape to dismiss.
 * - `aria-atomic="true"`: Ensures screen readers announce the entire notification
 *   when content changes (not just the diff).
 * - `aria-relevant="additions text"`: Announces when new content is added or
 *   text changes, but not when elements are removed (e.g., during exit animation).
 *
 * The `role` and `aria-live` are set dynamically per-instance based on theme
 * (see `getAriaRole` and `getAriaLive` above).
 */
const NotificationItemWrapper = tasty({
    as: 'div',
    tabIndex: 0,
    'aria-atomic': 'true',
    'aria-relevant': 'additions text',
    styles: {
        outline: {
            '': 'none',
        },
    },
});
export function NotificationItem({ notification, onDismiss, }) {
    const { theme, title, description, icon, actions, isDismissible = true, id, internalId, } = notification;
    const notificationId = id ?? internalId;
    const handleKeyDown = useEvent((e) => {
        if (e.key === 'Escape' && isDismissible) {
            e.stopPropagation();
            onDismiss(notificationId, 'close');
        }
    });
    return (_jsx(NotificationItemWrapper, { role: getAriaRole(theme), "aria-live": getAriaLive(theme), onKeyDown: handleKeyDown, children: _jsx(NotificationCard, { qa: "Notification", theme: theme, title: title, description: description, icon: icon, actions: actions, isDismissible: isDismissible, notificationId: notificationId, onDismiss: onDismiss }) }));
}

        