import * as o from "react";
import { composeRefs as u } from "../../../../../@radix-ui_react-compose-refs@1.1.0_@types_react@18.3.3_react@18.3.0-canary-3d9b20132-20240124/node_modules/@radix-ui/react-compose-refs/dist/index.js";
import { j as c } from "../../../../../../../_virtual/jsx-runtime.js";
var d = o.forwardRef((e, n) => {
  const { children: r, ...t } = e, l = o.Children.toArray(r), i = l.find(g);
  if (i) {
    const s = i.props.children, a = l.map((p) => p === i ? o.Children.count(s) > 1 ? o.Children.only(null) : o.isValidElement(s) ? s.props.children : null : p);
    return /* @__PURE__ */ c.jsx(f, { ...t, ref: n, children: o.isValidElement(s) ? o.cloneElement(s, void 0, a) : null });
  }
  return /* @__PURE__ */ c.jsx(f, { ...t, ref: n, children: r });
});
d.displayName = "Slot";
var f = o.forwardRef((e, n) => {
  const { children: r, ...t } = e;
  if (o.isValidElement(r)) {
    const l = h(r);
    return o.cloneElement(r, {
      ...y(t, r.props),
      // @ts-ignore
      ref: n ? u(n, l) : l
    });
  }
  return o.Children.count(r) > 1 ? o.Children.only(null) : null;
});
f.displayName = "SlotClone";
var m = ({ children: e }) => /* @__PURE__ */ c.jsx(c.Fragment, { children: e });
function g(e) {
  return o.isValidElement(e) && e.type === m;
}
function y(e, n) {
  const r = { ...n };
  for (const t in n) {
    const l = e[t], i = n[t];
    /^on[A-Z]/.test(t) ? l && i ? r[t] = (...a) => {
      i(...a), l(...a);
    } : l && (r[t] = l) : t === "style" ? r[t] = { ...l, ...i } : t === "className" && (r[t] = [l, i].filter(Boolean).join(" "));
  }
  return { ...e, ...r };
}
function h(e) {
  let n = Object.getOwnPropertyDescriptor(e.props, "ref")?.get, r = n && "isReactWarning" in n && n.isReactWarning;
  return r ? e.ref : (n = Object.getOwnPropertyDescriptor(e, "ref")?.get, r = n && "isReactWarning" in n && n.isReactWarning, r ? e.props.ref : e.props.ref || e.ref);
}
export {
  d as Slot,
  m as Slottable
};
//# sourceMappingURL=index.js.map
