import p, { useState as s, useRef as i, useCallback as $, useEffect as y } from "react";
import { a as g } from "./SSRProvider-CQ9PmFV6.es.js";
const d = typeof document < "u" ? p.useLayoutEffect : () => {
};
function m(r) {
  let [e, f] = s(r), n = i(e), t = i(null), c = i(() => {
    if (!t.current) return;
    let o = t.current.next();
    if (o.done) {
      t.current = null;
      return;
    }
    n.current === o.value ? c.current() : f(o.value);
  });
  d(() => {
    n.current = e, t.current && c.current();
  });
  let u = $((o) => {
    t.current = o(n.current), c.current();
  }, [
    c
  ]);
  return [
    e,
    u
  ];
}
let x = !!(typeof window < "u" && window.document && window.document.createElement), l = /* @__PURE__ */ new Map(), a;
typeof FinalizationRegistry < "u" && (a = /* @__PURE__ */ new FinalizationRegistry((r) => {
  l.delete(r);
}));
function v(r) {
  let [e, f] = s(r), n = i(null), t = g(e), c = i(null);
  if (a && a.register(c, t), x) {
    const u = l.get(t);
    u && !u.includes(n) ? u.push(n) : l.set(t, [
      n
    ]);
  }
  return d(() => {
    let u = t;
    return () => {
      a && a.unregister(c), l.delete(u);
    };
  }, [
    t
  ]), y(() => {
    let u = n.current;
    return u && f(u), () => {
      u && (n.current = null);
    };
  }), t;
}
function w(r, e) {
  if (r === e) return r;
  let f = l.get(r);
  if (f)
    return f.forEach((t) => t.current = e), e;
  let n = l.get(e);
  return n ? (n.forEach((t) => t.current = r), r) : e;
}
function V(r = []) {
  let e = v(), [f, n] = m(e), t = $(() => {
    n(function* () {
      yield e, yield document.getElementById(e) ? e : void 0;
    });
  }, [
    e,
    n
  ]);
  return d(t, [
    e,
    t,
    ...r
  ]), f;
}
function h(...r) {
  return (...e) => {
    for (let f of r) typeof f == "function" && f(...e);
  };
}
function b(r) {
  var e, f, n = "";
  if (typeof r == "string" || typeof r == "number") n += r;
  else if (typeof r == "object") if (Array.isArray(r)) {
    var t = r.length;
    for (e = 0; e < t; e++) r[e] && (f = b(r[e])) && (n && (n += " "), n += f);
  } else for (f in r) r[f] && (n && (n += " "), n += f);
  return n;
}
function I() {
  for (var r, e, f = 0, n = "", t = arguments.length; f < t; f++) (r = arguments[f]) && (e = b(r)) && (n && (n += " "), n += e);
  return n;
}
function k(...r) {
  let e = {
    ...r[0]
  };
  for (let f = 1; f < r.length; f++) {
    let n = r[f];
    for (let t in n) {
      let c = e[t], u = n[t];
      typeof c == "function" && typeof u == "function" && // This is a lot faster than a regex.
      t[0] === "o" && t[1] === "n" && t.charCodeAt(2) >= /* 'A' */
      65 && t.charCodeAt(2) <= /* 'Z' */
      90 ? e[t] = h(c, u) : (t === "className" || t === "UNSAFE_className") && typeof c == "string" && typeof u == "string" ? e[t] = I(c, u) : t === "id" && c && u ? e.id = w(c, u) : e[t] = u !== void 0 ? u : c;
    }
  }
  return e;
}
export {
  k as $,
  v as a,
  d as b,
  V as c,
  h as d
};
//# sourceMappingURL=mergeProps-B-cqsBhL.es.js.map
