from __future__ import annotations
from rapidfuzz import fuzz

def dedupe_strings(items: list[str], threshold: int = 90) -> list[str]:
    """
    Keep first occurrence; merge near-duplicates based on fuzzy similarity.
    """
    kept: list[str] = []
    for s in items:
        s_norm = " ".join(s.split()).strip()
        if not s_norm:
            continue
        is_dup = False
        for k in kept:
            if fuzz.ratio(s_norm.lower(), k.lower()) >= threshold:
                is_dup = True
                break
        if not is_dup:
            kept.append(s_norm)
    return kept
