{"version":3,"file":"messageFocus.mjs","names":[],"sources":["../../../../src/components/MessageList/messageFocus.ts"],"sourcesContent":["/**\n * Shared by `MessageList` and `VirtualizedMessageList` to find a focused message (a deep-link or\n * quoted-reply jump, or jump-to-latest) and to decide when the reader has viewed it, so the two\n * lists start the highlight's dismissal countdown under the same rule.\n */\n\n/** `IntersectionObserver` thresholds that report the crossings `isMessageViewed` checks. */\nexport const MESSAGE_VIEWED_THRESHOLDS = [0, 0.5, 1];\n\n/**\n * A message counts as viewed when half of it is visible, or when its visible slice fills half the\n * viewport (a message taller than the viewport never reaches a ratio of 0.5).\n */\nexport const isMessageViewed = (entry: IntersectionObserverEntry, rootHeight: number) =>\n  entry.isIntersecting &&\n  (entry.intersectionRatio >= 0.5 ||\n    entry.intersectionRect.height >= (rootHeight || 1) * 0.5);\n\n/**\n * Finds the rendered item of a message by its `data-message-id`. The ID is compared as a string\n * rather than interpolated into a selector: a custom message ID may contain quotes or backslashes.\n */\nexport const findMessageElement = (\n  container: ParentNode,\n  messageId: string,\n): HTMLElement | null => {\n  for (const element of container.querySelectorAll<HTMLElement>('[data-message-id]')) {\n    if (element.getAttribute('data-message-id') === messageId) return element;\n  }\n  return null;\n};\n"],"mappings":";;;;;;;AAOA,IAAa,4BAA4B;CAAC;CAAG;CAAK;AAAC;;;;;AAMnD,IAAa,mBAAmB,OAAkC,eAChE,MAAM,mBACL,MAAM,qBAAqB,MAC1B,MAAM,iBAAiB,WAAW,cAAc,KAAK;;;;;AAMzD,IAAa,sBACX,WACA,cACuB;CACvB,KAAK,MAAM,WAAW,UAAU,iBAA8B,mBAAmB,GAC/E,IAAI,QAAQ,aAAa,iBAAiB,MAAM,WAAW,OAAO;CAEpE,OAAO;AACT"}