"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var summarizer_exports = {};
__export(summarizer_exports, {
  summarizeSection: () => summarizeSection
});
module.exports = __toCommonJS(summarizer_exports);
function summarizeSection(content, title, strategy) {
  if (strategy === "off") return null;
  return extractFirstSentence(content, title);
}
function extractFirstSentence(content, title) {
  const lines = content.split("\n");
  const bodyLines = lines.filter((l) => {
    const trimmed = l.trim();
    if (trimmed === "") return false;
    if (trimmed.startsWith("#") || trimmed.startsWith("=") || trimmed.startsWith("*")) {
      if (/^[#=*]+\s/.test(trimmed)) return false;
    }
    if (trimmed.startsWith("```") || trimmed.startsWith("~~~")) return false;
    if (/^[=-]+\s*$/.test(trimmed)) return false;
    if (/^<\/?(?:h[1-6]|div|section|article|nav|header|footer)[^>]*>$/i.test(trimmed)) return false;
    if (trimmed.toLowerCase() === title.toLowerCase()) return false;
    return true;
  });
  if (bodyLines.length === 0) return null;
  const firstLine = bodyLines[0].trim();
  const cleaned = firstLine.replace(/^[-*•]\s+/, "").replace(/^\d+\.\s+/, "");
  const sentenceEnd = cleaned.search(/[.!?]\s|[.!?]$/);
  if (sentenceEnd > 0 && sentenceEnd < 200) {
    return cleaned.slice(0, sentenceEnd + 1).trim();
  }
  return cleaned.length > 200 ? cleaned.slice(0, 200) + "\u2026" : cleaned;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  summarizeSection
});
//# sourceMappingURL=summarizer.js.map
