/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

import { elementInViewport } from '../../utils/dom.js';
import '../../_chunks/dep-2e5d8948.js';
import 'lodash/isString';
import 'lodash/isFunction';
import 'lodash/isArray';
import '../../utils/easing.js';

function getScrollParent(element) {
  var style = window.getComputedStyle(element);
  var excludeStaticParent = style.position === "absolute";
  var overflowRegex = /(auto|scroll)/;
  if (style.position === "fixed") return document.body;
  for (var parent = element; parent.parentElement;) {
    parent = parent.parentElement;
    style = window.getComputedStyle(parent);
    if (excludeStaticParent && style.position === "static") continue;
    if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) return parent;
  }
  return document.body;
}
function scrollToParentVisibleArea(element) {
  var parent = getScrollParent(element);
  if (parent === document.body) return;
  if (elementInViewport(element, parent)) return;
  parent.scrollTop = element.offsetTop - parent.offsetTop;
}

export { getScrollParent, scrollToParentVisibleArea };
//# sourceMappingURL=getScrollParent.js.map
