/**
 * Notifications Actions
 */
import { Fragment, useMemo } from 'react';
import PropTypes from 'prop-types';
import Box from '@mui/material/Box';
import Link from '@mui/material/Link';
import Divider from '@mui/material/Divider';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
function NotificationActions({
  notification
}) {
  const notificationActions = useMemo(() => {
    const {
      actions,
      action
    } = notification;
    let actionList = actions ?? [];
    if (!actionList.length && action) {
      actionList = [{
        name: 'Visit',
        link: action
      }];
    }
    return actionList;
  }, [notification]);
  if (!notificationActions.length) {
    return null;
  }
  return /*#__PURE__*/_jsx(Box, {
    sx: {
      display: 'flex',
      justifyContent: 'start',
      flexWrap: 'wrap',
      alignItems: 'center',
      gap: 1
    },
    children: notificationActions.map((action, index) => /*#__PURE__*/_jsxs(Fragment, {
      children: [/*#__PURE__*/_jsx(Link, {
        href: action.link,
        target: "_blank",
        className: "link",
        rel: "noopener noreferrer",
        sx: {
          fontSize: '15px'
        },
        onClick: e => {
          // 设置自定义标记并阻止冒泡，防止父组件重复打开链接
          e.customPreventRedirect = true;
          // 不阻止默认行为，让链接正常打开
        },
        children: action.name
      }, action.link), index < notificationActions.length - 1 ? /*#__PURE__*/_jsx(Divider, {
        orientation: "vertical",
        sx: {
          height: 12,
          borderWidth: '1px'
        }
      }) : null]
    }, action.link))
  });
}
NotificationActions.propTypes = {
  notification: PropTypes.object.isRequired
};
export default NotificationActions;