//#region ../@intlayer/cli/dist/esm/utils/getOutputFilePath.mjs
/**
* Get the output file path by replacing the base locale with the target locale
*
* This function handles two types of replacements:
* 1. Actual locale values (e.g., `/en/` → `/fr/`)
* 2. Template placeholders (e.g., `{{baseLocale}}` → `{{locale}}`, `{{baseLocaleName}}` → `{{localeName}}`)
*
* Replacement patterns:
* - `/baseLocale/` → `/locale/`
* - `\baseLocale\` → `\locale\`
* - `_baseLocale.` → `_locale.`
* - `baseLocale_` → `locale_`
* - `.baseLocaleName.` → `.localeName.`
* - `{{baseLocale}}` → `{{locale}}`
* - `{{baseLocaleName}}` → `{{localeName}}`
*
* If no patterns match, appends `.locale` to the file extension.
*
* @param filePath - The input file path
* @param locale - The target locale
* @param baseLocale - The base locale to replace
* @returns The output file path with locale replacements
*/
const getOutputFilePath = (filePath, locale, baseLocale) => {
	if (!filePath || !locale || !baseLocale) throw new Error("filePath, locale, and baseLocale are required");
	let outputFilePath = filePath;
	const replacements = [
		{
			pattern: /\{\{baseLocale\}\}/g,
			replacement: "{{locale}}"
		},
		{
			pattern: /\{\{baseLocaleName\}\}/g,
			replacement: "{{localeName}}"
		},
		{
			pattern: new RegExp(`/${baseLocale}/`, "g"),
			replacement: `/${locale}/`
		},
		{
			pattern: new RegExp(`\\\\${baseLocale}\\\\`, "g"),
			replacement: `\\${locale}\\`
		},
		{
			pattern: new RegExp(`_${baseLocale}\\.`, "g"),
			replacement: `_${locale}.`
		},
		{
			pattern: new RegExp(`/${baseLocale}_`, "g"),
			replacement: `/${locale}_`
		},
		{
			pattern: new RegExp(`(^|[\\/])${baseLocale}_`, "g"),
			replacement: `$1${locale}_`
		},
		{
			pattern: new RegExp(`\\.${baseLocale}\\.`, "g"),
			replacement: `.${locale}.`
		}
	];
	for (const { pattern, replacement } of replacements) outputFilePath = outputFilePath.replace(pattern, replacement);
	if (outputFilePath === filePath) {
		const lastDotIndex = filePath.lastIndexOf(".");
		if (lastDotIndex > 0) return `${filePath.slice(0, lastDotIndex)}.${locale}${filePath.slice(lastDotIndex)}`;
		else return `${filePath}.${locale}`;
	}
	return outputFilePath;
};

//#endregion
export { getOutputFilePath };
//# sourceMappingURL=getOutputFilePath.mjs.map