import asyncio
import logging

log = logging.getLogger(__name__)


async def publish(topic: str, account_id: str, blocks: dict) -> None:
    """Thin wrapper to call API-layer publisher without circular imports."""
    try:
        # Lazy import to avoid circulars
        from ..api.v2.slack import publish as api_publish  # type: ignore

        await api_publish(topic, account_id, blocks, db=None)
    except Exception:
        log.exception("Slack publish failed topic=%s account=%s", topic, account_id)


def fire_and_forget(topic: str, account_id: str, blocks: dict) -> None:
    try:
        asyncio.create_task(publish(topic, account_id, blocks))
    except Exception:
        pass
