/**
 * MemoryRegistry — thin observable wrapper around the MemoryStore.
 * Panels subscribe via listeners; commands push/retrieve through this.
 */
export class MemoryRegistry {
    store;
    listeners = [];
    constructor(store) {
        this.store = store;
    }
    getStore() {
        return this.store;
    }
    subscribe(fn) {
        this.listeners.push(fn);
        return () => {
            this.listeners = this.listeners.filter(l => l !== fn);
        };
    }
    notify() {
        for (const fn of this.listeners)
            fn();
    }
    async add(opts) {
        const record = await this.store.add(opts);
        this.notify();
        return record;
    }
    search(filter = {}) {
        return this.store.search(filter);
    }
    searchSemantic(filter = {}) {
        return this.store.searchSemantic(filter);
    }
    rebuildVectors() {
        return this.store.rebuildVectorIndex();
    }
    async rebuildVectorsAsync() {
        return this.store.rebuildVectorIndexAsync();
    }
    vectorStats() {
        return this.store.vectorStats();
    }
    async doctor() {
        return this.store.doctor();
    }
    reviewQueue(limit = 10) {
        return this.store.reviewQueue(limit);
    }
    exportBundle(filter = {}) {
        return this.store.exportBundle(filter);
    }
    async importBundle(bundle) {
        const result = await this.store.importBundle(bundle);
        this.notify();
        return result;
    }
    get(id) {
        return this.store.get(id);
    }
    async link(fromId, toId, relation) {
        const link = await this.store.link(fromId, toId, relation);
        if (link)
            this.notify();
        return link;
    }
    linksFor(id) {
        return this.store.linksFor(id);
    }
    update(id, patch) {
        const record = this.store.update(id, patch);
        if (record)
            this.notify();
        return record;
    }
    review(id, patch) {
        const record = this.store.review(id, patch);
        if (record)
            this.notify();
        return record;
    }
    delete(id) {
        const removed = this.store.delete(id);
        if (removed)
            this.notify();
        return removed;
    }
    getAll() {
        return this.store.search({});
    }
}
