
from __future__ import annotations
from typing import Dict
from bs4 import BeautifulSoup
from shared.utils import normalize_text
from ..registry import extractor

@extractor
def ex_short_description(soup: BeautifulSoup, url: str) -> Dict:
    desc_short = None
    for sel in [".product.attribute.description .value", ".product.attribute.overview .value",
                "meta[name='description']", "meta[property='og:description']"]:
        el = soup.select_one(sel)
        if not el:
            continue
        desc_short = normalize_text(el.get_text() if el.name != "meta" else el.get("content"))
        if desc_short:
            break
    return {"description_short": desc_short}
