function appendUnique(target, value) {
    const normalized = typeof value === 'string' ? value.trim() : '';
    if (!normalized)
        return;
    if (target.includes(normalized))
        return;
    target.push(normalized);
}
export function resolveRetainedVersionIds(params) {
    const retainCount = Math.max(1, params.retainCount ?? 2);
    const keep = [];
    appendUnique(keep, params.currentVersionId);
    appendUnique(keep, params.previousVersionId);
    for (const versionId of params.orderedVersionIdsNewestFirst) {
        appendUnique(keep, versionId);
        if (keep.length >= retainCount) {
            break;
        }
    }
    const prune = params.orderedVersionIdsNewestFirst.filter((versionId) => !keep.includes(versionId));
    return { keep, prune };
}
//# sourceMappingURL=retentionPolicy.js.map