// src/runtime/on-content-ready.ts
function onContentReady(callback) {
  const { readyState } = document;
  if (readyState === "complete" || readyState === "interactive") {
    setTimeout(callback, 0);
  } else {
    document.addEventListener("DOMContentLoaded", callback);
  }
}

// src/runtime/with-cookie-consent.ts
function withCookieConsent(callback) {
  function hasCookie(name) {
    return document.cookie.split("; ").some((row) => row.startsWith(`${name}=`));
  }
  onContentReady(() => {
    if (!document.querySelector(".cookie-warning")) {
      callback();
      return;
    }
    if (!navigator.cookieEnabled) {
      return;
    }
    if (hasCookie("doc-cookie-consent")) {
      callback();
      return;
    }
    const registeredUrl = window.location.href;
    window.addEventListener(
      "doc-cookie-consent",
      () => {
        if (window.location.href === registeredUrl) {
          callback();
        }
      },
      {
        once: true
      }
    );
  });
}

// src/runtime/bootstrap.ts
window.withCookieConsent = withCookieConsent;
