"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const helpers_1 = require("../../helpers");
const payloads_1 = require("../../payloads");
const constants_1 = require("../../constants");
const constants_2 = require("../../payloads/constants");
const sendVideoCallNotification = ({ signer, chainId, pgpPrivateKey }, { recipientAddress, senderAddress, chatId, rules, status, signalData = null, env = constants_1.default.ENV.PROD, callType = constants_2.VIDEO_CALL_TYPE.PUSH_VIDEO, callDetails, }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
    var _a;
    try {
        const videoData = {
            recipientAddress,
            senderAddress,
            chatId: (_a = rules === null || rules === void 0 ? void 0 : rules.access.data) !== null && _a !== void 0 ? _a : chatId,
            signalData,
            status,
            callDetails,
        };
        const senderAddressInCaip = (0, helpers_1.getCAIPWithChainId)(senderAddress, chainId);
        const recipientAddressInCaip = (0, helpers_1.getCAIPWithChainId)(recipientAddress, chainId);
        const notificationText = `Video Call from ${senderAddress}`;
        const notificationType = constants_2.NOTIFICATION_TYPE.TARGETTED;
        yield (0, payloads_1.sendNotification)({
            senderType: 1,
            signer,
            pgpPrivateKey,
            chatId,
            rules,
            type: notificationType,
            identityType: 2,
            notification: {
                title: notificationText,
                body: notificationText,
            },
            payload: {
                title: 'VideoCall',
                body: 'VideoCall',
                cta: '',
                img: '',
                additionalMeta: {
                    type: `${callType}+1`,
                    data: JSON.stringify(videoData),
                },
            },
            recipients: recipientAddressInCaip,
            channel: senderAddressInCaip,
            env,
        });
    }
    catch (err) {
        console.error('Error occured while sending notification for video call', err);
    }
});
exports.default = sendVideoCallNotification;
//# sourceMappingURL=sendVideoCallNotification.js.map