import { useLocation } from "react-router";
function getTransitionDirection(from, to) {
  const fromPath = (from || "/").split("?")[0].split("#")[0];
  const toPath = (to || "/").split("?")[0].split("#")[0];
  const normalizedFrom = fromPath.replace(/\/$/, "") || "/";
  const normalizedTo = toPath.replace(/\/$/, "") || "/";
  if (normalizedFrom === normalizedTo) {
    return "none";
  }
  const fromSegments = normalizedFrom.split("/").filter(Boolean);
  const toSegments = normalizedTo.split("/").filter(Boolean);
  const fromLength = fromSegments.length;
  const toLength = toSegments.length;
  const minLength = Math.min(fromLength, toLength);
  let allSegmentsMatch = true;
  for (let i = 0; i < minLength; i++) {
    if (fromSegments[i] !== toSegments[i]) {
      allSegmentsMatch = false;
      break;
    }
  }
  if (allSegmentsMatch) {
    if (toLength > fromLength) {
      return "push";
    } else if (toLength < fromLength) {
      return "pop";
    }
  }
  return "none";
}
function useTransitionDirection(to, dontAnimate = false) {
  const location = useLocation();
  if (dontAnimate) return "none";
  return getTransitionDirection(location.pathname, to);
}
export {
  getTransitionDirection,
  useTransitionDirection
};
