import { ContextGraphBuilder } from './toGraph.js';
import { fromGraph } from './fromGraph.js';
export class ContextGraphMapper {
    registry;
    nodeIdentityMap = new WeakMap();
    constructor(registry) {
        this.registry = registry;
    }
    builder;
    applyEvent(event, tokenCalculator) {
        if (!this.builder) {
            this.builder = new ContextGraphBuilder(tokenCalculator, this.nodeIdentityMap);
        }
        if (event.type === 'CLEAR') {
            this.builder.clear();
            return [];
        }
        if (event.type === 'SYNC_FULL') {
            this.builder.clear();
        }
        this.builder.processHistory(event.payload);
        return this.builder.getNodes();
    }
    fromGraph(nodes) {
        return fromGraph(nodes, this.registry);
    }
}
//# sourceMappingURL=mapper.js.map