{"version":3,"file":"util.capture-relevant-comments.cjs","sources":["../../../../src/rules/limit-single-line-comments/util.capture-relevant-comments.ts"],"sourcesContent":["import type { TSESLint, TSESTree } from \"@typescript-eslint/utils\";\n\nimport type { Context } from \"../../typings.context.js\";\nimport { isLineOverflowing } from \"../../utils/is-line-overflowing.js\";\nimport { isCommentOnOwnLine } from \"../../utils/is-on-own-line.js\";\nimport { isSemanticComment } from \"../../utils/is-semantic-comment.js\";\n\nimport type { CommentBlock } from \"./typings.block.js\";\nimport { mergeComments } from \"./util.merge-comments.js\";\n\nexport function captureRelevantCommentsIntoBlock(\n  sourceCode: TSESLint.SourceCode,\n  comments: TSESTree.LineComment[],\n  startIndex: number,\n  context: Context,\n): CommentBlock {\n  let comment = comments[startIndex];\n\n  if (!comment) {\n    return { mergedComment: undefined, startIndex, endIndex: startIndex };\n  }\n\n  let endIndex = startIndex;\n\n  for (let i = startIndex + 1; i < comments.length; i++) {\n    const nextComment = comments[i];\n\n    if (\n      (context.mode === \"overflow-only\" &&\n        !isLineOverflowing(comment.value, context)) ||\n      !nextComment ||\n      nextComment.value.trim() === \"\" ||\n      nextComment.loc?.start.line !== (comment.loc?.end.line ?? 0) + 1 ||\n      isSemanticComment(nextComment, context.semanticComments) ||\n      !isCommentOnOwnLine(sourceCode, nextComment)\n    ) {\n      break;\n    }\n\n    comment = mergeComments(comment, nextComment);\n    endIndex = i;\n  }\n\n  return { mergedComment: comment, startIndex, endIndex };\n}\n"],"names":["isLineOverflowing","isSemanticComment","isCommentOnOwnLine","mergeComments"],"mappings":";;;;;;;AAUO,SAAS,gCACd,CAAA,UAAA,EACA,QACA,EAAA,UAAA,EACA,OACc,EAAA;AACd,EAAI,IAAA,OAAA,GAAU,SAAS,UAAU,CAAA,CAAA;AAEjC,EAAA,IAAI,CAAC,OAAS,EAAA;AACZ,IAAA,OAAO,EAAE,aAAA,EAAe,KAAW,CAAA,EAAA,UAAA,EAAY,UAAU,UAAW,EAAA,CAAA;AAAA,GACtE;AAEA,EAAA,IAAI,QAAW,GAAA,UAAA,CAAA;AAEf,EAAA,KAAA,IAAS,IAAI,UAAa,GAAA,CAAA,EAAG,CAAI,GAAA,QAAA,CAAS,QAAQ,CAAK,EAAA,EAAA;AACrD,IAAM,MAAA,WAAA,GAAc,SAAS,CAAC,CAAA,CAAA;AAE9B,IAAA,IACG,OAAQ,CAAA,IAAA,KAAS,eAChB,IAAA,CAACA,oCAAkB,OAAQ,CAAA,KAAA,EAAO,OAAO,CAAA,IAC3C,CAAC,WACD,IAAA,WAAA,CAAY,KAAM,CAAA,IAAA,OAAW,EAC7B,IAAA,WAAA,CAAY,GAAK,EAAA,KAAA,CAAM,UAAU,OAAQ,CAAA,GAAA,EAAK,GAAI,CAAA,IAAA,IAAQ,KAAK,CAC/D,IAAAC,mCAAA,CAAkB,WAAa,EAAA,OAAA,CAAQ,gBAAgB,CACvD,IAAA,CAACC,8BAAmB,CAAA,UAAA,EAAY,WAAW,CAC3C,EAAA;AACA,MAAA,MAAA;AAAA,KACF;AAEA,IAAU,OAAA,GAAAC,gCAAA,CAAc,SAAS,WAAW,CAAA,CAAA;AAC5C,IAAW,QAAA,GAAA,CAAA,CAAA;AAAA,GACb;AAEA,EAAA,OAAO,EAAE,aAAA,EAAe,OAAS,EAAA,UAAA,EAAY,QAAS,EAAA,CAAA;AACxD;;;;"}