import * as tsplus_module_1 from "@tsplus/stdlib/service/Tag";
import { constFalse } from "@tsplus/stdlib/data/Function";
export const ClockSym = /*#__PURE__*/Symbol.for("@effect/core/io/Clock");
export const Clock = {
  $: {},
  Scheduler: {},
  Tag: /*#__PURE__*/tsplus_module_1.Tag()
};
/**
 * @tsplus static ets/Clock/Ops MAX_TIMER_MILLIS
 */

const MAX_TIMER_MILLIS_1 = 2 ** 31 - 1;
export const MAX_TIMER_MILLIS = MAX_TIMER_MILLIS_1;
/**
 * @tsplus static ets/Clock/Scheduler/Ops globalScheduler
 */

export const globalScheduler = {
  unsafeSchedule(task, duration) {
    // If the duration is greater than the value allowable by the JS timer
    // functions, treat the value as an infinite duration
    if (duration.millis > MAX_TIMER_MILLIS_1) {
      return constFalse;
    }

    let completed = false;
    const handle = setTimeout(() => {
      completed = true;
      task();
    }, duration.millis);
    return () => {
      clearTimeout(handle);
      return !completed;
    };
  }

};
//# sourceMappingURL=definition.mjs.map