import { o as E } from "./rolldown-runtime.js";
import { i as _ } from "./vendor/react.js";
function s() {
  return typeof window < "u";
}
function f(t) {
  return w(t) ? (t.nodeName || "").toLowerCase() : "#document";
}
function i(t) {
  var n;
  return (t == null || (n = t.ownerDocument) == null ? void 0 : n.defaultView) || window;
}
function L(t) {
  var n;
  return (n = (w(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : n.documentElement;
}
function w(t) {
  return s() ? t instanceof Node || t instanceof i(t).Node : !1;
}
function h(t) {
  return s() ? t instanceof Element || t instanceof i(t).Element : !1;
}
function g(t) {
  return s() ? t instanceof HTMLElement || t instanceof i(t).HTMLElement : !1;
}
function p(t) {
  return !s() || typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof i(t).ShadowRoot;
}
function y(t) {
  const { overflow: n, overflowX: r, overflowY: c, display: e } = b(t);
  return /auto|scroll|overlay|hidden|clip/.test(n + c + r) && e !== "inline" && e !== "contents";
}
function B(t) {
  return /^(table|td|th)$/.test(f(t));
}
function T(t) {
  try {
    if (t.matches(":popover-open")) return !0;
  } catch {
  }
  try {
    return t.matches(":modal");
  } catch {
    return !1;
  }
}
var C = /transform|translate|scale|rotate|perspective|filter/, D = /paint|layout|strict|content/, o = (t) => !!t && t !== "none", u;
function R(t) {
  const n = h(t) ? b(t) : t;
  return o(n.transform) || o(n.translate) || o(n.scale) || o(n.rotate) || o(n.perspective) || !k() && (o(n.backdropFilter) || o(n.filter)) || C.test(n.willChange || "") || D.test(n.contain || "");
}
function H(t) {
  let n = l(t);
  for (; g(n) && !S(n); ) {
    if (R(n)) return n;
    if (T(n)) return null;
    n = l(n);
  }
  return null;
}
function k() {
  return u == null && (u = typeof CSS < "u" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none")), u;
}
function S(t) {
  return /^(html|body|#document)$/.test(f(t));
}
function b(t) {
  return i(t).getComputedStyle(t);
}
function O(t) {
  return h(t) ? {
    scrollLeft: t.scrollLeft,
    scrollTop: t.scrollTop
  } : {
    scrollLeft: t.scrollX,
    scrollTop: t.scrollY
  };
}
function l(t) {
  if (f(t) === "html") return t;
  const n = t.assignedSlot || t.parentNode || p(t) && t.host || L(t);
  return p(n) ? n.host : n;
}
function v(t) {
  const n = l(t);
  return S(n) ? t.ownerDocument ? t.ownerDocument.body : t.body : g(n) && y(n) ? n : v(n);
}
function m(t, n, r) {
  var c;
  n === void 0 && (n = []), r === void 0 && (r = !0);
  const e = v(t), N = e === ((c = t.ownerDocument) == null ? void 0 : c.body), a = i(e);
  if (N) {
    const d = M(a);
    return n.concat(a, a.visualViewport || [], y(e) ? e : [], d && r ? m(d) : []);
  } else return n.concat(e, m(e, [], r));
}
function M(t) {
  return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null;
}
var W = /* @__PURE__ */ E(_()), V = { ...W };
export {
  p as _,
  M as a,
  k as b,
  m as c,
  R as d,
  h as f,
  y as g,
  w as h,
  L as i,
  l,
  S as m,
  b as n,
  f as o,
  g as p,
  H as r,
  O as s,
  V as t,
  i as u,
  B as v,
  T as y
};

//# sourceMappingURL=safeReact.js.map