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