"""市場情報 adapter 註冊表。"""

from services.market_intel.adapters.coupang_adapter import CoupangMarketAdapter
from services.market_intel.adapters.momo_adapter import MomoMarketAdapter
from services.market_intel.adapters.pchome_adapter import PChomeMarketAdapter
from services.market_intel.adapters.shopee_adapter import ShopeeMarketAdapter


ADAPTER_CLASSES = {
    "momo": MomoMarketAdapter,
    "pchome": PChomeMarketAdapter,
    "coupang": CoupangMarketAdapter,
    "shopee": ShopeeMarketAdapter,
}


def get_adapter(platform_code):
    adapter_class = ADAPTER_CLASSES.get((platform_code or "").lower())
    if not adapter_class:
        return None
    return adapter_class()


def get_adapter_registry():
    return {code: adapter_class() for code, adapter_class in ADAPTER_CLASSES.items()}


def get_adapter_summaries():
    return [adapter.summary() for adapter in get_adapter_registry().values()]
