// import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs'; // import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs'; // /** // * A simple in-memory map acting as a Space. // * Pure Storage. No Indexing logic. // * // * Copied/Adapted from Keystone Respecs. // */ // export class MockIbGibSpace { // store = new Map(); // constructor(public name: string = "mock_space") { } // async put({ ibGib }: { ibGib: IbGib_V1 }): Promise { // const addr = getIbGibAddr({ ibGib }); // this.store.set(addr, JSON.parse(JSON.stringify(ibGib))); // Deep copy // } // async get({ addr }: { addr: string }): Promise { // const data = this.store.get(addr); // return data ? JSON.parse(JSON.stringify(data)) : null; // } // async witness(arg: any): Promise { // const cmd = arg.data?.cmd; // if (cmd === 'get') { // const addrs = arg.data.ibGibAddrs || []; // const ibGibs: IbGib_V1[] = []; // for (const addr of addrs) { // const ig = await this.get({ addr }); // if (ig) { ibGibs.push(ig); } // } // return { ibGibs }; // } // if (cmd === 'put') { // const ibGibs = arg.ibGibs || []; // for (const ibGib of ibGibs) { // await this.put({ ibGib }); // } // return { ibGibs: [] }; // Return empty result or whatever witness expects // } // return undefined; // } // } // /** // * A partial mock of Metaspace. // */ // export class MockMetaspaceService { // /** // * Map of TJP Gib (Timeline ID) -> Latest IbGib Addr (Head) // */ // timelineHeads = new Map(); // constructor(public space: MockIbGibSpace) { } // async getLocalUserSpace({ lock }: { lock: boolean }): Promise { // return this.space; // } // async put(args: any): Promise { // const target = args.space || this.space; // return target.put(args); // } // async registerNewIbGib(args: { ibGib: IbGib_V1, space?: any }): Promise { // const { ibGib } = args; // const targetSpace = args.space || this.space; // // 1. Ensure it is stored // await targetSpace.put({ ibGib }); // // 2. Extract TJP // const gib = ibGib.gib || ''; // let tjpGib = gib; // if (gib.includes('.')) { // const parts = gib.split('.'); // tjpGib = parts.slice(1).join('.'); // } // const addr = getIbGibAddr({ ibGib }); // this.timelineHeads.set(tjpGib, addr); // } // }