import n from "react";
var p = "__wrap_b", u = "__wrap_o", y = typeof window > "u", f = y ? n.useEffect : n.useLayoutEffect, h = (a, r, e) => {
  e = e || document.querySelector(`[data-br="${a}"]`);
  let s = e.parentElement, i = (m) => e.style.maxWidth = m + "px";
  e.style.maxWidth = "";
  let t = s.clientWidth, l = s.clientHeight, o = t / 2 - 0.25, c = t + 0.5, d;
  if (t) {
    for (; o + 1 < c; ) d = Math.round((o + c) / 2), i(d), s.clientHeight === l ? c = d : o = d;
    i(c * r + t * (1 - r));
  }
  e.__wrap_o || (typeof ResizeObserver < "u" ? (e.__wrap_o = new ResizeObserver(() => {
    self.__wrap_b(0, +e.dataset.brr, e);
  })).observe(s) : process.env.NODE_ENV);
}, b = h.toString(), _ = (a, r = "") => n.createElement("script", { suppressHydrationWarning: !0, dangerouslySetInnerHTML: { __html: (a ? "" : `self.${p}=${b};`) + r } }), v = n.createContext(!1), w = ({ as: a = "span", ratio: r = 1, children: e, ...s }) => {
  let i = n.useId(), t = n.useRef(), l = n.useContext(v);
  return f(() => {
    t.current && (self[p] = h)(0, r, t.current);
  }, [e, r]), f(() => () => {
    if (!t.current) return;
    let o = t.current[u];
    !o || (o.disconnect(), delete t.current[u]);
  }, []), process.env.NODE_ENV === "development" && e && !Array.isArray(e) && typeof e == "object" && "type" in e && typeof e.type == "string" && e.type, n.createElement(n.Fragment, null, n.createElement(a, { ...s, "data-br": i, "data-brr": r, ref: t, style: { display: "inline-block", verticalAlign: "top", textDecoration: "inherit" }, suppressHydrationWarning: !0 }, e), _(l, `self.${p}("${i}",${r})`));
};
if (!y && process.env.NODE_ENV !== "production") {
  let a = document.querySelector("[data-next-hide-fouc]");
  if (a) {
    let r = (s) => {
      for (let i of s) for (let t of Array.from(i.removedNodes)) {
        if (t !== a) continue;
        e.disconnect();
        let l = document.querySelectorAll("[data-br]");
        for (let o of Array.from(l)) self[p](0, +o.dataset.brr, o);
      }
    }, e = new MutationObserver(r);
    e.observe(document.head, { childList: !0 });
  }
}
var E = w;
export {
  E as default
};
