import { P, H, a } from "./ooo-Y0RqL_2P.js";
import { S } from "./schedule-8CReg_DS.js";
import { B } from "./booking-3Ajdl9qR.js";
import { E } from "./eventTypeRepository-xClplieB.js";
import { R } from "./formResponse-4j2gt5Il.js";
import { T } from "./team-AQqVMyqH.js";
import { U } from "./user--mpkKOwW.js";
import { F } from "./features.repository-X0S5Zedc.js";
import { M } from "./membership-OqrlZlYw.js";
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 }
      }
    });
  }
}
export {
  P as PrismaAttributeRepository,
  B as PrismaBookingRepository,
  E as PrismaEventTypeRepository,
  F as PrismaFeaturesRepository,
  H as PrismaHostRepository,
  M as PrismaMembershipRepository,
  a as PrismaOOORepository,
  R as PrismaRoutingFormResponseRepository,
  S as PrismaScheduleRepository,
  PrismaSelectedSlotRepository,
  T as PrismaTeamRepository,
  U as PrismaUserRepository
};
