"use client";
import { useState as r } from "react";
import { calculateFocusTarget as l } from "./helpers/calculateFocusTarget.js";
import { getNextFocus as T } from "./helpers/getNextFocus.js";
function S(c, o, F, a, f) {
  const { autoFocus: i } = c, [d, m] = r(), n = l(o.days, F, a || (() => !1), d), [s, t] = r(i ? n : void 0);
  return {
    isFocusTarget: (u) => !!n?.isEqualTo(u),
    setFocused: t,
    focused: s,
    blur: () => {
      m(s), t(void 0);
    },
    moveFocus: (u, g) => {
      if (!s)
        return;
      const e = T(u, g, s, o.navStart, o.navEnd, c, f);
      e && (o.goToDay(e), t(e));
    }
  };
}
export {
  S as useFocus
};
