function getScrollableParent(element) {
  var parent = element.parentElement;
  while (parent) {
    var _window$getComputedSt = window.getComputedStyle(parent),
      overflow = _window$getComputedSt.overflow,
      overflowY = _window$getComputedSt.overflowY;
    var isScrollable = (overflow === 'auto' || overflow === 'scroll' || overflowY === 'auto' || overflowY === 'scroll') && parent.scrollHeight > parent.clientHeight;
    if (isScrollable) {
      return parent;
    }
    parent = parent.parentElement;
  }
  return null;
}
export function scrollIntoView(index, element) {
  var scrollableParent = getScrollableParent(element);
  if (!scrollableParent) {
    return;
  }
  if (index === 0) {
    scrollableParent.scrollTop = 0;
    return;
  }
  var offsetTop = element.offsetTop,
    clientHeight = element.clientHeight;
  var scrollTop = scrollableParent.scrollTop,
    parentHeight = scrollableParent.clientHeight;
  if (offsetTop < scrollTop) {
    scrollableParent.scrollTop = offsetTop;
  } else if (offsetTop + clientHeight > scrollTop + parentHeight) {
    scrollableParent.scrollTop = offsetTop - parentHeight + clientHeight;
  }
}
//# sourceMappingURL=scrollIntoView.js.map