import { $ as y, b as m } from "./mergeProps-B-cqsBhL.es.js";
import { $ as b } from "./useObjectRef-CaJ5pgjX.es.js";
import p, { useMemo as i, useContext as x, useState as S, useRef as h, useCallback as C } from "react";
function v(...e) {
  return e.length === 1 && e[0] ? e[0] : (l) => {
    let t = !1;
    const f = e.map((n) => {
      const a = d(n, l);
      return t || (t = typeof a == "function"), a;
    });
    if (t) return () => {
      f.forEach((n, a) => {
        typeof n == "function" ? n() : d(e[a], null);
      });
    };
  };
}
function d(e, l) {
  if (typeof e == "function") return e(l);
  e != null && (e.current = l);
}
const N = /* @__PURE__ */ Symbol("default");
function j({ values: e, children: l }) {
  for (let [t, f] of e)
    l = /* @__PURE__ */ p.createElement(t.Provider, {
      value: f
    }, l);
  return l;
}
function k(e) {
  let { className: l, style: t, children: f, defaultClassName: n, defaultChildren: a, defaultStyle: u, values: r } = e;
  return i(() => {
    let s, c, o;
    return typeof l == "function" ? s = l({
      ...r,
      defaultClassName: n
    }) : s = l, typeof t == "function" ? c = t({
      ...r,
      defaultStyle: u || {}
    }) : c = t, typeof f == "function" ? o = f({
      ...r,
      defaultChildren: a
    }) : f == null ? o = a : o = f, {
      className: s ?? n,
      style: c || u ? {
        ...u,
        ...c
      } : void 0,
      children: o ?? a,
      "data-rac": ""
    };
  }, [
    l,
    t,
    f,
    n,
    a,
    u,
    r
  ]);
}
function R(e, l) {
  let t = x(e);
  if (l === null)
    return null;
  if (t && typeof t == "object" && "slots" in t && t.slots) {
    let f = l || N;
    if (!t.slots[f]) {
      let n = new Intl.ListFormat().format(Object.keys(t.slots).map((u) => `"${u}"`)), a = l ? `Invalid slot "${l}".` : "A slot prop is required.";
      throw new Error(`${a} Valid slot names are ${n}.`);
    }
    return t.slots[f];
  }
  return t;
}
function I(e, l, t) {
  let f = R(t, e.slot) || {}, { ref: n, ...a } = f, u = b(i(() => v(l, n), [
    l,
    n
  ])), r = y(a, e);
  return "style" in a && a.style && "style" in e && e.style && (typeof a.style == "function" || typeof e.style == "function" ? r.style = (s) => {
    let c = typeof a.style == "function" ? a.style(s) : a.style, o = {
      ...s.defaultStyle,
      ...c
    }, $ = typeof e.style == "function" ? e.style({
      ...s,
      defaultStyle: o
    }) : e.style;
    return {
      ...o,
      ...$
    };
  } : r.style = {
    ...a.style,
    ...e.style
  }), [
    r,
    u
  ];
}
function M(e = !0) {
  let [l, t] = S(e), f = h(!1), n = C((a) => {
    f.current = !0, t(!!a);
  }, []);
  return m(() => {
    f.current || t(!1);
  }, []), [
    n,
    l
  ];
}
function P(e) {
  const l = /^(data-.*)$/;
  let t = {};
  for (const f in e) l.test(f) || (t[f] = e[f]);
  return t;
}
export {
  I as $,
  k as a,
  M as b,
  R as c,
  v as d,
  j as e,
  P as f,
  N as g
};
//# sourceMappingURL=utils-CrjF8U_E.es.js.map
