import * as o from "react";
const c = ({
  open: t,
  onOpen: r,
  onClose: s
}) => {
  const e = o.useRef(typeof t == "boolean").current, [i, a] = o.useState(!1);
  o.useEffect(() => {
    if (e) {
      if (typeof t != "boolean")
        throw new Error("You must not mix controlling and uncontrolled mode for `open` prop");
      a(t);
    }
  }, [e, t]);
  const n = o.useCallback((f) => {
    e || a(f), f && r && r(), !f && s && s();
  }, [e, r, s]);
  return {
    isOpen: i,
    setIsOpen: n
  };
};
export {
  c as useOpenState
};
