{"version":3,"file":"getContentExtension.cjs","names":[],"sources":["../../../src/utils/getContentExtension.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Generates the .content file extension based on the desired format\n * and the project's fileExtensions configuration.\n *\n * Example:\n * format 'ts' -> '.content.ts'\n * format 'esm' -> '.content.js' (if matching .content.js is found in config)\n */\nexport const getContentExtension = (\n  format: 'ts' | 'esm' | 'cjs' | 'json' | 'jsonc' | 'json5' | (string & {}),\n  configuration: IntlayerConfig\n): string => {\n  let contentFileExtension = '.ts';\n  switch (format) {\n    case 'json':\n      contentFileExtension = '.json';\n      break;\n    case 'cjs':\n      contentFileExtension = '.cjs';\n      break;\n    case 'esm':\n      contentFileExtension = '.js';\n      break;\n  }\n\n  // Find the configured extension that matches the format's extension\n  const pickedFileExtension = configuration.content.fileExtensions.find(\n    (extension) => extension.endsWith(contentFileExtension)\n  );\n\n  return (\n    pickedFileExtension ??\n    configuration.content.fileExtensions[0] ??\n    `.content${contentFileExtension}`\n  );\n};\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,uBACX,QACA,kBACW;CACX,IAAI,uBAAuB;CAC3B,QAAQ,QAAR;EACE,KAAK;GACH,uBAAuB;GACvB;EACF,KAAK;GACH,uBAAuB;GACvB;EACF,KAAK;GACH,uBAAuB;GACvB;CACJ;CAOA,OAJ4B,cAAc,QAAQ,eAAe,MAC9D,cAAc,UAAU,SAAS,oBAAoB,CAIpC,KAClB,cAAc,QAAQ,eAAe,MACrC,WAAW;AAEf"}