const fileName_1 = "(@effect/core) _src/io/Schedule/operations/hourOfDay.ts";
import * as tsplus_module_1 from "@effect/core/io/Cause/errors";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/die";
import * as tsplus_module_3 from "@effect/core/io/Schedule/Interval";
import * as tsplus_module_4 from "@effect/core/io/Schedule/Decision";
import * as tsplus_module_5 from "@tsplus/stdlib/data/Tuple/make";
import * as tsplus_module_6 from "@effect/core/io/Effect/operations/succeedNow";
import { makeWithState } from "@effect/core/io/Schedule/operations/_internal/makeWithState";
import { beginningOfHour, endOfHour, nextHour } from "@effect/core/io/Schedule/operations/_internal/time";
/**
 * Cron-like schedule that recurs every specified `hour` of each day. It
 * triggers at zero minute of the hour. Producing a count of repeats: 0, 1, 2.
 *
 * NOTE: `hour` parameter is validated lazily. Must be in range 0...23.
 *
 * @tsplus static ets/Schedule hourOfDay
 */

export function hourOfDay(hour) {
  return makeWithState(0, (now, _, state) => {
    if (!Number.isInteger(hour) || hour < 0 || 23 < hour) {
      return tsplus_module_2.die(() => new tsplus_module_1.IllegalArgumentException(`Invalid argument in: hourOfDay(${hour}). Must be in range 0...23`), fileName_1 + ":19:24");
    }

    const hr = nextHour(now, hour);
    const start = Math.max(beginningOfHour(hr), now);
    const end = endOfHour(hr);
    const interval = tsplus_module_3.fromStartEndMillis(start, end);
    return tsplus_module_6.succeedNow(tsplus_module_5.make(state + 1, state, tsplus_module_4._continue(interval)), fileName_1 + ":29:29");
  });
}
//# sourceMappingURL=hourOfDay.mjs.map