def extract_citation_spans(text: str) -> dict[str, list[Tuple[int, int]]]:
    """
    Extract citation IDs with their positions in the text.

    Args:
        text: The text to search for citations. If None, returns an empty dict.

    Returns:
        Dictionary mapping citation IDs to lists of (start, end) position tuples,
        where start is the position of the opening bracket and end is the position
        just after the closing bracket.
    """
    # Handle None or empty input
    if text is None or text == "":
        return {}

    # Use the same pattern as the original extract_citations
    CITATION_PATTERN = re.compile(r"\[([A-Za-z0-9]{7,8})\]")

    citation_spans: dict = {}

    for match in CITATION_PATTERN.finditer(text):
        sid = match.group(1)
        start = match.start()
        end = match.end()

        if sid not in citation_spans:
            citation_spans[sid] = []

        # Add the position span
        citation_spans[sid].append((start, end))

    return citation_spans

    Extract citation IDs with their positions in the text.

    Args:
        text: The text to search for citations. If None, returns an empty dict.

    Returns:
        Dictionary mapping citation IDs to lists of (start, end) position tuples,
        where start is the position of the opening bracket and end is the position
        just after the closing bracket.
    
py/core/utils/__init__.py