import { P, H, a } from "./ooo-Y0RqL_2P.js";
import { S } from "./schedule-ONlqbj_y.js";
import { B } from "./booking-mBCxBXeJ.js";
import { E } from "./eventTypeRepository-bLzDPNDz.js";
import { R } from "./formResponse-4j2gt5Il.js";
import { T } from "./team-7rZ1xMNP.js";
import { U } from "./user-qsqUT7Fk.js";
import { F } from "./features.repository-X0S5Zedc.js";
import { M } from "./membership-mMg5Wpvz.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
};
