import { H as HttpError } from "./http-error-RJXCPZV2.js";
import { U as UserRepository } from "./user-9vti0VBh.js";
import { p as prisma } from "./orgDomains-eTg-cjth.js";
const throwIfNotHaveAdminAccessToTeam = async ({
  teamId,
  userId
}) => {
  if (!teamId) {
    return;
  }
  const userRepo = new UserRepository(prisma);
  const userAdminTeams = await userRepo.getUserAdminTeams({ userId });
  const teamsUserHasAdminAccessFor = userAdminTeams?.teams?.map(({ team }) => team.id) ?? [];
  const hasAdminAccessToTeam = teamsUserHasAdminAccessFor.some((id) => id === teamId);
  if (!hasAdminAccessToTeam) {
    throw new HttpError({ statusCode: 401, message: "You must be an admin of the team to do this" });
  }
};
export {
  throwIfNotHaveAdminAccessToTeam as t
};
