import { MIN_SCROLL_SIZE, scrollSizeParametersNames } from "../ScrollContainer.constants";
export var getScrollSizeParams = function getScrollSizeParams(inner, axis) {
  var _scrollSizeParameters = scrollSizeParametersNames[axis],
    offset = _scrollSizeParameters.offset,
    size = _scrollSizeParameters.size,
    pos = _scrollSizeParameters.pos;
  var contentSize = inner[size];
  var scrollOffset = inner[pos];
  var containerSize = inner[offset];
  var scrollActive = containerSize < contentSize;
  var scrollSize = 0;
  var scrollPos = 0;
  if (scrollActive) {
    scrollSize = Math.max(containerSize / contentSize * containerSize, MIN_SCROLL_SIZE);
    scrollPos = scrollOffset / (contentSize - containerSize) * (containerSize - scrollSize);

    // Convert pixels to percentages
    scrollSize = containerSize && 100 / containerSize * scrollSize;
    scrollPos = containerSize && 100 / containerSize * scrollPos;
  }
  return {
    scrollActive: scrollActive,
    scrollSize: scrollSize,
    scrollPos: scrollPos
  };
};
export var getScrollYOffset = function getScrollYOffset(element, container) {
  var elementTopOffset = element.offsetTop;
  if (container.scrollTop > elementTopOffset) {
    return elementTopOffset;
  }
  var offset = elementTopOffset + element.scrollHeight - container.offsetHeight;
  if (container.scrollTop < offset) {
    return offset;
  }
  return container.scrollTop;
};
export var convertScrollbarXScrollState = function convertScrollbarXScrollState(state) {
  var scrollBarState = {
    begin: 'left',
    end: 'right',
    middle: 'scroll'
  };
  return scrollBarState[state];
};
export var convertScrollbarYScrollState = function convertScrollbarYScrollState(state) {
  var scrollBarState = {
    begin: 'top',
    end: 'bottom',
    middle: 'scroll'
  };
  return scrollBarState[state];
};