import { useCallback, useRef } from "react";
var initialScrollWidth = -1;
var initialClientWidth = -1;
export default (function (parentRef, ref, target, callback, deps) {
  var prevScrollWidthRef = useRef(initialScrollWidth);
  var prevClientWidthRef = useRef(initialClientWidth);
  return useCallback(function () {
    if (!ref.current || !target.current || !parentRef || !parentRef.current) return;
    var width = document.body.clientWidth;
    var draggableTabs = ref.current;
    var draggableLeft = draggableTabs.getBoundingClientRect().left;
    var container = parentRef.current;
    var _container$getBoundin = container.getBoundingClientRect(),
      containerRight = _container$getBoundin.right,
      containerLeft = _container$getBoundin.left;
    var _target$current$getBo = target.current.getBoundingClientRect(),
      tabRight = _target$current$getBo.right,
      tabWidth = _target$current$getBo.width;
    if (prevScrollWidthRef.current === draggableTabs.scrollWidth && prevClientWidthRef.current === width) return;
    prevScrollWidthRef.current = draggableTabs.scrollWidth;
    prevClientWidthRef.current = width;
    var padRight = width - containerRight;
    if (tabRight < width - padRight && containerLeft + (draggableLeft - containerLeft) + (tabRight - draggableLeft) + padRight > width) return;
    if (tabRight >= containerRight) return callback(true);
    if (tabRight + tabWidth < containerRight) return callback(false);
  }, deps);
});