"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const React = require("react");
const PresenceContext = require("./dist-es-context-PresenceContext.cjs");
function usePresence(subscribe = true) {
  const context = React.useContext(PresenceContext.PresenceContext);
  if (context === null)
    return [true, null];
  const { isPresent, onExitComplete, register } = context;
  const id = React.useId();
  React.useEffect(() => {
    if (subscribe)
      register(id);
  }, [subscribe]);
  const safeToRemove = React.useCallback(() => subscribe && onExitComplete && onExitComplete(id), [id, onExitComplete, subscribe]);
  return !isPresent && onExitComplete ? [false, safeToRemove] : [true];
}
exports.usePresence = usePresence;
//# sourceMappingURL=dist-es-components-AnimatePresence-use-presence.cjs.map
