import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2022-2026 GoodData Corporation
import cx from "classnames";
import { FormattedMessage, defineMessage, useIntl } from "react-intl";
import { Button, Dialog, Hyperlink, OverlayController, OverlayControllerProvider, Typography, useId, } from "@gooddata/sdk-ui-kit";
import { messages } from "../../../../locales.js";
import { DASHBOARD_DIALOG_OVERS_Z_INDEX } from "../../../constants/zIndex.js";
import { useAlertingManagementDialogContext } from "../../contexts/AlertingManagementDialogContext.js";
import { useAutomationsContext } from "../../contexts/AutomationsContext.js";
import { isMobileView } from "../DefaultAlertingDialog/utils/responsive.js";
import { useAlertingDialogAccessibility } from "../hooks/useAlertingDialogAccessibility.js";
import { Alerts } from "./components/AlertsList.js";
const overlayController = OverlayController.getInstance(DASHBOARD_DIALOG_OVERS_Z_INDEX);
/**
 * @internal
 */
export function DefaultAlertingManagementDialogContentBasic({ onClose, onDelete, onEdit, onPause, isLoadingAlertingData, automations, }) {
    const intl = useIntl();
    const { isWhiteLabeled } = useAutomationsContext();
    const { isAlertDialogOpen } = useAlertingManagementDialogContext();
    const { returnFocusTo } = useAlertingDialogAccessibility();
    const isMobile = isMobileView();
    const helpTextId = isMobile
        ? defineMessage({ id: "dialogs.alerting.footer.title.short" }).id
        : defineMessage({ id: "dialogs.alerting.footer.title" }).id;
    const titleElementId = useId();
    return (_jsx(Dialog, { displayCloseButton: true, onCancel: onClose, shouldCloseOnClick: () => false, autofocusOnOpen: true, className: cx("gd-notifications-channels-management-dialog s-alerting-management-dialog"), accessibilityConfig: { titleElementId, isModal: true }, returnFocusTo: returnFocusTo, returnFocusAfterClose: true, refocusKey: isAlertDialogOpen, children: _jsxs(OverlayControllerProvider, { overlayController: overlayController, children: [
                _jsx("div", { className: "gd-notifications-channels-management-dialog-title", children: _jsx(Typography, { tagName: "h3", className: "gd-dialog-header", id: titleElementId, children: _jsx(FormattedMessage, { id: "dialogs.alerting.management.title" }) }) }), _jsxs("div", { className: "gd-notifications-channels-content", children: [
                        _jsx("div", { className: "gd-notifications-channels-content-header", children: _jsx(Typography, { tagName: "h3", children: _jsx(FormattedMessage, { id: messages.alertingManagementListTitle.id }) }) }), _jsx(Alerts, { onDelete: onDelete, onEdit: onEdit, onPause: onPause, isLoading: isLoadingAlertingData, alerts: automations, noAlertsMessageId: messages.alertingManagementNoAlerts.id })
                    ] }), _jsx("div", { className: "gd-content-divider" }), _jsxs("div", { className: `gd-buttons${isWhiteLabeled ? " gd-buttons--end" : ""}`, children: [isWhiteLabeled ? null : (_jsx(Hyperlink, { text: intl.formatMessage({ id: helpTextId }), href: "https://www.gooddata.com/docs/cloud/create-dashboards/automation/alerts/", iconClass: "gd-icon-circle-question" })), _jsx("div", { className: "gd-buttons", children: _jsx(Button, { onClick: onClose, className: "gd-button-secondary s-close-button", value: intl.formatMessage({ id: "close" }) }) })
                    ] })
            ] }) }));
}
