/*!
* tabbable 6.4.0
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
*/
var C = ["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] *)"], h = /* @__PURE__ */ C.join(","), I = typeof Element > "u", d = I ? function() {
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, v = !I && 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;
}, b = 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 && (typeof t.closest == "function" ? t.closest("[inert]") : b(t.parentNode));
  return n;
}, E = function(t) {
  var e, r = t == null || (e = t.getAttribute) === null || e === void 0 ? void 0 : e.call(t, "contenteditable");
  return r === "" || r === "true";
}, R = function(t, e, r) {
  if (b(t))
    return [];
  var a = Array.prototype.slice.apply(t.querySelectorAll(h));
  return e && d.call(t, h) && 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 (!b(n, !1))
      if (n.tagName === "SLOT") {
        var c = n.assignedElements(), s = c.length ? c : n.children, u = g(s, !0, r);
        r.flatten ? a.push.apply(a, u) : a.push({
          scopeParent: n,
          candidates: u
        });
      } else {
        var o = d.call(n, h);
        o && r.filter(n) && (e || !t.includes(n)) && a.push(n);
        var f = n.shadowRoot || typeof r.getShadowRoot == "function" && r.getShadowRoot(n), N = !b(f, !1) && (!r.shadowRootFilter || r.shadowRootFilter(n));
        if (f && N) {
          var y = g(f === !0 ? n.children : f.children, !0, r);
          r.flatten ? a.push.apply(a, y) : a.push({
            scopeParent: n,
            candidates: y
          });
        } else
          l.unshift.apply(l, n.children);
      }
  }
  return a;
}, T = function(t) {
  return !isNaN(parseInt(t.getAttribute("tabindex"), 10));
}, m = function(t) {
  if (!t)
    throw new Error("No node provided");
  return t.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName) || E(t)) && !T(t) ? 0 : t.tabIndex;
}, x = function(t, e) {
  var r = m(t);
  return r < 0 && e && !T(t) ? 0 : r;
}, O = function(t, e) {
  return t.tabIndex === e.tabIndex ? t.documentOrder - e.documentOrder : t.tabIndex - e.tabIndex;
}, w = function(t) {
  return t.tagName === "INPUT";
}, k = function(t) {
  return w(t) && t.type === "hidden";
}, D = function(t) {
  var e = t.tagName === "DETAILS" && Array.prototype.slice.apply(t.children).some(function(r) {
    return r.tagName === "SUMMARY";
  });
  return e;
}, F = function(t, e) {
  for (var r = 0; r < t.length; r++)
    if (t[r].checked && t[r].form === e)
      return t[r];
}, M = function(t) {
  if (!t.name)
    return !0;
  var e = t.form || v(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 = F(a, t.form);
  return !l || l === t;
}, P = function(t) {
  return w(t) && t.type === "radio";
}, L = function(t) {
  return P(t) && !M(t);
}, V = function(t) {
  var e, r = t && v(t), a = (e = r) === null || e === void 0 ? void 0 : e.host, l = !1;
  if (r && r !== t) {
    var n, c, s;
    for (l = !!((n = a) !== null && n !== void 0 && (c = n.ownerDocument) !== null && c !== void 0 && c.contains(a) || t != null && (s = t.ownerDocument) !== null && s !== void 0 && s.contains(t)); !l && a; ) {
      var u, o, f;
      r = v(a), a = (u = r) === null || u === void 0 ? void 0 : u.host, l = !!((o = a) !== null && o !== void 0 && (f = o.ownerDocument) !== null && f !== void 0 && f.contains(a));
    }
  }
  return l;
}, p = function(t) {
  var e = t.getBoundingClientRect(), r = e.width, a = e.height;
  return r === 0 && a === 0;
}, B = function(t, e) {
  var r = e.displayCheck, a = e.getShadowRoot;
  if (r === "full-native" && "checkVisibility" in t) {
    var l = t.checkVisibility({
      checkOpacity: !1,
      opacityProperty: !1,
      contentVisibilityAuto: !0,
      visibilityProperty: !0,
      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" || r === "full-native" || r === "legacy-full") {
    if (typeof a == "function") {
      for (var s = t; t; ) {
        var u = t.parentElement, o = v(t);
        if (u && !u.shadowRoot && a(u) === !0)
          return p(t);
        t.assignedSlot ? t = t.assignedSlot : !u && o !== t.ownerDocument ? t = o.host : t = u;
      }
      t = s;
    }
    if (V(t))
      return !t.getClientRects().length;
    if (r !== "legacy-full")
      return !0;
  } else if (r === "non-zero-area")
    return p(t);
  return !1;
}, q = 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;
}, U = function(t, e) {
  return !(e.disabled || k(e) || B(e, t) || D(e) || q(e));
}, S = function(t, e) {
  return !(L(e) || m(e) < 0 || !U(t, e));
}, W = function(t) {
  var e = parseInt(t.getAttribute("tabindex"), 10);
  return !!(isNaN(e) || e >= 0);
}, A = function(t) {
  var e = [], r = [];
  return t.forEach(function(a, l) {
    var n = !!a.scopeParent, c = n ? a.scopeParent : a, s = x(c, n), u = n ? A(a.candidates) : c;
    s === 0 ? n ? e.push.apply(e, u) : e.push(c) : r.push({
      documentOrder: l,
      tabIndex: s,
      item: a,
      isScope: n,
      content: u
    });
  }), r.sort(O).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 = R(t, e.includeContainer, S.bind(null, e)), A(r);
};
export {
  Z as t
};
