'use strict';
import { promises } from 'fs';
import _0x1c3e3a from 'node:path';
import { getAllInternalResourceMetas, setInternalResourceMeta } from '../../meta/server/resources/internal-resource-meta.js';
import { initialize } from '../../server/web/initialize.js';
import { generateTsConfig } from './generate-tsconfig.js';
import { generatedPaths, folders } from '../../../base-repo/app-constants/project-paths.js';
import { npmPackages } from '../../../base-repo/constants/packages.js';
import { readFile, mkdir, writeFile } from 'node:fs/promises';

var __defProp=Object['defineProperty'],__name=(_0x15f076,_0xb10857)=>__defProp(_0x15f076,'name',{'value':_0xb10857,'configurable':!![]});async function generateMeta(_0x45ea4e){const _0x286644=_0x45ea4e?.['isCombined'];await generateTsConfig();const _0x8061a5=await initialize();let _0x2c98a9=[];if(_0x286644){const _0x4e9152=generatedPaths['metaJson'],_0x2b3fbb=_0x1c3e3a['join'](folders['nodeModules'],npmPackages['saasKit']),_0x37d7ea=_0x1c3e3a['join'](_0x2b3fbb,generatedPaths['metaJson']);try{await readFile(_0x4e9152,'utf8');}catch{await mkdir(_0x1c3e3a['dirname'](_0x4e9152),{'recursive':!![]}),await writeFile(_0x4e9152,'{}','utf8');}const _0x3b1dba=await readFile(_0x37d7ea,'utf8'),_0x12b866=parseJsonObject(_0x3b1dba);for(const _0x205c79 of Object['values'](_0x12b866)){const _0x4ed20f=await getAllInternalResourceMetas([_0x205c79['name']]),_0x565424=_0x4ed20f[_0x205c79['name']]?.['crudHandlers'],_0x7beb83={..._0x205c79,'crudHandlers':_0x565424??_0x205c79['crudHandlers']};await setInternalResourceMeta(_0x7beb83);}_0x2c98a9=Object['keys'](_0x12b866);}const _0x2332f9=await getAllInternalResourceMetas([..._0x8061a5,..._0x2c98a9??[]]),_0x47613d=JSON['stringify'](_0x2332f9,void(0x111c*0x1+-0x987+-0x795),0x2*0x1357+0xede+-0x3588);await promises['mkdir'](_0x1c3e3a['dirname'](generatedPaths['metaJson']),{'recursive':!![]}),await promises['writeFile'](generatedPaths['metaJson'],_0x47613d);}__name(generateMeta,'generateMeta');function parseJsonObject(_0x401742){const _0x3fc996=JSON['parse'](_0x401742);return _0x3fc996;}__name(parseJsonObject,'parseJsonObject');

export { generateMeta };
