import { useLayoutEffect } from "react";
function AskCookbook({
  apiKey,
  alwaysOpen,
  noFastMode
}) {
  useLayoutEffect(() => {
    const rootEl = window?.document?.getElementById?.("__cookbook");
    if (!window?.document || !!rootEl)
      return;
    const el = window.document.createElement("div");
    el.id = "__cookbook";
    el.setAttribute("data-api-key", apiKey);
    if (alwaysOpen) {
      el.setAttribute("data-always-open", "");
    }
    if (noFastMode) {
      el.setAttribute("data-no-fast", "");
    }
    window.document.body.appendChild(el);
    const script = window.document.createElement("script");
    script.src = "https://cdn.jsdelivr.net/npm/@cookbookdev/docsbot/dist/standalone/index.cjs.js";
    script.defer = true;
    document.head.appendChild(script);
    return () => {
      window.document.body.removeChild(el);
      window.document.head.removeChild(script);
    };
  }, []);
  return null;
}
export {
  AskCookbook as default
};
