import { p as prisma } from "./i18n-VAwx2uzJ.js";
const getOrgMemberOrTeamWhere = (memberId, teamId) => {
  const conditions = [];
  if (memberId) {
    conditions.push({
      AND: [
        {
          members: {
            some: {
              userId: memberId,
              accepted: true
            }
          }
        },
        {
          isOrganization: true
        }
      ]
    });
  }
  if (teamId) {
    conditions.push({
      AND: [
        {
          children: {
            some: {
              id: teamId
            }
          }
        },
        {
          isOrganization: true
        }
      ]
    });
  }
  return {
    OR: conditions
  };
};
async function getOrgIdFromMemberOrTeamId(args) {
  const orgId = await prisma.team.findFirst({
    where: getOrgMemberOrTeamWhere(args.memberId, args.teamId),
    select: {
      id: true
    }
  });
  return orgId?.id;
}
export {
  getOrgIdFromMemberOrTeamId as g
};
