var p = function(r) {
  return r.tagName === "TEXTAREA";
}, w = function(r, e) {
  var t = window.getComputedStyle(r);
  return (
    // not-not-scrollable
    t[e] !== "hidden" && // contains scroll inside self
    !(t.overflowY === t.overflowX && !p(r) && t[e] === "visible")
  );
}, y = function(r) {
  return w(r, "overflowY");
}, H = function(r) {
  return w(r, "overflowX");
}, L = function(r, e) {
  var t = e;
  do {
    typeof ShadowRoot < "u" && t instanceof ShadowRoot && (t = t.host);
    var o = g(r, t);
    if (o) {
      var n = C(r, t), a = n[1], i = n[2];
      if (a > i)
        return !0;
    }
    t = t.parentNode;
  } while (t && t !== document.body);
  return !1;
}, B = function(r) {
  var e = r.scrollTop, t = r.scrollHeight, o = r.clientHeight;
  return [
    e,
    t,
    o
  ];
}, V = function(r) {
  var e = r.scrollLeft, t = r.scrollWidth, o = r.clientWidth;
  return [
    e,
    t,
    o
  ];
}, g = function(r, e) {
  return r === "v" ? y(e) : H(e);
}, C = function(r, e) {
  return r === "v" ? B(e) : V(e);
}, W = function(r, e) {
  return r === "h" && e === "rtl" ? -1 : 1;
}, N = function(r, e, t, o, n) {
  var a = W(r, window.getComputedStyle(e).direction), i = a * o, l = t.target, d = e.contains(l), c = !1, f = i > 0, s = 0, h = 0;
  do {
    var u = C(r, l), v = u[0], b = u[1], m = u[2], S = b - m - a * v;
    (v || S) && g(r, l) && (s += S, h += v), l = l.parentNode;
  } while (
    // portaled content
    !d && l !== document.body || // self content
    d && (e.contains(l) || e === l)
  );
  return (f && (s === 0 || !n) || !f && (h === 0 || !n)) && (c = !0), c;
};
export {
  N as handleScroll,
  L as locationCouldBeScrolled
};
