"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GroupKeyResponseTranslator = void 0;
const utils_1 = require("@streamr/utils");
const EncryptedGroupKey_1 = require("./EncryptedGroupKey");
const GroupKeyResponse_1 = require("./GroupKeyResponse");
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
class GroupKeyResponseTranslator {
    static toProtobuf(msg) {
        const groupKeys = msg.encryptedGroupKeys.map((groupKey) => {
            return {
                data: groupKey.data,
                id: groupKey.id
            };
        });
        const translated = {
            recipientId: (0, utils_1.toUserIdRaw)(msg.recipient),
            requestId: msg.requestId,
            groupKeys
        };
        return translated;
    }
    static toClientProtocol(msg) {
        const encryptedGroupKeys = msg.groupKeys.map((groupKey) => new EncryptedGroupKey_1.EncryptedGroupKey(groupKey.id, groupKey.data));
        return new GroupKeyResponse_1.GroupKeyResponse({
            requestId: msg.requestId,
            recipient: (0, utils_1.toUserId)(msg.recipientId),
            encryptedGroupKeys
        });
    }
}
exports.GroupKeyResponseTranslator = GroupKeyResponseTranslator;
//# sourceMappingURL=GroupKeyResponseTranslator.js.map