import { useRef as y, useEffect as c } from "react";
import { useFormContext as S, useWatch as f } from "react-hook-form";
import { shallow as m } from "zustand/shallow";
import { useStepper as K } from "../useStepper/index.js";
function x() {
  const { trigger: t, getValues: i } = S(), a = y(!1), n = f({ name: "statusLoad" }), { initialStepKey: p, initialStepKeyApplied: r, applyInitialStepKey: l } = K(
    (e) => ({
      initialStepKey: e.initialStepKey,
      initialStepKeyApplied: e.initialStepKeyApplied,
      applyInitialStepKey: e.actions.applyInitialStepKey
    }),
    m
  );
  c(() => {
    if (n !== "ready" || !p || r || a.current)
      return;
    a.current = !0, (async () => {
      const s = async (o) => o.length === 0 ? !0 : t(o), u = i();
      await l(s, u);
    })();
  }, [
    n,
    p,
    r,
    l,
    t,
    i
  ]);
}
export {
  x as useInitialStepKey
};
