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

import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { IconAlertTriangle, IconCircleCheck, IconExclamationCircle, IconInfoCircle, IconX, } from '@tabler/icons-react';
import { useMemo } from 'react';
import { useEvent } from '../../../_internal/hooks/use-event.js';
import { tasty } from '../../../tasty/index.js';
import { Item } from '../../content/Item/Item.js';
import { Link } from '../Link/Link.js';
const DEFAULT_ICONS = {
    danger: _jsx(IconExclamationCircle, {}),
    warning: _jsx(IconAlertTriangle, {}),
    note: _jsx(IconInfoCircle, {}),
    success: _jsx(IconCircleCheck, {}),
};
const BannerElement = tasty(Item, {
    styles: {
        width: '100%',
        Description: {
            textOverflow: 'ellipsis / 2',
            whiteSpace: 'normal',
        },
        Actions: {
            gap: '1x',
        },
    },
});
const BannerActionElement = tasty(Item.Action, {
    type: 'outline',
    styles: {
        preset: 't3m',
        border: '#clear',
    },
});
const BannerLinkElement = tasty(Link, {
    styles: {
        color: '#white',
        textDecoration: 'underline',
    },
});
/**
 * Sub-component for action buttons within a Banner.
 * Automatically styled to match the banner's theme.
 */
export function BannerAction(props) {
    return _jsx(BannerActionElement, { ...props });
}
/**
 * Sub-component for inline links within Banner content.
 * Styled with white color and underline to stand out against the banner background.
 */
export function BannerLink(props) {
    return _jsx(BannerLinkElement, { ...props });
}
/**
 * Banner displays prominent messages and notifications to users.
 * Supports different themes (danger, warning, note, success) with appropriate icons.
 * Use Banner.Action for action buttons and Banner.Link for inline links.
 */
export function Banner(props) {
    const { theme = 'note', actions, isDismissible = false, onDismiss, children, icon, ...rest } = props;
    const onDismissEvent = useEvent(() => {
        onDismiss?.();
    });
    const defaultIcon = useMemo(() => DEFAULT_ICONS[theme], [theme]);
    const hasActions = !!(actions || isDismissible);
    return (_jsx(BannerElement, { qa: "Banner", role: "status", type: "primary", theme: theme, size: "large", icon: icon ?? defaultIcon, ...rest, actions: hasActions ? (_jsxs(_Fragment, { children: [actions, isDismissible && (_jsx(Item.Action, { icon: _jsx(IconX, {}), tooltip: "Hide banner", onPress: onDismissEvent }))] })) : undefined, children: children }));
}
Banner.Action = BannerAction;
Banner.Link = BannerLink;

        