"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.addCommentReaction = addCommentReaction;
exports.createComment = createComment;
exports.createReplyComment = createReplyComment;
exports.deleteCommentById = deleteCommentById;
exports.editComment = editComment;
exports.removeCommentReaction = removeCommentReaction;
var _tsSdkReactNative = require("@amityco/ts-sdk-react-native");
async function addCommentReaction(commentId, reactionName) {
  const reactionObject = new Promise(async (resolve, reject) => {
    try {
      const isCommentReactionAdded = await _tsSdkReactNative.ReactionRepository.addReaction('comment', commentId, reactionName);
      resolve(isCommentReactionAdded);
    } catch (error) {
      reject(error);
    }
  });
  return reactionObject;
}
async function removeCommentReaction(commentId, reactionName) {
  const reactionObject = new Promise(async (resolve, reject) => {
    try {
      const isCommentReactionRemoved = await _tsSdkReactNative.ReactionRepository.removeReaction('comment', commentId, reactionName);
      resolve(isCommentReactionRemoved);
    } catch (error) {
      reject(error);
    }
  });
  return reactionObject;
}
async function createComment(text, postId, mentionUserIds, mentionPosition, referenceType) {
  const createCommentObject = new Promise(async (resolve, reject) => {
    try {
      const newComment = {
        data: {
          text: text
        },
        referenceId: postId,
        referenceType: referenceType,
        mentionees: [{
          type: 'user',
          userIds: mentionUserIds
        }],
        metadata: {
          mentioned: mentionPosition
        }
      };
      const {
        data: comment
      } = await _tsSdkReactNative.CommentRepository.createComment(newComment);
      resolve(comment);
    } catch (error) {
      reject(error);
    }
  });
  return createCommentObject;
}
async function createReplyComment(text, postId, parentId, mentionUserIds, mentionPosition, referenceType) {
  const createCommentObject = new Promise(async (resolve, reject) => {
    try {
      const newComment = {
        data: {
          text: text
        },
        referenceId: postId,
        referenceType: referenceType,
        mentionees: [{
          type: 'user',
          userIds: mentionUserIds
        }],
        metadata: {
          mentioned: mentionPosition
        },
        parentId: parentId
      };
      const {
        data: comment
      } = await _tsSdkReactNative.CommentRepository.createComment(newComment);
      resolve(comment);
    } catch (error) {
      reject(error);
    }
  });
  return createCommentObject;
}
async function editComment(text, commentId, referenceType, mentionUserIds, mentionPosition) {
  const createCommentObject = new Promise(async (resolve, reject) => {
    try {
      const updatedComment = {
        data: {
          text: text
        },
        referenceType: referenceType,
        mentionees: [{
          type: 'user',
          userIds: mentionUserIds ?? []
        }],
        metadata: {
          mentioned: mentionPosition ?? []
        }
      };
      const {
        data: comment
      } = await _tsSdkReactNative.CommentRepository.updateComment(commentId, updatedComment);
      resolve(comment);
    } catch (error) {
      reject(error);
    }
  });
  return createCommentObject;
}
async function deleteCommentById(commentId) {
  const isDeletedObject = new Promise(async (resolve, reject) => {
    try {
      const hardDelete = await _tsSdkReactNative.CommentRepository.deleteComment(commentId, true);
      if (hardDelete) {
        resolve(true);
      }
    } catch (error) {
      reject(error);
    }
  });
  return isDeletedObject;
}
//# sourceMappingURL=comment.js.map