"use strict";
const index = require("./i18n-HHdcQbuJ.cjs");
const credential = require("./credential-xoMnaX4v.cjs");
function isRecurringEvent(obj) {
  const parsed = index.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 index.prisma.credential.findMany({
    where: {
      userId: user.id
    },
    select: index.credentialForCalendarServiceSelect,
    orderBy: {
      id: "asc"
    }
  });
  const { credentials: allCredentials } = await credential.enrichUserWithDelegationCredentialsIncludeServiceAccountKey({
    user: {
      email: user.email,
      id: user.id,
      credentials
    }
  });
  return allCredentials;
}
exports.checkAdminOrOwner = checkAdminOrOwner;
exports.getUsersCredentialsIncludeServiceAccountKey = getUsersCredentialsIncludeServiceAccountKey;
exports.isRecurringEvent = isRecurringEvent;
exports.parseRecurringEvent = parseRecurringEvent;
