import { useRef as f, useEffect as l } from "react";
const h = (s, a) => {
  const t = f(null);
  return l(() => {
    var u;
    if (!s || !t.current) return;
    t.current.innerHTML = "", t.current.innerHTML = s;
    const c = t.current.getElementsByTagName("iframe");
    for (let r = 0; r < c.length; r++) {
      const e = c[r];
      e.setAttribute("width", "100%"), e.setAttribute("height", "100%"), e.style.width = "100%", e.style.height = "100%";
      const n = e.src;
      e.src = "", setTimeout(() => {
        e.src = n;
      }, 100);
    }
    const i = t.current.getElementsByTagName("script");
    for (let r = 0; r < i.length; r++) {
      const e = i[r], n = document.createElement("script");
      Array.from(e.attributes).forEach((o) => {
        n.setAttribute(o.name, o.value);
      }), n.innerHTML = e.innerHTML, (u = e.parentNode) == null || u.replaceChild(n, e);
    }
    return () => {
      t.current && (t.current.innerHTML = "");
    };
  }, [s, a]), t;
};
export {
  h as u
};
