"""PChome 市場活動 read-only adapter skeleton。"""

from services.market_intel.adapters.base import (
    AdapterSafetyPolicy,
    CampaignSource,
    MarketIntelAdapter,
)


class PChomeMarketAdapter(MarketIntelAdapter):
    platform_code = "pchome"
    platform_name = "PChome 24h"
    base_url = "https://24h.pchome.com.tw"
    campaign_url_keywords = (
        "24h.pchome.com.tw",
        "/activity",
        "/campaign",
        "/region/",
        "promo",
        "event",
    )
    campaign_text_keywords = (
        "pchome",
        "24h",
        "活動",
        "優惠",
        "限時",
        "品牌日",
        "特價",
        "折扣",
    )
    safety_policy = AdapterSafetyPolicy(
        request_interval_sec=1.5,
        timeout_sec=20,
        max_pages_per_run=8,
    )

    def campaign_sources(self):
        return (
            CampaignSource(
                source_key="pchome_home",
                name="PChome 24h 首頁活動入口",
                url="https://24h.pchome.com.tw/",
                campaign_type="homepage_campaign",
                notes="可作為活動 banner / 分類入口 discovery 起點。",
            ),
            CampaignSource(
                source_key="pchome_region_beauty",
                name="PChome 美妝保養館別入口",
                url="https://24h.pchome.com.tw/region/DDAB",
                campaign_type="category_sale",
                notes="延續既有 PChome crawler 的 region page 低成本入口。",
            ),
        )
