import { Client } from '@amityco/ts-sdk-react-native';
import { MemberRoles, Permissions } from '../../core/constants';
export const checkDeleteCommunityPermission = communityId => {
  const client = Client.getActiveClient();
  const communityPermission = client.hasPermission(Permissions.DeleteCommunityPermission).community(communityId);
  return !!communityPermission;
};
export const checkEditCommunityPermission = communityId => {
  const client = Client.getActiveClient();
  const communityPermission = client.hasPermission(Permissions.EditCommunityPermission).community(communityId);
  return !!communityPermission;
};
export const checkEditRolePermission = communityId => {
  const client = Client.getActiveClient();
  const communityPermission = client.hasPermission(Permissions.EditRolePermission).community(communityId);
  return !!communityPermission;
};
export const isModerator = (roles = []) => {
  if (!(roles !== null && roles !== void 0 && roles.length)) return false;
  const moderatorRoles = [MemberRoles.COMMUNITY_MODERATOR, MemberRoles.CHANNEL_MODERATOR, MemberRoles.MODERATOR, MemberRoles.SUPER_MODERATOR];
  return moderatorRoles.some(role => roles.includes(role));
};
export const isAdmin = (roles = []) => {
  if (!(roles !== null && roles !== void 0 && roles.length)) return false;
  return roles.includes(MemberRoles.ADMIN);
};
export const checkStoryPermission = (client, communityId) => {
  if (!client) {
    return false;
  }
  if (communityId) {
    const communityPermission = client.hasPermission(Permissions.ManageStoryPermission).community(communityId);
    return communityPermission;
  }
  return false;
};
//# sourceMappingURL=permissions.js.map