import type { Attachment } from 'stream-chat'

/**
 * True when an attachment is a link preview (OG card) rather than media:
 * either Stream's native `link` type, or a non-empty (trimmed) `og_scrape_url`
 * with no `asset_url`. A whitespace-only `og_scrape_url` is not a link.
 */
export function isLinkAttachment(a: Attachment): boolean {
  return a.type === 'link' || (!!a.og_scrape_url?.trim() && !a.asset_url)
}
