import * as i from "react";
import { jsx as f, Fragment as g } from "react/jsx-runtime";
function d(e, t) {
  if (typeof e == "function")
    return e(t);
  e != null && (e.current = t);
}
function m(...e) {
  return (t) => {
    let r = !1;
    const o = e.map((n) => {
      const l = d(n, t);
      return !r && typeof l == "function" && (r = !0), l;
    });
    if (r)
      return () => {
        for (let n = 0; n < o.length; n++) {
          const l = o[n];
          typeof l == "function" ? l() : d(e[n], null);
        }
      };
  };
}
function I(...e) {
  return i.useCallback(m(...e), e);
}
// @__NO_SIDE_EFFECTS__
function C(e) {
  const t = /* @__PURE__ */ b(e), r = i.forwardRef((o, n) => {
    const { children: l, ...a } = o, s = i.Children.toArray(l), c = s.find(R);
    if (c) {
      const u = c.props.children, S = s.map((p) => p === c ? i.Children.count(u) > 1 ? i.Children.only(null) : i.isValidElement(u) ? u.props.children : null : p);
      return /* @__PURE__ */ f(t, { ...a, ref: n, children: i.isValidElement(u) ? i.cloneElement(u, void 0, S) : null });
    }
    return /* @__PURE__ */ f(t, { ...a, ref: n, children: l });
  });
  return r.displayName = `${e}.Slot`, r;
}
var V = /* @__PURE__ */ C("Slot");
// @__NO_SIDE_EFFECTS__
function b(e) {
  const t = i.forwardRef((r, o) => {
    const { children: n, ...l } = r;
    if (i.isValidElement(n)) {
      const a = _(n), s = h(l, n.props);
      return n.type !== i.Fragment && (s.ref = o ? m(o, a) : a), i.cloneElement(n, s);
    }
    return i.Children.count(n) > 1 ? i.Children.only(null) : null;
  });
  return t.displayName = `${e}.SlotClone`, t;
}
var y = Symbol("radix.slottable");
// @__NO_SIDE_EFFECTS__
function E(e) {
  const t = ({ children: r }) => /* @__PURE__ */ f(g, { children: r });
  return t.displayName = `${e}.Slottable`, t.__radixId = y, t;
}
var v = /* @__PURE__ */ E("Slottable");
function R(e) {
  return i.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === y;
}
function h(e, t) {
  const r = { ...t };
  for (const o in t) {
    const n = e[o], l = t[o];
    /^on[A-Z]/.test(o) ? n && l ? r[o] = (...s) => {
      const c = l(...s);
      return n(...s), c;
    } : n && (r[o] = n) : o === "style" ? r[o] = { ...n, ...l } : o === "className" && (r[o] = [n, l].filter(Boolean).join(" "));
  }
  return { ...e, ...r };
}
function _(e) {
  let t = Object.getOwnPropertyDescriptor(e.props, "ref")?.get, r = t && "isReactWarning" in t && t.isReactWarning;
  return r ? e.ref : (t = Object.getOwnPropertyDescriptor(e, "ref")?.get, r = t && "isReactWarning" in t && t.isReactWarning, r ? e.props.ref : e.props.ref || e.ref);
}
export {
  V as S,
  v as a,
  C as c,
  I as u
};
//# sourceMappingURL=index-DhGWNzsz.mjs.map
