from typing import Set, Optional
from ..slugs import canonical_html_slug
from shared.config import config

_blocked: Set[str] = set()
_mtime: Optional[float] = None

def _norm(slug: str) -> str:
    slug = (slug or "").strip().strip("/").lower()
    if slug.startswith("product/"):
        slug = slug.split("/", 1)[1]
    return canonical_html_slug(slug)

def is_product_blocked(slug: str) -> bool:
    return _norm(slug) in config()["blacklist"]["product"]
