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