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