from __future__ import annotations

import logging
import os
from typing import Any, Dict, Optional

logger = logging.getLogger(__name__)


def magento_sync_uses_master_catalog(options: Optional[Dict[str, Any]] = None) -> bool:
    """Magento publish always uses the master catalog integration."""
    if options is not None and options.get("use_master_catalog") is False:
        logger.warning(
            "use_master_catalog=false is ignored; Plytix ingest is no longer an active Magento source"
        )
    legacy = os.getenv("MAGENTO_SYNC_SOURCE", "master").strip().lower()
    if legacy == "plytix":
        logger.warning(
            "MAGENTO_SYNC_SOURCE=plytix is legacy and ignored; master catalog is always used"
        )
    return True


def default_magento_queue_options(**extra: Any) -> Dict[str, Any]:
    opts: Dict[str, Any] = {"use_master_catalog": True}
    opts.update(extra)
    return opts
