/**
 * Memory recall helpers — reference/link deduplication and filename sanitisation
 * used by MemoryEngine during recall, network-graph construction, and vault writes.
 */
export function dedupeReferences(references) {
    const seen = new Set();
    const result = [];
    for (const reference of references) {
        const key = `${reference.type}:${reference.id}`;
        if (seen.has(key))
            continue;
        seen.add(key);
        result.push(reference);
    }
    return result;
}
export function dedupeLinks(links) {
    const seen = new Set();
    const result = [];
    for (const link of links) {
        const key = `${link.source}:${link.target}:${link.type}`;
        if (seen.has(key))
            continue;
        seen.add(key);
        result.push(link);
    }
    return result;
}
export function sanitizeFileName(value) {
    return value
        .trim()
        .replace(/[^a-z0-9._-]+/gi, '-')
        .replace(/-+/g, '-')
        .replace(/^-|-$/g, '')
        .slice(0, 120) || 'memory';
}
