export function createMemoryAnchor(kind, id, label, path) {
    return { kind, id, label, path };
}
export function serializeMemoryAnchors(anchors) {
    return JSON.stringify(anchors);
}
export function parseMemoryAnchors(value) {
    if (!value)
        return [];
    try {
        const parsed = JSON.parse(value);
        if (!Array.isArray(parsed))
            return [];
        return parsed.flatMap((entry) => {
            if (typeof entry !== "object" || entry === null)
                return [];
            const record = entry;
            if (typeof record.kind !== "string" || typeof record.id !== "string" || typeof record.label !== "string") {
                return [];
            }
            return [
                {
                    kind: record.kind,
                    id: record.id,
                    label: record.label,
                    path: typeof record.path === "string" ? record.path : undefined,
                },
            ];
        });
    }
    catch {
        return [];
    }
}
//# sourceMappingURL=memory-anchors.js.map