"""Provider factory — the only place that knows which class serves a channel.

To add a new job board (Indeed, Monster, Foundit, Shine, Glassdoor, …):
  1. create indeed.py with `class IndeedIntegration(JobBoardIntegration)`
  2. add one line to _REGISTRY below
No business logic changes.
"""

from .base import JobBoardIntegration, IntegrationError
from .linkedin import LinkedInIntegration
from .naukri import NaukriIntegration
from .career_portal import CareerPortalIntegration
from .social_sharing import WhatsAppIntegration, SMSIntegration, TelegramIntegration

_REGISTRY: dict[str, type[JobBoardIntegration]] = {
    "LINKEDIN": LinkedInIntegration,
    "NAUKRI": NaukriIntegration,
    "CAREER_PORTAL": CareerPortalIntegration,
    "WHATSAPP": WhatsAppIntegration,
    "SMS": SMSIntegration,
    "TELEGRAM": TelegramIntegration,
}


def get_integration(channel: str) -> JobBoardIntegration:
    """Return the provider instance for a channel. Raise IntegrationError if unknown."""
    cls = _REGISTRY.get((channel or "").upper())
    if cls is None:
        raise IntegrationError(f"No integration configured for channel '{channel}'")
    return cls()


def supported_channels() -> list[str]:
    return list(_REGISTRY.keys())
