import '../contracts/danmaku.dart'; import 'danmaku_comment_merger.dart'; List processDanmakuComments( List comments, { required List blockedKeywords, required bool mergeDuplicates, }) { final visible = blockedKeywords.isEmpty ? comments : comments .where((c) => blockedKeywords.every((kw) => !c.text.contains(kw))) .toList(); final processed = mergeDuplicates ? mergeDuplicateDanmakuComments(visible) : List.of(visible); processed.sort((a, b) => a.time.compareTo(b.time)); return processed; } int lowerBoundByTime(List sortedByTime, double posSec) { var lo = 0; var hi = sortedByTime.length; while (lo < hi) { final mid = (lo + hi) >> 1; if (sortedByTime[mid].time < posSec) { lo = mid + 1; } else { hi = mid; } } return lo; }