import { a, c as o, i } from "./floating-ui.utils.dom-jr2suqy2.js";
import { a as u } from "./detectBrowser-Dn2N72k1.js";
const n = "data-base-ui-focusable", h = "active", E = "selected", c = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])", m = "ArrowLeft", A = "ArrowRight", R = "ArrowUp", T = "ArrowDown";
function g(t) {
  let e = t.activeElement;
  for (; e?.shadowRoot?.activeElement != null; )
    e = e.shadowRoot.activeElement;
  return e;
}
function f(t, e) {
  if (!t || !e)
    return !1;
  const r = e.getRootNode?.();
  if (t.contains(e))
    return !0;
  if (r && o(r)) {
    let s = e;
    for (; s; ) {
      if (t === s)
        return !0;
      s = s.parentNode || s.host;
    }
  }
  return !1;
}
function p(t, e) {
  if (!a(t))
    return !1;
  const r = t;
  if (e.hasElement(r))
    return !r.hasAttribute("data-trigger-disabled");
  for (const [, s] of e.entries())
    if (f(s, r))
      return !s.hasAttribute("data-trigger-disabled");
  return !1;
}
function w(t) {
  return "composedPath" in t ? t.composedPath()[0] : t.target;
}
function _(t, e) {
  if (e == null)
    return !1;
  if ("composedPath" in t)
    return t.composedPath().includes(e);
  const r = t;
  return r.target != null && e.contains(r.target);
}
function O(t) {
  return t.matches("html,body");
}
function l(t) {
  return i(t) && t.matches(c);
}
function L(t) {
  return t ? t.getAttribute("role") === "combobox" && l(t) : !1;
}
function S(t) {
  if (!t || u)
    return !0;
  try {
    return t.matches(":focus-visible");
  } catch {
    return !0;
  }
}
function y(t) {
  return t ? t.hasAttribute(n) ? t : t.querySelector(`[${n}]`) || t : null;
}
export {
  R as A,
  n as F,
  E as S,
  c as T,
  g as a,
  w as b,
  f as c,
  l as d,
  T as e,
  m as f,
  y as g,
  A as h,
  p as i,
  L as j,
  _ as k,
  O as l,
  S as m,
  h as n
};
