/*!
* tabbable 6.4.0
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
*/
var E = ["input:not([inert]):not([inert] *)", "select:not([inert]):not([inert] *)", "textarea:not([inert]):not([inert] *)", "a[href]:not([inert]):not([inert] *)", "button:not([inert]):not([inert] *)", "[tabindex]:not(slot):not([inert]):not([inert] *)", "audio[controls]:not([inert]):not([inert] *)", "video[controls]:not([inert]):not([inert] *)", '[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)', "details>summary:first-of-type:not([inert]):not([inert] *)", "details:not([inert]):not([inert] *)"], v = /* @__PURE__ */ E.join(","), T = typeof Element > "u", d = T ? function() {
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, b = !T && Element.prototype.getRootNode ? function(i) {
  var t;
  return i == null || (t = i.getRootNode) === null || t === void 0 ? void 0 : t.call(i);
} : function(i) {
  return i == null ? void 0 : i.ownerDocument;
}, h = function(t, e) {
  var r;
  e === void 0 && (e = !0);
  var a = t == null || (r = t.getAttribute) === null || r === void 0 ? void 0 : r.call(t, "inert"), l = a === "" || a === "true", n = l || e && t && // closest does not exist on shadow roots, so we fall back to a manual
  // lookup upward, in case it is not defined.
  (typeof t.closest == "function" ? t.closest("[inert]") : h(t.parentNode));
  return n;
}, x = function(t) {
  var e, r = t == null || (e = t.getAttribute) === null || e === void 0 ? void 0 : e.call(t, "contenteditable");
  return r === "" || r === "true";
}, I = function(t, e, r) {
  if (h(t))
    return [];
  var a = Array.prototype.slice.apply(t.querySelectorAll(v));
  return e && d.call(t, v) && a.unshift(t), a = a.filter(r), a;
}, g = function(t, e, r) {
  for (var a = [], l = Array.from(t); l.length; ) {
    var n = l.shift();
    if (!h(n, !1))
      if (n.tagName === "SLOT") {
        var c = n.assignedElements(), o = c.length ? c : n.children, u = g(o, !0, r);
        r.flatten ? a.push.apply(a, u) : a.push({
          scopeParent: n,
          candidates: u
        });
      } else {
        var s = d.call(n, v);
        s && r.filter(n) && (e || !t.includes(n)) && a.push(n);
        var f = n.shadowRoot || // check for an undisclosed shadow
        typeof r.getShadowRoot == "function" && r.getShadowRoot(n), A = !h(f, !1) && (!r.shadowRootFilter || r.shadowRootFilter(n));
        if (f && A) {
          var p = g(f === !0 ? n.children : f.children, !0, r);
          r.flatten ? a.push.apply(a, p) : a.push({
            scopeParent: n,
            candidates: p
          });
        } else
          l.unshift.apply(l, n.children);
      }
  }
  return a;
}, m = function(t) {
  return !isNaN(parseInt(t.getAttribute("tabindex"), 10));
}, R = function(t) {
  if (!t)
    throw new Error("No node provided");
  return t.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName) || x(t)) && !m(t) ? 0 : t.tabIndex;
}, O = function(t, e) {
  var r = R(t);
  return r < 0 && e && !m(t) ? 0 : r;
}, k = function(t, e) {
  return t.tabIndex === e.tabIndex ? t.documentOrder - e.documentOrder : t.tabIndex - e.tabIndex;
}, C = function(t) {
  return t.tagName === "INPUT";
}, D = function(t) {
  return C(t) && t.type === "hidden";
}, F = function(t) {
  var e = t.tagName === "DETAILS" && Array.prototype.slice.apply(t.children).some(function(r) {
    return r.tagName === "SUMMARY";
  });
  return e;
}, M = function(t, e) {
  for (var r = 0; r < t.length; r++)
    if (t[r].checked && t[r].form === e)
      return t[r];
}, P = function(t) {
  if (!t.name)
    return !0;
  var e = t.form || b(t), r = function(c) {
    return e.querySelectorAll('input[type="radio"][name="' + c + '"]');
  }, a;
  if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
    a = r(window.CSS.escape(t.name));
  else
    try {
      a = r(t.name);
    } catch (n) {
      return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", n.message), !1;
    }
  var l = M(a, t.form);
  return !l || l === t;
}, L = function(t) {
  return C(t) && t.type === "radio";
}, V = function(t) {
  return L(t) && !P(t);
}, B = function(t) {
  var e, r = t && b(t), a = (e = r) === null || e === void 0 ? void 0 : e.host, l = !1;
  if (r && r !== t) {
    var n, c, o;
    for (l = !!((n = a) !== null && n !== void 0 && (c = n.ownerDocument) !== null && c !== void 0 && c.contains(a) || t != null && (o = t.ownerDocument) !== null && o !== void 0 && o.contains(t)); !l && a; ) {
      var u, s, f;
      r = b(a), a = (u = r) === null || u === void 0 ? void 0 : u.host, l = !!((s = a) !== null && s !== void 0 && (f = s.ownerDocument) !== null && f !== void 0 && f.contains(a));
    }
  }
  return l;
}, w = function(t) {
  var e = t.getBoundingClientRect(), r = e.width, a = e.height;
  return r === 0 && a === 0;
}, q = function(t, e) {
  var r = e.displayCheck, a = e.getShadowRoot;
  if (r === "full-native" && "checkVisibility" in t) {
    var l = t.checkVisibility({
      // Checking opacity might be desirable for some use cases, but natively,
      // opacity zero elements _are_ focusable and tabbable.
      checkOpacity: !1,
      opacityProperty: !1,
      contentVisibilityAuto: !0,
      visibilityProperty: !0,
      // This is an alias for `visibilityProperty`. Contemporary browsers
      // support both. However, this alias has wider browser support (Chrome
      // >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
      // we include it anyway.
      checkVisibilityCSS: !0
    });
    return !l;
  }
  if (getComputedStyle(t).visibility === "hidden")
    return !0;
  var n = d.call(t, "details>summary:first-of-type"), c = n ? t.parentElement : t;
  if (d.call(c, "details:not([open]) *"))
    return !0;
  if (!r || r === "full" || // full-native can run this branch when it falls through in case
  // Element#checkVisibility is unsupported
  r === "full-native" || r === "legacy-full") {
    if (typeof a == "function") {
      for (var o = t; t; ) {
        var u = t.parentElement, s = b(t);
        if (u && !u.shadowRoot && a(u) === !0)
          return w(t);
        t.assignedSlot ? t = t.assignedSlot : !u && s !== t.ownerDocument ? t = s.host : t = u;
      }
      t = o;
    }
    if (B(t))
      return !t.getClientRects().length;
    if (r !== "legacy-full")
      return !0;
  } else if (r === "non-zero-area")
    return w(t);
  return !1;
}, U = function(t) {
  if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))
    for (var e = t.parentElement; e; ) {
      if (e.tagName === "FIELDSET" && e.disabled) {
        for (var r = 0; r < e.children.length; r++) {
          var a = e.children.item(r);
          if (a.tagName === "LEGEND")
            return d.call(e, "fieldset[disabled] *") ? !0 : !a.contains(t);
        }
        return !0;
      }
      e = e.parentElement;
    }
  return !1;
}, y = function(t, e) {
  return !(e.disabled || D(e) || q(e, t) || // For a details element with a summary, the summary element gets the focus
  F(e) || U(e));
}, S = function(t, e) {
  return !(V(e) || R(e) < 0 || !y(t, e));
}, W = function(t) {
  var e = parseInt(t.getAttribute("tabindex"), 10);
  return !!(isNaN(e) || e >= 0);
}, N = function(t) {
  var e = [], r = [];
  return t.forEach(function(a, l) {
    var n = !!a.scopeParent, c = n ? a.scopeParent : a, o = O(c, n), u = n ? N(a.candidates) : c;
    o === 0 ? n ? e.push.apply(e, u) : e.push(c) : r.push({
      documentOrder: l,
      tabIndex: o,
      item: a,
      isScope: n,
      content: u
    });
  }), r.sort(k).reduce(function(a, l) {
    return l.isScope ? a.push.apply(a, l.content) : a.push(l.content), a;
  }, []).concat(e);
}, Z = function(t, e) {
  e = e || {};
  var r;
  return e.getShadowRoot ? r = g([t], e.includeContainer, {
    filter: S.bind(null, e),
    flatten: !1,
    getShadowRoot: e.getShadowRoot,
    shadowRootFilter: W
  }) : r = I(t, e.includeContainer, S.bind(null, e)), N(r);
}, j = function(t, e) {
  e = e || {};
  var r;
  return e.getShadowRoot ? r = g([t], e.includeContainer, {
    filter: y.bind(null, e),
    flatten: !0,
    getShadowRoot: e.getShadowRoot
  }) : r = I(t, e.includeContainer, y.bind(null, e)), r;
}, z = function(t, e) {
  if (e = e || {}, !t)
    throw new Error("No node provided");
  return d.call(t, v) === !1 ? !1 : S(e, t);
};
export {
  j as focusable,
  R as getTabIndex,
  z as isTabbable,
  Z as tabbable
};
