/**
 * Converter for "text" message type.
 */

import type { ConvertedPayload, MessageConvertContext } from './types'
import { safeParse } from './utils'

export async function convertText(ctx: MessageConvertContext): Promise<ConvertedPayload | null> {
  const parsed = safeParse(ctx.rawContent) as { text?: string } | undefined
  const text = parsed?.text ?? ''
  if (!text.trim()) return null
  return { text }
}
