import { m as tt, h as et, a as Y, d as rt, o as at, E as nt, u as it, j as ot, p as st } from "./useOpenChangeComplete-RUbg6RBw.mjs";
import * as l from "react";
import * as j from "react-dom";
import { i as ut, a as lt, b as ct } from "./floating-ui.utils.dom-uiDUZc_y.mjs";
import { a as dt, b as ft } from "./detectBrowser-Bc7rk5fI.mjs";
import { jsx as R, jsxs as B } from "react/jsx-runtime";
const _t = "data-base-ui-click-trigger", bt = {
  clipPath: "inset(50%)",
  position: "fixed",
  top: 0,
  left: 0
}, q = "data-base-ui-focusable", Kt = "active", Jt = "selected", vt = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
function ht(r) {
  let t = r.activeElement;
  for (; t?.shadowRoot?.activeElement != null; )
    t = t.shadowRoot.activeElement;
  return t;
}
function pt(r, t) {
  if (!r || !t)
    return !1;
  const e = t.getRootNode?.();
  if (r.contains(t))
    return !0;
  if (e && lt(e)) {
    let a = t;
    for (; a; ) {
      if (r === a)
        return !0;
      a = a.parentNode || a.host;
    }
  }
  return !1;
}
function Zt(r) {
  return "composedPath" in r ? r.composedPath()[0] : r.target;
}
function $t(r, t) {
  if (t == null)
    return !1;
  if ("composedPath" in r)
    return r.composedPath().includes(t);
  const e = r;
  return e.target != null && t.contains(e.target);
}
function Xt(r) {
  return r.matches("html,body");
}
function F(r) {
  return r?.ownerDocument || document;
}
function gt(r) {
  return ut(r) && r.matches(vt);
}
function Ht(r) {
  return r ? r.getAttribute("role") === "combobox" && gt(r) : !1;
}
function Qt(r) {
  if (!r || dt)
    return !0;
  try {
    return r.matches(":focus-visible");
  } catch {
    return !0;
  }
}
function te(r) {
  return r ? r.hasAttribute(q) ? r : r.querySelector(`[${q}]`) || r : null;
}
/*!
* tabbable 6.3.0
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
*/
var mt = ["input:not([inert])", "select:not([inert])", "textarea:not([inert])", "a[href]:not([inert])", "button:not([inert])", "[tabindex]:not(slot):not([inert])", "audio[controls]:not([inert])", "video[controls]:not([inert])", '[contenteditable]:not([contenteditable="false"]):not([inert])', "details>summary:first-of-type:not([inert])", "details:not([inert])"], I = /* @__PURE__ */ mt.join(","), z = typeof Element > "u", y = z ? function() {
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, x = !z && Element.prototype.getRootNode ? function(r) {
  var t;
  return r == null || (t = r.getRootNode) === null || t === void 0 ? void 0 : t.call(r);
} : function(r) {
  return r?.ownerDocument;
}, T = function(t, e) {
  var a;
  e === void 0 && (e = !0);
  var n = t == null || (a = t.getAttribute) === null || a === void 0 ? void 0 : a.call(t, "inert"), s = n === "" || n === "true", o = s || e && t && T(t.parentNode);
  return o;
}, yt = function(t) {
  var e, a = t == null || (e = t.getAttribute) === null || e === void 0 ? void 0 : e.call(t, "contenteditable");
  return a === "" || a === "true";
}, W = function(t, e, a) {
  if (T(t))
    return [];
  var n = Array.prototype.slice.apply(t.querySelectorAll(I));
  return e && y.call(t, I) && n.unshift(t), n = n.filter(a), n;
}, w = function(t, e, a) {
  for (var n = [], s = Array.from(t); s.length; ) {
    var o = s.shift();
    if (!T(o, !1))
      if (o.tagName === "SLOT") {
        var u = o.assignedElements(), c = u.length ? u : o.children, i = w(c, !0, a);
        a.flatten ? n.push.apply(n, i) : n.push({
          scopeParent: o,
          candidates: i
        });
      } else {
        var d = y.call(o, I);
        d && a.filter(o) && (e || !t.includes(o)) && n.push(o);
        var f = o.shadowRoot || // check for an undisclosed shadow
        typeof a.getShadowRoot == "function" && a.getShadowRoot(o), h = !T(f, !1) && (!a.shadowRootFilter || a.shadowRootFilter(o));
        if (f && h) {
          var b = w(f === !0 ? o.children : f.children, !0, a);
          a.flatten ? n.push.apply(n, b) : n.push({
            scopeParent: o,
            candidates: b
          });
        } else
          s.unshift.apply(s, o.children);
      }
  }
  return n;
}, _ = function(t) {
  return !isNaN(parseInt(t.getAttribute("tabindex"), 10));
}, K = function(t) {
  if (!t)
    throw new Error("No node provided");
  return t.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName) || yt(t)) && !_(t) ? 0 : t.tabIndex;
}, St = function(t, e) {
  var a = K(t);
  return a < 0 && e && !_(t) ? 0 : a;
}, Et = function(t, e) {
  return t.tabIndex === e.tabIndex ? t.documentOrder - e.documentOrder : t.tabIndex - e.tabIndex;
}, J = function(t) {
  return t.tagName === "INPUT";
}, Tt = function(t) {
  return J(t) && t.type === "hidden";
}, Rt = function(t) {
  var e = t.tagName === "DETAILS" && Array.prototype.slice.apply(t.children).some(function(a) {
    return a.tagName === "SUMMARY";
  });
  return e;
}, It = function(t, e) {
  for (var a = 0; a < t.length; a++)
    if (t[a].checked && t[a].form === e)
      return t[a];
}, xt = function(t) {
  if (!t.name)
    return !0;
  var e = t.form || x(t), a = function(u) {
    return e.querySelectorAll('input[type="radio"][name="' + u + '"]');
  }, n;
  if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
    n = a(window.CSS.escape(t.name));
  else
    try {
      n = a(t.name);
    } catch (o) {
      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", o.message), !1;
    }
  var s = It(n, t.form);
  return !s || s === t;
}, wt = function(t) {
  return J(t) && t.type === "radio";
}, Ct = function(t) {
  return wt(t) && !xt(t);
}, Nt = function(t) {
  var e, a = t && x(t), n = (e = a) === null || e === void 0 ? void 0 : e.host, s = !1;
  if (a && a !== t) {
    var o, u, c;
    for (s = !!((o = n) !== null && o !== void 0 && (u = o.ownerDocument) !== null && u !== void 0 && u.contains(n) || t != null && (c = t.ownerDocument) !== null && c !== void 0 && c.contains(t)); !s && n; ) {
      var i, d, f;
      a = x(n), n = (i = a) === null || i === void 0 ? void 0 : i.host, s = !!((d = n) !== null && d !== void 0 && (f = d.ownerDocument) !== null && f !== void 0 && f.contains(n));
    }
  }
  return s;
}, G = function(t) {
  var e = t.getBoundingClientRect(), a = e.width, n = e.height;
  return a === 0 && n === 0;
}, At = function(t, e) {
  var a = e.displayCheck, n = e.getShadowRoot;
  if (a === "full-native" && "checkVisibility" in t) {
    var s = 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 !s;
  }
  if (getComputedStyle(t).visibility === "hidden")
    return !0;
  var o = y.call(t, "details>summary:first-of-type"), u = o ? t.parentElement : t;
  if (y.call(u, "details:not([open]) *"))
    return !0;
  if (!a || a === "full" || // full-native can run this branch when it falls through in case
  // Element#checkVisibility is unsupported
  a === "full-native" || a === "legacy-full") {
    if (typeof n == "function") {
      for (var c = t; t; ) {
        var i = t.parentElement, d = x(t);
        if (i && !i.shadowRoot && n(i) === !0)
          return G(t);
        t.assignedSlot ? t = t.assignedSlot : !i && d !== t.ownerDocument ? t = d.host : t = i;
      }
      t = c;
    }
    if (Nt(t))
      return !t.getClientRects().length;
    if (a !== "legacy-full")
      return !0;
  } else if (a === "non-zero-area")
    return G(t);
  return !1;
}, Ot = function(t) {
  if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))
    for (var e = t.parentElement; e; ) {
      if (e.tagName === "FIELDSET" && e.disabled) {
        for (var a = 0; a < e.children.length; a++) {
          var n = e.children.item(a);
          if (n.tagName === "LEGEND")
            return y.call(e, "fieldset[disabled] *") ? !0 : !n.contains(t);
        }
        return !0;
      }
      e = e.parentElement;
    }
  return !1;
}, A = function(t, e) {
  return !(e.disabled || // we must do an inert look up to filter out any elements inside an inert ancestor
  //  because we're limited in the type of selectors we can use in JSDom (see related
  //  note related to `candidateSelectors`)
  T(e) || Tt(e) || At(e, t) || // For a details element with a summary, the summary element gets the focus
  Rt(e) || Ot(e));
}, O = function(t, e) {
  return !(Ct(e) || K(e) < 0 || !A(t, e));
}, Pt = function(t) {
  var e = parseInt(t.getAttribute("tabindex"), 10);
  return !!(isNaN(e) || e >= 0);
}, Z = function(t) {
  var e = [], a = [];
  return t.forEach(function(n, s) {
    var o = !!n.scopeParent, u = o ? n.scopeParent : n, c = St(u, o), i = o ? Z(n.candidates) : u;
    c === 0 ? o ? e.push.apply(e, i) : e.push(u) : a.push({
      documentOrder: s,
      tabIndex: c,
      item: n,
      isScope: o,
      content: i
    });
  }), a.sort(Et).reduce(function(n, s) {
    return s.isScope ? n.push.apply(n, s.content) : n.push(s.content), n;
  }, []).concat(e);
}, $ = function(t, e) {
  e = e || {};
  var a;
  return e.getShadowRoot ? a = w([t], e.includeContainer, {
    filter: O.bind(null, e),
    flatten: !1,
    getShadowRoot: e.getShadowRoot,
    shadowRootFilter: Pt
  }) : a = W(t, e.includeContainer, O.bind(null, e)), Z(a);
}, ee = function(t, e) {
  e = e || {};
  var a;
  return e.getShadowRoot ? a = w([t], e.includeContainer, {
    filter: A.bind(null, e),
    flatten: !0,
    getShadowRoot: e.getShadowRoot
  }) : a = W(t, e.includeContainer, A.bind(null, e)), a;
}, re = function(t, e) {
  if (e = e || {}, !t)
    throw new Error("No node provided");
  return y.call(t, I) === !1 ? !1 : O(e, t);
};
const X = () => ({
  getShadowRoot: !0,
  displayCheck: (
    // JSDOM does not support the `tabbable` library. To solve this we can
    // check if `ResizeObserver` is a real function (not polyfilled), which
    // determines if the current environment is JSDOM-like.
    typeof ResizeObserver == "function" && ResizeObserver.toString().includes("[native code]") ? "full" : "none"
  )
});
function H(r, t) {
  const e = $(r, X()), a = e.length;
  if (a === 0)
    return;
  const n = ht(F(r)), s = e.indexOf(n), o = s === -1 ? t === 1 ? 0 : a - 1 : s + t;
  return e[o];
}
function Ft(r) {
  return H(F(r).body, 1) || r;
}
function Dt(r) {
  return H(F(r).body, -1) || r;
}
function N(r, t) {
  const e = t || r.currentTarget, a = r.relatedTarget;
  return !a || !pt(e, a);
}
function Lt(r) {
  $(r, X()).forEach((e) => {
    e.dataset.tabindex = e.getAttribute("tabindex") || "", e.setAttribute("tabindex", "-1");
  });
}
function U(r) {
  r.querySelectorAll("[data-tabindex]").forEach((e) => {
    const a = e.dataset.tabindex;
    delete e.dataset.tabindex, a ? e.setAttribute("tabindex", a) : e.removeAttribute("tabindex");
  });
}
function ae(r) {
  return r?.ownerDocument || document;
}
const E = 0;
class D {
  static create() {
    return new D();
  }
  currentId = E;
  /**
   * Executes `fn` after `delay`, clearing any previously scheduled call.
   */
  start(t, e) {
    this.clear(), this.currentId = setTimeout(() => {
      this.currentId = E, e();
    }, t);
  }
  isStarted() {
    return this.currentId !== E;
  }
  clear = () => {
    this.currentId !== E && (clearTimeout(this.currentId), this.currentId = E);
  };
  disposeEffect = () => this.clear;
}
function ne() {
  const r = tt(D.create).current;
  return et(r.disposeEffect), r;
}
function Mt(r) {
  return `data-base-ui-${r}`;
}
const kt = {
  clip: "rect(0 0 0 0)",
  overflow: "hidden",
  whiteSpace: "nowrap",
  position: "fixed",
  top: 0,
  left: 0,
  border: 0,
  padding: 0,
  width: 1,
  height: 1,
  margin: -1
}, P = /* @__PURE__ */ l.forwardRef(function(t, e) {
  const [a, n] = l.useState();
  return Y(() => {
    ft && n("button");
  }, []), /* @__PURE__ */ R("span", {
    ...t,
    ref: e,
    style: kt,
    "aria-hidden": a ? void 0 : !0,
    ...{
      tabIndex: 0,
      // Role is only for VoiceOver
      role: a
    },
    "data-base-ui-focus-guard": ""
  });
});
process.env.NODE_ENV !== "production" && (P.displayName = "FocusGuard");
const L = /* @__PURE__ */ l.createContext(null);
process.env.NODE_ENV !== "production" && (L.displayName = "PortalContext");
const Vt = () => l.useContext(L), Bt = Mt("portal");
function qt(r = {}) {
  const {
    ref: t,
    container: e,
    componentProps: a = nt,
    elementProps: n,
    elementState: s
  } = r, o = it(), c = Vt()?.portalNode, [i, d] = l.useState(null), [f, h] = l.useState(null), b = l.useRef(null);
  Y(() => {
    if (e === null) {
      b.current && (b.current = null, h(null), d(null));
      return;
    }
    if (o == null)
      return;
    const g = (e && (ct(e) ? e : e.current)) ?? c ?? document.body;
    if (g == null) {
      b.current && (b.current = null, h(null), d(null));
      return;
    }
    b.current !== g && (b.current = g, h(null), d(g));
  }, [e, c, o]);
  const S = ot("div", a, {
    ref: [t, h],
    state: s,
    props: [{
      id: o,
      [Bt]: ""
    }, n]
  });
  return {
    portalNode: f,
    portalSubtree: i && S ? /* @__PURE__ */ j.createPortal(S, i) : null
  };
}
const Gt = /* @__PURE__ */ l.forwardRef(function(t, e) {
  const {
    children: a,
    container: n,
    className: s,
    render: o,
    renderGuards: u,
    ...c
  } = t, {
    portalNode: i,
    portalSubtree: d
  } = qt({
    container: n,
    ref: e,
    componentProps: t,
    elementProps: c
  }), f = l.useRef(null), h = l.useRef(null), b = l.useRef(null), S = l.useRef(null), [v, g] = l.useState(null), M = v?.modal, k = v?.open, C = typeof u == "boolean" ? u : !!v && !v.modal && v.open && !!i;
  l.useEffect(() => {
    if (!i || M)
      return;
    function p(m) {
      i && N(m) && (m.type === "focusin" ? U : Lt)(i);
    }
    return i.addEventListener("focusin", p, !0), i.addEventListener("focusout", p, !0), () => {
      i.removeEventListener("focusin", p, !0), i.removeEventListener("focusout", p, !0);
    };
  }, [i, M]), l.useEffect(() => {
    !i || k || U(i);
  }, [k, i]);
  const Q = l.useMemo(() => ({
    beforeOutsideRef: f,
    afterOutsideRef: h,
    beforeInsideRef: b,
    afterInsideRef: S,
    portalNode: i,
    setFocusManagerState: g
  }), [i]);
  return /* @__PURE__ */ B(l.Fragment, {
    children: [d, /* @__PURE__ */ B(L.Provider, {
      value: Q,
      children: [C && i && /* @__PURE__ */ R(P, {
        "data-type": "outside",
        ref: f,
        onFocus: (p) => {
          if (N(p, i))
            b.current?.focus();
          else {
            const m = v ? v.domReference : null;
            Dt(m)?.focus();
          }
        }
      }), C && i && /* @__PURE__ */ R("span", {
        "aria-owns": i.id,
        style: bt
      }), i && /* @__PURE__ */ j.createPortal(a, i), C && i && /* @__PURE__ */ R(P, {
        "data-type": "outside",
        ref: h,
        onFocus: (p) => {
          if (N(p, i))
            S.current?.focus();
          else {
            const m = v ? v.domReference : null;
            Ft(m)?.focus(), v?.closeOnFocusOut && v?.onOpenChange(!1, rt(at, p.nativeEvent));
          }
        }
      })]
    })]
  });
});
process.env.NODE_ENV !== "production" && (Gt.displayName = "FloatingPortal");
function ie(r) {
  return st(19) ? r : r ? "true" : void 0;
}
export {
  Kt as A,
  _t as C,
  P as F,
  Jt as S,
  D as T,
  ht as a,
  F as b,
  pt as c,
  Ht as d,
  Vt as e,
  ne as f,
  Zt as g,
  te as h,
  ie as i,
  X as j,
  Mt as k,
  N as l,
  Qt as m,
  Ft as n,
  ae as o,
  Dt as p,
  re as q,
  ee as r,
  gt as s,
  $ as t,
  qt as u,
  kt as v,
  Xt as w,
  $t as x,
  q as y,
  Gt as z
};
//# sourceMappingURL=inertValue-Bif5Sqs6.mjs.map
