var u = Object.defineProperty;
var n = (r, t, e) => t in r ? u(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
var i = (r, t, e) => n(r, typeof t != "symbol" ? t + "" : t, e);
import { useRefWithInit as o } from "./useRefWithInit.js";
import { useOnMount as a } from "./useOnMount.js";
const s = 0;
class c {
  constructor() {
    i(this, "currentId", s);
    i(this, "clear", () => {
      this.currentId !== s && (clearTimeout(this.currentId), this.currentId = s);
    });
    i(this, "disposeEffect", () => this.clear);
  }
  static create() {
    return new c();
  }
  /**
   * Executes `fn` after `delay`, clearing any previously scheduled call.
   */
  start(t, e) {
    this.clear(), this.currentId = setTimeout(() => {
      this.currentId = s, e();
    }, t);
  }
  isStarted() {
    return this.currentId !== s;
  }
}
function m() {
  const r = o(c.create).current;
  return a(r.disposeEffect), r;
}
export {
  c as Timeout,
  m as useTimeout
};
