import { add, subtract } from "../../position";
import withViewportDisplacement from "../../with-scroll-change/with-viewport-displacement";

const getClientRectFromPageBorderBoxCenter = ({ pageBorderBoxCenter, draggable, viewport }) => {
  const withoutPageScrollChange = withViewportDisplacement(viewport, pageBorderBoxCenter);
  const offset = subtract(withoutPageScrollChange, draggable.page.borderBox.center);
  return add(draggable.client.borderBox.center, offset);
};

export default getClientRectFromPageBorderBoxCenter;
