```ts
export function firstOverload(bookings: number[][], capacity: number): number {
  if (capacity < 1) throw new Error("Capacity must be at least 1");
  for (const [start, end] of bookings) {
    if (!Number.isInteger(start) || !Number.isInteger(end)) throw new Error("Endpoints must be integers");
    if (start >= end) throw new Error("Start time must come strictly before end time");
  }

  const events: { time: number; isEnd: boolean }[] = [];
  for (const [start, end] of bookings) {
    events.push({ time: start, isEnd: false });
    events.push({ time: end, isEnd: true });
  }
  events.sort((a, b) => a.time - b.time || (a.isEnd ? 1 : -1));

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

  return -1;
}
```