var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import BadDataException from "../../../../../Types/Exception/BadDataException";
import ObjectID from "../../../../../Types/ObjectID";
import AlertService from "../../../../Services/AlertService";
import SlackUtil from "../Slack";
import SlackActionType, { PrivateNoteEmojis } from "./ActionTypes";
import Response from "../../../Response";
import AlertInternalNoteService from "../../../../Services/AlertInternalNoteService";
import OnCallDutyPolicyService from "../../../../Services/OnCallDutyPolicyService";
import { LIMIT_PER_PROJECT } from "../../../../../Types/Database/LimitMax";
import UserNotificationEventType from "../../../../../Types/UserNotification/UserNotificationEventType";
import AlertStateService from "../../../../Services/AlertStateService";
import logger from "../../../Logger";
import AccessTokenService from "../../../../Services/AccessTokenService";
import CaptureSpan from "../../../Telemetry/CaptureSpan";
import WorkspaceNotificationLogService from "../../../../Services/WorkspaceNotificationLogService";
import WorkspaceUserAuthTokenService from "../../../../Services/WorkspaceUserAuthTokenService";
import WorkspaceType from "../../../../../Types/Workspace/WorkspaceType";
import WorkspaceProjectAuthTokenService from "../../../../Services/WorkspaceProjectAuthTokenService";
export default class SlackAlertActions {
    static isAlertAction(data) {
        const { actionType } = data;
        switch (actionType) {
            case SlackActionType.AcknowledgeAlert:
            case SlackActionType.ResolveAlert:
            case SlackActionType.ViewAddAlertNote:
            case SlackActionType.SubmitAlertNote:
            case SlackActionType.ViewChangeAlertState:
            case SlackActionType.SubmitChangeAlertState:
            case SlackActionType.ViewExecuteAlertOnCallPolicy:
            case SlackActionType.SubmitExecuteAlertOnCallPolicy:
            case SlackActionType.ViewAlert:
                return true;
            default:
                return false;
        }
    }
    static async acknowledgeAlert(data) {
        var _a;
        const { slackRequest, req, res } = data;
        const { botUserId, userId, projectAuthToken, slackUsername } = slackRequest;
        const { actionValue } = data.action;
        if (!actionValue) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid Alert ID"));
        }
        if (!userId) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid User ID"));
        }
        if (!projectAuthToken) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid Project Auth Token"));
        }
        if (!botUserId) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid Bot User ID"));
        }
        if (data.action.actionType === SlackActionType.AcknowledgeAlert) {
            const alertId = new ObjectID(actionValue);
            // We send this early let slack know we're ok. We'll do the rest in the background.
            Response.sendJsonObjectResponse(req, res, {
                response_action: "clear",
            });
            const isAlreadyAcknowledged = await AlertService.isAlertAcknowledged({
                alertId: alertId,
            });
            if (isAlreadyAcknowledged) {
                const alertNumberResult = await AlertService.getAlertNumber({
                    alertId: alertId,
                });
                // send a message to the channel visible to user, that the alert has already been acknowledged.
                const markdwonPayload = {
                    _type: "WorkspacePayloadMarkdown",
                    text: `@${slackUsername}, unfortunately you cannot acknowledge the **[Alert ${alertNumberResult.numberWithPrefix || "#" + alertNumberResult.number}](${await AlertService.getAlertLinkInDashboard(slackRequest.projectId, alertId)})**. It has already been acknowledged.`,
                };
                await SlackUtil.sendDirectMessageToUser({
                    messageBlocks: [markdwonPayload],
                    authToken: projectAuthToken,
                    workspaceUserId: slackRequest.slackUserId,
                });
                return;
            }
            await AlertService.acknowledgeAlert(alertId, userId);
            // Log the button interaction
            if (slackRequest.projectId) {
                try {
                    const logData = {
                        projectId: slackRequest.projectId,
                        workspaceType: WorkspaceType.Slack,
                        userId: userId,
                        buttonAction: "acknowledge_alert",
                    };
                    if (slackRequest.slackChannelId) {
                        logData.channelId = slackRequest.slackChannelId;
                    }
                    logData.alertId = alertId;
                    await WorkspaceNotificationLogService.logButtonPressed(logData, {
                        isRoot: true,
                    });
                }
                catch (err) {
                    logger.error("Error logging button interaction:", {
                        projectId: (_a = slackRequest.projectId) === null || _a === void 0 ? void 0 : _a.toString(),
                    });
                    logger.error(err);
                    // Don't throw the error, just log it so the main flow continues
                }
            }
            // Alert Feed will send a message to the channel that the alert has been Acknowledged.
            return;
        }
        // invalid action type.
        return Response.sendErrorResponse(req, res, new BadDataException("Invalid Action Type"));
    }
    static async resolveAlert(data) {
        const { slackRequest, req, res } = data;
        const { botUserId, userId, projectAuthToken, slackUsername } = slackRequest;
        const { actionValue } = data.action;
        if (!actionValue) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid Alert ID"));
        }
        if (!userId) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid User ID"));
        }
        if (!projectAuthToken) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid Project Auth Token"));
        }
        if (!botUserId) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid Bot User ID"));
        }
        if (data.action.actionType === SlackActionType.ResolveAlert) {
            const alertId = new ObjectID(actionValue);
            // We send this early let slack know we're ok. We'll do the rest in the background.
            Response.sendJsonObjectResponse(req, res, {
                response_action: "clear",
            });
            const isAlreadyResolved = await AlertService.isAlertResolved({
                alertId: alertId,
            });
            if (isAlreadyResolved) {
                const alertNumberResult = await AlertService.getAlertNumber({
                    alertId: alertId,
                });
                // send a message to the channel visible to user, that the alert has already been Resolved.
                const markdwonPayload = {
                    _type: "WorkspacePayloadMarkdown",
                    text: `@${slackUsername}, unfortunately you cannot resolve the **[Alert ${alertNumberResult.numberWithPrefix || "#" + alertNumberResult.number}](${await AlertService.getAlertLinkInDashboard(slackRequest.projectId, alertId)})**. It has already been resolved.`,
                };
                await SlackUtil.sendDirectMessageToUser({
                    messageBlocks: [markdwonPayload],
                    authToken: projectAuthToken,
                    workspaceUserId: slackRequest.slackUserId,
                });
                return;
            }
            await AlertService.resolveAlert(alertId, userId);
            return;
        }
        // invalid action type.
        return Response.sendErrorResponse(req, res, new BadDataException("Invalid Action Type"));
    }
    static async viewExecuteOnCallPolicy(data) {
        const { req, res } = data;
        const { actionValue } = data.action;
        if (!actionValue) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid Alert ID"));
        }
        // We send this early let slack know we're ok. We'll do the rest in the background.
        Response.sendJsonObjectResponse(req, res, {
            response_action: "clear",
        });
        // const alertId: ObjectID = new ObjectID(actionValue);
        // send a modal with a dropdown that says "Public Note" or "Private Note" and a text area to add the note.
        const onCallPolicies = await OnCallDutyPolicyService.findBy({
            query: {
                projectId: data.slackRequest.projectId,
            },
            select: {
                name: true,
            },
            props: {
                isRoot: true,
            },
            limit: LIMIT_PER_PROJECT,
            skip: 0,
        });
        const dropdownOption = onCallPolicies
            .map((policy) => {
            var _a;
            return {
                label: policy.name || "",
                value: ((_a = policy._id) === null || _a === void 0 ? void 0 : _a.toString()) || "",
            };
        })
            .filter((option) => {
            return option.label !== "" || option.value !== "";
        });
        if (dropdownOption.length === 0) {
            if (data.slackRequest.slackChannelId) {
                await SlackUtil.sendEphemeralMessageToChannel({
                    messageBlocks: [
                        {
                            _type: "WorkspacePayloadMarkdown",
                            text: "No on-call policies have been configured for this project yet. Please add an on-call policy in the OneUptime Dashboard under On-Call Duty > Policies to use this feature.",
                        },
                    ],
                    authToken: data.slackRequest.projectAuthToken,
                    channelId: data.slackRequest.slackChannelId,
                    userId: data.slackRequest.slackUserId,
                });
            }
            return;
        }
        const onCallPolicyDropdown = {
            _type: "WorkspaceDropdownBlock",
            label: "On Call Policy",
            blockId: "onCallPolicy",
            placeholder: "Select On Call Policy",
            options: dropdownOption,
        };
        const modalBlock = {
            _type: "WorkspaceModalBlock",
            title: "Execute On Call Policy",
            submitButtonTitle: "Submit",
            cancelButtonTitle: "Cancel",
            actionId: SlackActionType.SubmitExecuteAlertOnCallPolicy,
            actionValue: actionValue,
            blocks: [onCallPolicyDropdown],
        };
        await SlackUtil.showModalToUser({
            authToken: data.slackRequest.projectAuthToken,
            modalBlock: modalBlock,
            triggerId: data.slackRequest.triggerId,
        });
    }
    static async viewChangeAlertState(data) {
        var _a;
        const { req, res } = data;
        const { actionValue } = data.action;
        if (!actionValue) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid Alert ID"));
        }
        // We send this early let slack know we're ok. We'll do the rest in the background.
        Response.sendJsonObjectResponse(req, res, {
            response_action: "clear",
        });
        // const alertId: ObjectID = new ObjectID(actionValue);
        // send a modal with a dropdown that says "Public Note" or "Private Note" and a text area to add the note.
        const alertStates = await AlertStateService.getAllAlertStates({
            projectId: data.slackRequest.projectId,
            props: {
                isRoot: true,
            },
        });
        logger.debug("Alert States: ", {
            projectId: (_a = data.slackRequest.projectId) === null || _a === void 0 ? void 0 : _a.toString(),
        });
        logger.debug(alertStates);
        const dropdownOptions = alertStates
            .map((state) => {
            var _a;
            return {
                label: state.name || "",
                value: ((_a = state._id) === null || _a === void 0 ? void 0 : _a.toString()) || "",
            };
        })
            .filter((option) => {
            return option.label !== "" || option.value !== "";
        });
        logger.debug("Dropdown Options: ");
        logger.debug(dropdownOptions);
        const statePickerDropdown = {
            _type: "WorkspaceDropdownBlock",
            label: "Alert State",
            blockId: "alertState",
            placeholder: "Select Alert State",
            options: dropdownOptions,
        };
        const modalBlock = {
            _type: "WorkspaceModalBlock",
            title: "Change Alert State",
            submitButtonTitle: "Submit",
            cancelButtonTitle: "Cancel",
            actionId: SlackActionType.SubmitChangeAlertState,
            actionValue: actionValue,
            blocks: [statePickerDropdown],
        };
        await SlackUtil.showModalToUser({
            authToken: data.slackRequest.projectAuthToken,
            modalBlock: modalBlock,
            triggerId: data.slackRequest.triggerId,
        });
    }
    static async submitChangeAlertState(data) {
        var _a;
        const { req, res } = data;
        const { actionValue } = data.action;
        if (!actionValue) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid Alert ID"));
        }
        // We send this early let slack know we're ok. We'll do the rest in the background.
        Response.sendJsonObjectResponse(req, res, {
            response_action: "clear",
        });
        // const alertId: ObjectID = new ObjectID(actionValue);
        // send a modal with a dropdown that says "Public Note" or "Private Note" and a text area to add the note.
        if (!data.slackRequest.viewValues ||
            !data.slackRequest.viewValues["alertState"]) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid View Values"));
        }
        const alertId = new ObjectID(actionValue);
        const stateString = data.slackRequest.viewValues["alertState"].toString();
        const stateId = new ObjectID(stateString);
        await AlertService.updateOneById({
            id: alertId,
            data: {
                currentAlertStateId: stateId,
            },
            props: await AccessTokenService.getDatabaseCommonInteractionPropsByUserAndProject({
                userId: data.slackRequest.userId,
                projectId: data.slackRequest.projectId,
            }),
        });
        // Log the button interaction
        if (data.slackRequest.projectId && data.slackRequest.userId) {
            try {
                const logData = {
                    projectId: data.slackRequest.projectId,
                    workspaceType: WorkspaceType.Slack,
                    userId: data.slackRequest.userId,
                    buttonAction: "change_alert_state",
                };
                if (data.slackRequest.slackChannelId) {
                    logData.channelId = data.slackRequest.slackChannelId;
                }
                logData.alertId = alertId;
                await WorkspaceNotificationLogService.logButtonPressed(logData, {
                    isRoot: true,
                });
            }
            catch (err) {
                logger.error("Error logging button interaction:", {
                    projectId: (_a = data.slackRequest.projectId) === null || _a === void 0 ? void 0 : _a.toString(),
                    alertId: alertId.toString(),
                });
                logger.error(err);
                // Don't throw the error, just log it so the main flow continues
            }
        }
    }
    static async executeOnCallPolicy(data) {
        const { slackRequest, req, res } = data;
        const { botUserId, userId, projectAuthToken, slackUsername } = slackRequest;
        const { actionValue } = data.action;
        if (!actionValue) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid Alert ID"));
        }
        if (!userId) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid User ID"));
        }
        if (!projectAuthToken) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid Project Auth Token"));
        }
        if (!botUserId) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid Bot User ID"));
        }
        if (data.action.actionType === SlackActionType.SubmitExecuteAlertOnCallPolicy) {
            const alertId = new ObjectID(actionValue);
            // We send this early let slack know we're ok. We'll do the rest in the background.
            Response.sendJsonObjectResponse(req, res, {
                response_action: "clear",
            });
            const isAlreadyResolved = await AlertService.isAlertResolved({
                alertId: alertId,
            });
            if (isAlreadyResolved) {
                const alertNumberResult = await AlertService.getAlertNumber({
                    alertId: alertId,
                });
                // send a message to the channel visible to user, that the alert has already been Resolved.
                const markdwonPayload = {
                    _type: "WorkspacePayloadMarkdown",
                    text: `@${slackUsername}, unfortunately you cannot execute the on-call policy for **[Alert ${alertNumberResult.numberWithPrefix || "#" + alertNumberResult.number}](${await AlertService.getAlertLinkInDashboard(slackRequest.projectId, alertId)})**. It has already been resolved.`,
                };
                await SlackUtil.sendDirectMessageToUser({
                    messageBlocks: [markdwonPayload],
                    authToken: projectAuthToken,
                    workspaceUserId: slackRequest.slackUserId,
                });
                return;
            }
            if (!data.slackRequest.viewValues ||
                !data.slackRequest.viewValues["onCallPolicy"]) {
                return Response.sendErrorResponse(req, res, new BadDataException("Invalid View Values"));
            }
            const onCallPolicyString = data.slackRequest.viewValues["onCallPolicy"].toString();
            // get the on-call policy id.
            const onCallPolicyId = new ObjectID(onCallPolicyString);
            await OnCallDutyPolicyService.executePolicy(onCallPolicyId, {
                triggeredByAlertId: alertId,
                userNotificationEventType: UserNotificationEventType.AlertCreated,
            });
        }
    }
    static async submitAlertNote(data) {
        const { req, res } = data;
        const { actionValue } = data.action;
        if (!actionValue) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid Alert ID"));
        }
        // const alertId: ObjectID = new ObjectID(actionValue);
        // send a modal with a dropdown that says "Public Note" or "Private Note" and a text area to add the note.
        // if view values is empty, then return error.
        if (!data.slackRequest.viewValues) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid View Values"));
        }
        if (!data.slackRequest.viewValues["note"]) {
            // return error.
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid Note"));
        }
        const alertId = new ObjectID(actionValue);
        const note = data.slackRequest.viewValues["note"].toString();
        // send empty response.
        Response.sendJsonObjectResponse(req, res, {
            response_action: "clear",
        });
        await AlertInternalNoteService.addNote({
            alertId: alertId,
            note: note || "",
            projectId: data.slackRequest.projectId,
            userId: data.slackRequest.userId,
        });
    }
    static async viewAddAlertNote(data) {
        const { req, res } = data;
        const { actionValue } = data.action;
        if (!actionValue) {
            return Response.sendErrorResponse(req, res, new BadDataException("Invalid Alert ID"));
        }
        // We send this early let slack know we're ok. We'll do the rest in the background.
        Response.sendJsonObjectResponse(req, res, {
            response_action: "clear",
        });
        // const alertId: ObjectID = new ObjectID(actionValue);
        // send a modal with a dropdown that says "Public Note" or "Private Note" and a text area to add the note.
        const noteTextArea = {
            _type: "WorkspaceTextAreaBlock",
            label: "Note",
            blockId: "note",
            placeholder: "Note",
            description: "Please type in plain text or markdown.",
        };
        const modalBlock = {
            _type: "WorkspaceModalBlock",
            title: "Add Note",
            submitButtonTitle: "Submit",
            cancelButtonTitle: "Cancel",
            actionId: SlackActionType.SubmitAlertNote,
            actionValue: actionValue,
            blocks: [noteTextArea],
        };
        await SlackUtil.showModalToUser({
            authToken: data.slackRequest.projectAuthToken,
            modalBlock: modalBlock,
            triggerId: data.slackRequest.triggerId,
        });
    }
    static async handleAlertAction(data) {
        // now we should be all set, project is authorized and user is authorized. Lets perform some actions based on the action type.
        const actionType = data.action.actionType;
        if (actionType === SlackActionType.AcknowledgeAlert) {
            return await this.acknowledgeAlert(data);
        }
        if (actionType === SlackActionType.ResolveAlert) {
            return await this.resolveAlert(data);
        }
        if (actionType === SlackActionType.ViewAddAlertNote) {
            return await this.viewAddAlertNote(data);
        }
        if (actionType === SlackActionType.SubmitAlertNote) {
            return await this.submitAlertNote(data);
        }
        if (actionType === SlackActionType.ViewExecuteAlertOnCallPolicy) {
            return await this.viewExecuteOnCallPolicy(data);
        }
        if (actionType === SlackActionType.SubmitExecuteAlertOnCallPolicy) {
            return await this.executeOnCallPolicy(data);
        }
        if (actionType === SlackActionType.ViewChangeAlertState) {
            return await this.viewChangeAlertState(data);
        }
        if (actionType === SlackActionType.SubmitChangeAlertState) {
            return await this.submitChangeAlertState(data);
        }
        if (actionType === SlackActionType.ViewAlert) {
            /*
             * do nothing. This is just a view alert action.
             * clear response.
             */
            return Response.sendJsonObjectResponse(data.req, data.res, {
                response_action: "clear",
            });
        }
        // invalid action type.
        return Response.sendErrorResponse(data.req, data.res, new BadDataException("Invalid Action Type"));
    }
    static async handleEmojiReaction(data) {
        logger.debug("Handling emoji reaction for Alert with data:", {
            channelId: data.channelId,
        });
        logger.debug(data);
        const { teamId, reaction, userId, channelId, messageTs } = data;
        // Alerts only support private notes, so only pushpin emojis work
        const isPrivateNoteEmoji = PrivateNoteEmojis.includes(reaction);
        if (!isPrivateNoteEmoji) {
            logger.debug(`Emoji "${reaction}" is not a supported private note emoji for alerts. Ignoring.`);
            return;
        }
        // Get the project auth token using the team ID
        const projectAuth = await WorkspaceProjectAuthTokenService.findOneBy({
            query: {
                workspaceProjectId: teamId,
            },
            select: {
                projectId: true,
                authToken: true,
            },
            props: {
                isRoot: true,
            },
        });
        if (!projectAuth || !projectAuth.projectId || !projectAuth.authToken) {
            logger.debug("No project auth found for team ID. Ignoring emoji reaction.");
            return;
        }
        const projectId = projectAuth.projectId;
        const authToken = projectAuth.authToken;
        // Find the alert linked to this channel
        const workspaceLog = await WorkspaceNotificationLogService.findOneBy({
            query: {
                channelId: channelId,
                workspaceType: WorkspaceType.Slack,
                projectId: projectId,
            },
            select: {
                alertId: true,
            },
            props: {
                isRoot: true,
            },
        });
        if (!workspaceLog || !workspaceLog.alertId) {
            logger.debug("No alert found linked to this channel. Ignoring emoji reaction.");
            return;
        }
        const alertId = workspaceLog.alertId;
        // Get the alert number for the confirmation message
        const alertNumberResult = await AlertService.getAlertNumber({
            alertId: alertId,
        });
        // Get the user ID in OneUptime based on Slack user ID
        const userAuth = await WorkspaceUserAuthTokenService.findOneBy({
            query: {
                workspaceUserId: userId,
                workspaceType: WorkspaceType.Slack,
                projectId: projectId,
            },
            select: {
                userId: true,
            },
            props: {
                isRoot: true,
            },
        });
        if (!userAuth || !userAuth.userId) {
            logger.debug("No OneUptime user found for Slack user. Ignoring emoji reaction.");
            return;
        }
        const oneUptimeUserId = userAuth.userId;
        // Fetch the message text using the timestamp
        let messageText = null;
        try {
            messageText = await SlackUtil.getMessageByTimestamp({
                authToken: authToken,
                channelId: channelId,
                messageTs: messageTs,
            });
        }
        catch (err) {
            logger.error("Error fetching message text:", {
                projectId: projectId.toString(),
                alertId: alertId.toString(),
                channelId: channelId,
            });
            logger.error(err);
            return;
        }
        if (!messageText) {
            logger.debug("No message text found. Ignoring emoji reaction.", {
                projectId: projectId.toString(),
                alertId: alertId.toString(),
                channelId: channelId,
            });
            return;
        }
        // Create a unique identifier for this Slack message to prevent duplicate notes
        const postedFromSlackMessageId = `${channelId}:${messageTs}`;
        // Check if a note from this Slack message already exists
        const hasExistingNote = await AlertInternalNoteService.hasNoteFromSlackMessage({
            alertId: alertId,
            postedFromSlackMessageId: postedFromSlackMessageId,
        });
        if (hasExistingNote) {
            logger.debug("Private note from this Slack message already exists. Skipping duplicate.");
            return;
        }
        // Save as private note (Alerts only support private notes)
        try {
            await AlertInternalNoteService.addNote({
                alertId: alertId,
                note: messageText,
                projectId: projectId,
                userId: oneUptimeUserId,
                postedFromSlackMessageId: postedFromSlackMessageId,
            });
            logger.debug("Private note added to alert successfully.", {
                projectId: projectId.toString(),
                alertId: alertId.toString(),
            });
        }
        catch (err) {
            logger.error("Error saving note:", {
                projectId: projectId.toString(),
                alertId: alertId.toString(),
            });
            logger.error(err);
            return;
        }
        // Send confirmation message as a reply to the original message thread
        try {
            const alertLink = (await AlertService.getAlertLinkInDashboard(projectId, alertId)).toString();
            const confirmationMessage = `✅ Message saved as *private note* to <${alertLink}|Alert ${alertNumberResult.numberWithPrefix || "#" + alertNumberResult.number}>.`;
            await SlackUtil.sendMessageToThread({
                authToken: authToken,
                channelId: channelId,
                threadTs: messageTs,
                text: confirmationMessage,
            });
            logger.debug("Confirmation message sent successfully.");
        }
        catch (err) {
            logger.error("Error sending confirmation message:", {
                projectId: projectId.toString(),
                alertId: alertId.toString(),
            });
            logger.error(err);
            // Don't throw - note was saved successfully, confirmation is best effort
        }
    }
}
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Boolean)
], SlackAlertActions, "isAlertAction", null);
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], SlackAlertActions, "acknowledgeAlert", null);
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], SlackAlertActions, "resolveAlert", null);
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], SlackAlertActions, "viewExecuteOnCallPolicy", null);
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], SlackAlertActions, "viewChangeAlertState", null);
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], SlackAlertActions, "submitChangeAlertState", null);
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], SlackAlertActions, "executeOnCallPolicy", null);
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], SlackAlertActions, "submitAlertNote", null);
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], SlackAlertActions, "viewAddAlertNote", null);
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], SlackAlertActions, "handleAlertAction", null);
__decorate([
    CaptureSpan(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], SlackAlertActions, "handleEmojiReaction", null);
//# sourceMappingURL=Alert.js.map