import * as c from "react";
import { useRef as u } from "react";
import { transitionEndName as a, animationEndName as f } from "../util/motion.mjs";
const d = function(e) {
  var r = u(), i = u(e);
  i.current = e;
  var t = c.useCallback(function(n) {
    i.current(n);
  }, []);
  function o(n) {
    n && (n.removeEventListener(a, t), n.removeEventListener(f, t));
  }
  function s(n) {
    r.current && r.current !== n && o(r.current), n && n !== r.current && (n.addEventListener(a, t), n.addEventListener(f, t), r.current = n);
  }
  return c.useEffect(function() {
    return function() {
      o(r.current);
    };
  }, []), [s, o];
};
export {
  d as default
};
