import { O as recurringEventType, p as prisma, c as credentialForCalendarServiceSelect } from "./i18n-tiaWqB1b.js";
import { e as enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "./credential-7RBuTGyw.js";
function isRecurringEvent(obj) {
  const parsed = recurringEventType.safeParse(obj);
  return parsed.success;
}
function parseRecurringEvent(obj) {
  let recurringEvent = null;
  if (isRecurringEvent(obj))
    recurringEvent = obj;
  return recurringEvent;
}
function checkAdminOrOwner(role) {
  return role === "OWNER" || role === "ADMIN";
}
async function getUsersCredentialsIncludeServiceAccountKey(user) {
  const credentials = await prisma.credential.findMany({
    where: {
      userId: user.id
    },
    select: credentialForCalendarServiceSelect,
    orderBy: {
      id: "asc"
    }
  });
  const { credentials: allCredentials } = await enrichUserWithDelegationCredentialsIncludeServiceAccountKey({
    user: {
      email: user.email,
      id: user.id,
      credentials
    }
  });
  return allCredentials;
}
export {
  checkAdminOrOwner as c,
  getUsersCredentialsIncludeServiceAccountKey as g,
  isRecurringEvent as i,
  parseRecurringEvent as p
};
