/**
 * VS Code / Cursor editor window title → workspace (repo folder) name only.
 * CDP title examples: `package-lock.json — CursorConnect - Cursor`, `CursorConnect - Cursor`.
 */
export function editorWindowRepoName(raw) {
    let t = raw.trim();
    if (!t)
        return t;
    t = t.replace(/\s*[-–—]\s*Cursor\s*$/i, '').trim();
    const parts = t.split(/\s+[—–-]\s+/).map((p) => p.trim()).filter(Boolean);
    if (parts.length >= 2) {
        const editorLabel = parts[0].replace(/^[●◦]\s*/, '').trim();
        if (looksLikeOpenEditorLabel(editorLabel)) {
            return parts[parts.length - 1];
        }
    }
    return t;
}
function looksLikeOpenEditorLabel(label) {
    if (!label)
        return false;
    if (/\.[a-z0-9]{1,12}$/i.test(label))
        return true;
    if (label.includes('/') || label.includes('\\'))
        return true;
    if (/^[●◦]/.test(label))
        return true;
    return false;
}
