"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const formResponse = require("./formResponse-QpO6EY2v.cjs");
const schedule = require("./schedule-aPT1I2PX.cjs");
const booking = require("./booking-uNoHWwSv.cjs");
const eventTypeRepository = require("./eventTypeRepository-x_dQZXQv.cjs");
const team = require("./team-HqS6vjRW.cjs");
const user = require("./user-cPqQS_l_.cjs");
const features_repository = require("./features.repository-UzW6TkXH.cjs");
class PrismaSelectedSlotRepository {
  constructor(prismaClient) {
    this.prismaClient = prismaClient;
  }
  async findFirst({ where }) {
    return await this.prismaClient.selectedSlots.findFirst({
      where
    });
  }
  async findReservedByOthers({
    slot,
    eventTypeId,
    uid
  }) {
    return await this.findFirst({
      where: {
        slotUtcStartDate: slot.utcStartIso,
        slotUtcEndDate: slot.utcEndIso,
        eventTypeId,
        uid: { not: uid },
        releaseAt: { gt: /* @__PURE__ */ new Date() }
      }
    });
  }
  async findManyReservedByOthers(slots, eventTypeId, uid) {
    return await this.prismaClient.selectedSlots.findMany({
      where: {
        OR: slots.map((slot) => ({
          slotUtcStartDate: slot.utcStartIso,
          slotUtcEndDate: slot.utcEndIso,
          eventTypeId,
          uid: { not: uid },
          releaseAt: { gt: /* @__PURE__ */ new Date() }
        }))
      },
      select: {
        slotUtcStartDate: true,
        slotUtcEndDate: true
      }
    });
  }
  async findManyUnexpiredSlots({
    userIds,
    currentTimeInUtc
  }) {
    return this.prismaClient.selectedSlots.findMany({
      where: {
        userId: { in: userIds },
        releaseAt: { gt: currentTimeInUtc }
      },
      select: {
        id: true,
        slotUtcStartDate: true,
        slotUtcEndDate: true,
        userId: true,
        isSeat: true,
        eventTypeId: true,
        uid: true
      }
    });
  }
  async deleteManyExpiredSlots({
    eventTypeId,
    currentTimeInUtc
  }) {
    return this.prismaClient.selectedSlots.deleteMany({
      where: {
        eventTypeId: { equals: eventTypeId },
        releaseAt: { lt: currentTimeInUtc }
      }
    });
  }
}
exports.PrismaOOORepository = formResponse.PrismaOOORepository;
exports.PrismaRoutingFormResponseRepository = formResponse.RoutingFormResponseRepository;
exports.PrismaScheduleRepository = schedule.ScheduleRepository;
exports.PrismaBookingRepository = booking.BookingRepository;
exports.PrismaEventTypeRepository = eventTypeRepository.EventTypeRepository;
exports.PrismaTeamRepository = team.TeamRepository;
exports.PrismaUserRepository = user.UserRepository;
exports.PrismaFeaturesRepository = features_repository.FeaturesRepository;
exports.PrismaSelectedSlotRepository = PrismaSelectedSlotRepository;
