import p from "../node_modules/ahooks/es/useUpdateLayoutEffect/index.mjs";
import l from "./useEvent.mjs";
import g from "./useState.mjs";
function s(t) {
  return t !== void 0;
}
function S(t, m) {
  const { defaultValue: n, value: e, onChange: v, postState: a } = m || {}, [u, f] = g(() => s(e) ? e : s(n) ? typeof n == "function" ? n() : n : typeof t == "function" ? t() : t), o = e !== void 0 ? e : u, d = a ? a(o) : o, V = l(v), [i, h] = g([o]);
  p(() => {
    const r = i[0];
    u !== r && V(u, r);
  }, [i]), p(() => {
    s(e) || f(e);
  }, [e]);
  const C = l((r, c) => {
    f(r, c), h([o], c);
  });
  return [d, C];
}
export {
  S as default
};
