import { useRef as l, useContext as S, useEffect as v } from "react";
import { MotionConfigContext as p } from "../context/MotionConfigContext.es.js";
import { useUnmountEffect as E } from "../utils/use-unmount-effect.es.js";
import { usePointerEvent as d } from "../events/use-pointer-event.es.js";
import { PanSession as g } from "./PanSession.es.js";
function D(t) {
  var e = t.onPan, a = t.onPanStart, o = t.onPanEnd, i = t.onPanSessionStart, u = t.visualElement, f = e || a || o || i, n = l(null), P = S(p).transformPagePoint, s = {
    onSessionStart: i,
    onStart: a,
    onMove: e,
    onEnd: function(r, c) {
      n.current = null, o && o(r, c);
    }
  };
  v(function() {
    n.current !== null && n.current.updateHandlers(s);
  });
  function m(r) {
    n.current = new g(r, s, {
      transformPagePoint: P
    });
  }
  d(u, "pointerdown", f && m), E(function() {
    return n.current && n.current.end();
  });
}
export {
  D as usePanGesture
};
//# sourceMappingURL=use-pan-gesture.es.js.map
