```ts
export function firstOverload(bookings: number[][], capacity: number): number {
  if (capacity < 1) {
    throw new Error("Capacity must be at least 1");
  }

  const events: { time: number; type: "start" | "end" }[] = [];

  for (const [start, end] of bookings) {
    if (!Number.isInteger(start) || !Number.isInteger(end)) {
      throw new Error("Booking endpoints must be integers");
    }
    if (start >= end) {
      throw new Error("Start time must come strictly before end time");
    }
    events.push({ time: start, type: "start" });
    events.push({ time: end, type: "end" });
  }

  events.sort((a, b) => a.time - b.time);

  let activeBookings = 0;
  for (const event of events) {
    if (event.type === "start") {
      activeBookings++;
      if (activeBookings > capacity) {
        return event.time;
      }
    } else {
      activeBookings--;
    }
  }

  return -1;
}
```