{"version":3,"file":"handleUnlinkedContentDeclarationFile.mjs","names":[],"sources":["../../src/handleUnlinkedContentDeclarationFile.ts"],"sourcesContent":["import { normalize } from 'node:path';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { buildDictionary } from './buildIntlayerDictionary/buildIntlayerDictionary';\nimport { cleanRemovedContentDeclaration } from './cleanRemovedContentDeclaration';\nimport { createTypes } from './createType';\nimport { createModuleAugmentation } from './createType/createModuleAugmentation';\nimport { listDictionaries } from './listDictionariesPath';\nimport { loadLocalDictionaries } from './loadDictionaries/loadLocalDictionaries';\nimport { formatPath } from './utils/formatter';\n\nexport const handleUnlinkedContentDeclarationFile = async (\n  filePath: string,\n  config: IntlayerConfig\n) => {\n  const appLogger = getAppLogger(config);\n\n  // Process the file with the functionToRun\n  appLogger(`Unlinked detected: ${formatPath(filePath)}`, {\n    isVerbose: true,\n  });\n\n  const files: string[] = await listDictionaries(config);\n\n  const existingFiles = files.filter(\n    (file) => normalize(file) !== normalize(filePath)\n  );\n\n  const localeDictionaries = await loadLocalDictionaries(existingFiles, config);\n\n  await cleanRemovedContentDeclaration(filePath, [], config);\n\n  const dictionariesOutput = await buildDictionary(localeDictionaries, config);\n\n  const dictionariesToBuild = Object.values(\n    dictionariesOutput?.mergedDictionaries ?? {}\n  ).map((dictionary) => dictionary.dictionary);\n\n  await createTypes(dictionariesToBuild, config);\n\n  appLogger('Dictionaries rebuilt', {\n    isVerbose: true,\n  });\n\n  await createModuleAugmentation(config);\n\n  appLogger('Module augmentation built', {\n    isVerbose: true,\n  });\n\n  // Plugin transformation\n  // Allow plugins to post-process the final build output (e.g., write back ICU JSON)\n  for await (const plugin of config.plugins ?? []) {\n    const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;\n\n    await plugin.afterBuild?.({\n      dictionaries: {\n        unmergedDictionaries,\n        mergedDictionaries,\n      },\n      configuration: config,\n    });\n  }\n};\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,uCAAuC,OAClD,UACA,WACG;CACH,MAAM,YAAY,aAAa,MAAM;CAGrC,UAAU,sBAAsB,WAAW,QAAQ,KAAK,EACtD,WAAW,KACb,CAAC;CAQD,MAAM,qBAAqB,MAAM,uBAJX,MAFQ,iBAAiB,MAAM,GAEzB,QACzB,SAAS,UAAU,IAAI,MAAM,UAAU,QAAQ,CAGiB,GAAG,MAAM;CAE5E,MAAM,+BAA+B,UAAU,CAAC,GAAG,MAAM;CAEzD,MAAM,qBAAqB,MAAM,gBAAgB,oBAAoB,MAAM;CAM3E,MAAM,YAJsB,OAAO,OACjC,oBAAoB,sBAAsB,CAAC,CAC7C,EAAE,KAAK,eAAe,WAAW,UAEG,GAAG,MAAM;CAE7C,UAAU,wBAAwB,EAChC,WAAW,KACb,CAAC;CAED,MAAM,yBAAyB,MAAM;CAErC,UAAU,6BAA6B,EACrC,WAAW,KACb,CAAC;CAID,WAAW,MAAM,UAAU,OAAO,WAAW,CAAC,GAAG;EAC/C,MAAM,EAAE,sBAAsB,uBAAuB;EAErD,MAAM,OAAO,aAAa;GACxB,cAAc;IACZ;IACA;GACF;GACA,eAAe;EACjB,CAAC;CACH;AACF"}