//#region imports
import { crossPlatformPath, folderName, Helpers, path } from 'tnp-core/lib';
import { UtilsTypescript } from 'tnp-helpers/lib';
import { templateFolderForArtifact } from '../../../../../../app-utils';
import { libFromImport, srcFromTaonImport, } from '../../../../../../constants';
//#endregion
export class BaseInsideStruct {
    project;
    initOptions;
    relativePaths() {
        const root = this.project.framework.coreProject.pathFor(templateFolderForArtifact(this.getCurrentArtifact()));
        const files = Helpers.getFilesFrom(root, {
            recursive: true,
            followSymlinks: false,
        }).map(f => f.replace(`${crossPlatformPath(path.dirname(root))}/`, ''));
        // console.log({
        //   files
        // })
        return files;
    }
    constructor(project, initOptions) {
        this.project = project;
        this.initOptions = initOptions;
    }
    //#region replace imports for browser or websql
    replaceImportsForBrowserOrWebsql(fileContent, { websql }) {
        //#region @backendFunc
        const importExports = UtilsTypescript.recognizeImportsFromContent(fileContent);
        for (const imp of importExports) {
            if (imp.cleanEmbeddedPathToFile.endsWith(`/${srcFromTaonImport}`)) {
                fileContent = fileContent.replace(imp.cleanEmbeddedPathToFile, imp.cleanEmbeddedPathToFile.replace(`/${srcFromTaonImport}`, websql ? `/${folderName.websql}` : `/${folderName.browser}`));
            }
        }
        if (websql) {
            fileContent = fileContent.replace('const websqlMode = false;', 'const websqlMode = true;');
        }
        return fileContent;
        //#endregion
    }
    //#endregion
    //#region replace imports for backend
    replaceImportsForBackend(fileContent) {
        //#region @backendFunc
        const importExports = UtilsTypescript.recognizeImportsFromContent(fileContent);
        for (const imp of importExports) {
            if (imp.cleanEmbeddedPathToFile.endsWith(`/${srcFromTaonImport}`)) {
                fileContent = fileContent.replace(imp.cleanEmbeddedPathToFile, imp.cleanEmbeddedPathToFile.replace(`/${srcFromTaonImport}`, `/${libFromImport}`));
            }
        }
        return fileContent;
        //#endregion
    }
}
//# sourceMappingURL=base-inside-struct.js.map