/**
 * saas-admin blueprint · wiring seam for `@platform-modules/mail`.
 *
 * Adapter-minimalism (CLAUDE.md §4): wrap a capture adapter in createMail. The host injects a real
 * provider adapter (resend/ses/…); the blueprint proves the seam — createMail validates the message
 * at the trust boundary (malformed addresses never reach the adapter) then delegates to send. The
 * capture array lets the composition test assert a notification was actually emitted past the gate.
 */
import { createMail, type MailAdapter, type MailMessage } from '@platform-modules/mail'

export type CaptureMail = {
  mail: ReturnType<typeof createMail>
  sent: MailMessage[]
}

export function createCaptureMail(): CaptureMail {
  const sent: MailMessage[] = []
  const adapter: MailAdapter = {
    async send(msg) {
      sent.push(msg)
      return { id: `cap-${sent.length}`, provider: 'capture' }
    },
  }
  return { mail: createMail(adapter), sent }
}
