@claritylabs/cl-sdk 3.0.21 → 3.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -9328,6 +9328,25 @@ function pageTitleFromText(text, fallback) {
9328
9328
  if (firstSentence && firstSentence.length <= 120) return firstSentence.replace(/[.]$/, "");
9329
9329
  return fallback;
9330
9330
  }
9331
+ function pageHeadingTitleFromText(text, fallback) {
9332
+ const normalized = cleanText(text, "");
9333
+ const headingText = normalized.replace(/^page\s+\d+\s*(?:\|\s*page\s*\|\s*page\s+\d+\s*\|?)?/i, "").slice(0, 700);
9334
+ const patterns = [
9335
+ /\bIMPORTANT NOTICE\s+[—-]\s+HOW TO REPORT A CLAIM\b/i,
9336
+ /\bPRIVACY NOTICE TO POLICYHOLDERS\b/i,
9337
+ /\bOFAC ADVISORY NOTICE\b/i,
9338
+ /\bTERRORISM RISK INSURANCE ACT\s*\(TRIA\)\s*DISCLOSURE AND REJECTION\b/i,
9339
+ /\bDECLARATIONS PAGE\b/i,
9340
+ /\bTECHNOLOGY ERRORS?\s*&\s*OMISSIONS AND CYBER LIABILITY INSURANCE POLICY\b/i,
9341
+ /\bTRADE OR ECONOMIC SANCTIONS LIMITATION\b/i,
9342
+ /\bFORMS? AND ENDORSEMENTS\b/i
9343
+ ];
9344
+ for (const pattern of patterns) {
9345
+ const match = headingText.match(pattern)?.[0];
9346
+ if (match) return cleanText(match, fallback);
9347
+ }
9348
+ return fallback;
9349
+ }
9331
9350
  function pageFormTypeFromText(text) {
9332
9351
  if (/\b(declarations?\s+page|declarations?\s+schedule)\b/i.test(text)) return "declarations";
9333
9352
  if (/\b(endorsement\s+(?:no\.?|number|#)|this endorsement changes the policy|[A-Z]{2,}-END\s+\d{2,})\b/i.test(text)) return "endorsement";
@@ -9591,7 +9610,7 @@ function applySemanticPageGrouping(sourceTree) {
9591
9610
  if (node.kind === "document" || node.kind === "page_group") return node;
9592
9611
  let nextNode = node;
9593
9612
  if (node.kind === "page" && /^page\s+\d+$/i.test(node.title)) {
9594
- const title = pageTitleFromText(sourceNodeText(node), node.title);
9613
+ const title = pageHeadingTitleFromText([node.textExcerpt, node.description].filter(Boolean).join(" "), node.title);
9595
9614
  if (title !== node.title) {
9596
9615
  nextNode = {
9597
9616
  ...node,