const SPA_APP_ROOT_SELECTORS = [
  "#__next",
  "#root",
  "[data-reactroot]",
  "[data-v-app]"
].join(", ");
const SPA_CONTENT_SELECTORS = [
  ".vp-doc",
  ".VPDoc",
  ".theme-doc-markdown",
  ".markdown-body",
  ".prose",
  '[role="main"]'
].join(", ");
function measure(el) {
  if (!el) return 0;
  const text = el.innerText ?? "";
  return text.trim().length;
}
function countBlocks(el, selector) {
  if (!el) return 0;
  try {
    return el.querySelectorAll(selector).length;
  } catch {
    return 0;
  }
}
function isHydrated(doc) {
  const article = doc.querySelector("article");
  if (measure(article) > 500) {
    const pCount = countBlocks(article, "p");
    const codeCount = countBlocks(article, "pre, code");
    if (pCount >= 3 || codeCount >= 2 || pCount + codeCount >= 4) return true;
  }
  const main = doc.querySelector("main");
  if (measure(main) > 500) {
    const pCount = countBlocks(main, "p");
    const codeCount = countBlocks(main, "pre, code");
    if (pCount >= 3 || codeCount >= 2 || pCount + codeCount >= 4) return true;
  }
  const contentEl = doc.querySelector(SPA_CONTENT_SELECTORS);
  if (measure(contentEl) > 500) {
    const pCount = countBlocks(contentEl, "p");
    const codeCount = countBlocks(contentEl, "pre, code");
    if (pCount >= 3 || codeCount >= 2 || pCount + codeCount >= 4) return true;
  }
  const appRoot = doc.querySelector(SPA_APP_ROOT_SELECTORS);
  if (measure(appRoot) > 1200) {
    const pCount = countBlocks(appRoot, "p");
    const codeCount = countBlocks(appRoot, "pre, code");
    if (pCount >= 3 || codeCount >= 2 || pCount + codeCount >= 4) return true;
  }
  const paragraphs = doc.querySelectorAll("p");
  let pText = 0;
  const limit = Math.min(paragraphs.length, 12);
  for (let i = 0; i < limit; i++) {
    pText += (paragraphs[i].innerText ?? "").length;
  }
  return pText > 700;
}
const HYDRATION_PROBE_SOURCE = `(() => {
  const SPA_APP_ROOT_SELECTORS = ${JSON.stringify(SPA_APP_ROOT_SELECTORS)};
  const SPA_CONTENT_SELECTORS = ${JSON.stringify(SPA_CONTENT_SELECTORS)};
  const measure = (el) => el ? ((el.innerText || '').trim().length) : 0;
  const countBlocks = (el, sel) => {
    if (!el) return 0;
    try { return el.querySelectorAll(sel).length; } catch { return 0; }
  };

  const article = document.querySelector('article');
  if (measure(article) > 500) {
    const p = countBlocks(article, 'p');
    const c = countBlocks(article, 'pre, code');
    if (p >= 3 || c >= 2 || p + c >= 4) return true;
  }

  const main = document.querySelector('main');
  if (measure(main) > 500) {
    const p = countBlocks(main, 'p');
    const c = countBlocks(main, 'pre, code');
    if (p >= 3 || c >= 2 || p + c >= 4) return true;
  }

  const contentEl = document.querySelector(SPA_CONTENT_SELECTORS);
  if (measure(contentEl) > 500) {
    const p = countBlocks(contentEl, 'p');
    const c = countBlocks(contentEl, 'pre, code');
    if (p >= 3 || c >= 2 || p + c >= 4) return true;
  }

  const appRoot = document.querySelector(SPA_APP_ROOT_SELECTORS);
  if (measure(appRoot) > 1200) {
    const p = countBlocks(appRoot, 'p');
    const c = countBlocks(appRoot, 'pre, code');
    if (p >= 3 || c >= 2 || p + c >= 4) return true;
  }

  const paragraphs = document.querySelectorAll('p');
  let pText = 0;
  const limit = Math.min(paragraphs.length, 12);
  for (let i = 0; i < limit; i++) {
    pText += ((paragraphs[i].innerText || '')).length;
  }
  return pText > 700;
})()`;
export {
  HYDRATION_PROBE_SOURCE,
  isHydrated
};
//# sourceMappingURL=hydration-probe.js.map