import { __rest } from "tslib";
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { styled } from '@mui/material/styles';
import { Avatar, Button, Stack, Typography } from '@mui/material';
import { Link, useSCRouting, SCRoutes } from '@selfcommunity/react-core';
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
import DateTimeAgo from '../../../shared/DateTimeAgo';
import NewChip from '../../../shared/NewChip/NewChip';
import classNames from 'classnames';
import { SCNotificationObjectTemplateType } from '../../../types';
import NotificationItem from '../../../shared/NotificationItem';
import { PREFIX } from '../constants';
const messages = defineMessages({
    incubatorApproved: {
        id: 'ui.notification.incubatorApproved.approved',
        defaultMessage: 'ui.notification.incubatorApproved.approved'
    }
});
const classes = {
    root: `${PREFIX}-incubator-approved-root`,
    categoryIcon: `${PREFIX}-category-icon`,
    categoryApprovedText: `${PREFIX}-category-approved-text`,
    activeAt: `${PREFIX}-active-at`,
    viewIncubatorButton: `${PREFIX}-view-incubator-button`
};
const Root = styled(NotificationItem, {
    name: PREFIX,
    slot: 'IncubatorApprovedRoot'
})(() => ({}));
export default function IncubatorApprovedNotification(props) {
    // PROPS
    const { notificationObject = null, id = `n_${props.notificationObject['feed_serialization_id']}`, template = SCNotificationObjectTemplateType.DETAIL, className } = props, rest = __rest(props, ["notificationObject", "id", "template", "className"]);
    // ROUTING
    const scRoutingContext = useSCRouting();
    // CONST
    const isSnippetTemplate = template === SCNotificationObjectTemplateType.SNIPPET;
    //INTL
    const intl = useIntl();
    /**
     * Renders root object
     */
    return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: _jsx(Avatar, { alt: notificationObject.incubator.approved_category.name, src: notificationObject.incubator.approved_category.image_medium, variant: "square", classes: { root: classes.categoryIcon } }), primary: _jsx(_Fragment, { children: isSnippetTemplate ? (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, notificationObject.incubator.approved_category) }, { children: _jsx(Typography, Object.assign({ component: "div", className: classes.categoryApprovedText, color: "inherit" }, { children: intl.formatMessage(messages.incubatorApproved, {
                        name: notificationObject.incubator.name,
                        b: (...chunks) => _jsx("strong", { children: chunks })
                    }) })) }))) : (_jsxs(_Fragment, { children: [template === SCNotificationObjectTemplateType.DETAIL && notificationObject.is_new && _jsx(NewChip, {}), _jsx(Typography, Object.assign({ component: "div", className: classes.categoryApprovedText, color: "inherit" }, { children: intl.formatMessage(messages.incubatorApproved, {
                            name: notificationObject.incubator.name,
                            b: (...chunks) => _jsx("strong", { children: chunks })
                        }) }))] })) }), secondary: (template === SCNotificationObjectTemplateType.DETAIL || template === SCNotificationObjectTemplateType.SNIPPET) && (_jsx(DateTimeAgo, { date: notificationObject.active_at, className: classes.activeAt })), footer: template === SCNotificationObjectTemplateType.DETAIL ? (_jsx(Button, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, notificationObject.incubator.approved_category), className: classes.viewIncubatorButton }, { children: _jsx(FormattedMessage, { id: 'ui.notification.incubatorApproved.viewIncubator', defaultMessage: 'ui.notification.incubatorApproved.viewIncubator' }) }))) : template === SCNotificationObjectTemplateType.TOAST ? (_jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [_jsx(DateTimeAgo, { date: notificationObject.active_at }), _jsx(Typography, Object.assign({ color: "primary", component: 'div' }, { children: _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, notificationObject.incubator) }, { children: _jsx(FormattedMessage, { id: "ui.userToastNotifications.incubatorApproved.viewIncubator", defaultMessage: 'ui.userToastNotifications.incubatorApproved.viewIncubator' }) })) }))] }))) : null }, rest)));
}
