const SHORT_SHA_LENGTH = 7;
export function shortSha(value, length = SHORT_SHA_LENGTH) {
    const trimmed = (value ?? "").trim();
    if (!trimmed)
        return "unknown";
    return trimmed.slice(0, Math.min(length, trimmed.length));
}
export function changesetIdForLocal(baseSha, headSha) {
    return `${shortSha(baseSha)}..${shortSha(headSha)}`;
}
export function changesetIdForGithub(owner, repo, number, headSha) {
    return `github:${owner.trim()}/${repo.trim()}#${String(number).trim()}:${headSha ? shortSha(headSha) : "unknown"}`;
}
export function stableSlug(value) {
    return value
        .trim()
        .replace(/\\/g, "/")
        .replace(/[^a-zA-Z0-9._/-]+/g, "-")
        .replace(/\/+/g, "/")
        .replace(/^-+|-+$/g, "")
        .replace(/\//g, "__")
        .slice(0, 96) || "item";
}
export function walkthroughCardId(phaseId, title, index = 0) {
    return `${phaseId}-${stableSlug(title).toLowerCase()}-${index + 1}`;
}
export function diffBlockIdForFile(filePath, index = 0) {
    return `block:${index + 1}:${stableSlug(filePath)}`;
}
export function hunkIdForBlock(blockId, hunkIndex) {
    return `${blockId}:h${hunkIndex}`;
}
export function lineIdForHunk(blockId, hunkIndex, lineIndex) {
    return `${blockId}:h${hunkIndex}:l${lineIndex}`;
}
//# sourceMappingURL=ids.js.map