import { getUUID } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
import { respecfully } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
const maam = `[${import.meta.url}]`, sir = maam;
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
import { GLOBAL_LOG_A_LOT } from '../../../core-constants.mjs';
import { testSpace_createAndInit, testSpace_persistTransformResult, testSpace_putGetDelete } from '../space-respec-helper.mjs';
import { FilesystemSpace_V1, } from './filesystem-space-v1.mjs';
const logalot = GLOBAL_LOG_A_LOT;
/**
 * simple mock that naively implements file operations using a private map that holds ibgibs.
 */
class MockFilesystemSpace_V1 extends FilesystemSpace_V1 {
    getMetaStoneAddrs({ tjpGib, }) {
        throw new Error('Method not implemented.');
    }
    async ensureDirsImpl(paths) {
        const lc = `${this.lc}[${this.ensureDirsImpl.name}]`;
        if (logalot) {
            console.log(`${lc} executed (I: 566d080b91eb7dc888ea5397e2838c23)`);
        }
    }
    #files = {};
    async putFile({ ibGib, isDna, }) {
        if (!ibGib) {
            throw new Error(`ibGib required (E: 8a63c7d0922565d6d14ceabd9d881f23)`);
        }
        let addr = getIbGibAddr({ ibGib });
        this.#files[addr] = ibGib;
        return { success: true };
    }
    async deleteFile({ addr, isDna, }) {
        if (!addr) {
            throw new Error(`addr required (E: 74167b11ed53abd5db45da2e19d4c923)`);
        }
        if (this.#files[addr]) {
            delete this.#files[addr];
        }
        return { success: true };
    }
    async getFile({ addr, isDna, }) {
        if (!addr) {
            throw new Error(`addr required (E: 07bcbc77f59b26266f447bedc7bab723)`);
        }
        if (this.#files[addr]) {
            return {
                success: true,
                ibGib: this.#files[addr],
            };
        }
        else {
            return {
                success: false,
                errorMsg: 'addr not found',
            };
        }
    }
}
await respecfully(sir, `[${FilesystemSpace_V1.name} specs]`, async () => {
    await testSpace_createAndInit({
        respecfulTitle: sir,
        // shortcircuitRespec: true,
        fnGetInitialSpaceData: async () => {
            return {
                name: (await getUUID()).substring(0, 8),
                uuid: await getUUID(),
            };
        },
        fnGetInitialSpaceRel8ns: () => {
            return Promise.resolve(undefined);
        },
        fnGetSpace: (initialData, initialRel8ns) => {
            return Promise.resolve(new MockFilesystemSpace_V1(initialData, initialRel8ns));
        },
    });
    await testSpace_putGetDelete({
        respecfulTitle: sir,
        // shortcircuitRespec: true,
        fnGetInitialSpaceData: async () => {
            return {
                name: (await getUUID()).substring(0, 8),
                uuid: await getUUID(),
            };
        },
        fnGetInitialSpaceRel8ns: () => {
            return Promise.resolve(undefined);
        },
        fnGetSpace: (initialData, initialRel8ns) => {
            return Promise.resolve(new MockFilesystemSpace_V1(initialData, initialRel8ns));
        },
    });
    await testSpace_persistTransformResult({
        respecfulTitle: sir,
        // shortcircuitRespec: true,
        fnGetInitialSpaceData: async () => {
            return {
                name: (await getUUID()).substring(0, 8),
                uuid: await getUUID(),
            };
        },
        fnGetInitialSpaceRel8ns: () => {
            return Promise.resolve(undefined);
        },
        fnGetSpace: (initialData, initialRel8ns) => {
            return Promise.resolve(new MockFilesystemSpace_V1(initialData, initialRel8ns));
        },
    });
});
//# sourceMappingURL=filesystem-space-v1.respec.mjs.map