{"version":3,"file":"configManipulation.mjs","names":[],"sources":["../../../../src/init/utils/configManipulation.ts"],"sourcesContent":["import type { RoutingConfig } from '@intlayer/types/config';\nimport * as recast from 'recast';\nimport { typescriptParser } from '../../utils/babelParser';\nimport { isModuleScopeBinding } from './astImports';\nimport type {\n  CompatSyncConfig,\n  CompatVitePluginConfig,\n} from './packageManager';\n\nconst { builders: b, namedTypes: n } = recast.types;\n\n/** The locale routing strategies supported by the Intlayer configuration. */\nexport type RoutingMode = RoutingConfig['mode'];\n\n/** Narrows an arbitrary recast node to an object expression. */\nconst isObjectExpression = (node: any): boolean =>\n  Boolean(node) &&\n  (node.type === 'ObjectExpression' || n.ObjectExpression.check(node));\n\n/**\n * Finds a property by key name on an object expression, creating it with the\n * provided default value node when it is absent. Returns the property node so\n * callers can read or mutate its value while preserving any attached comments.\n */\nconst ensureObjectProperty = (\n  objExpr: any,\n  key: string,\n  defaultValueNode: any\n): any => {\n  let property = (objExpr.properties as any[]).find((prop: any) => {\n    if (!prop?.key) return false;\n    return (prop.key.name ?? prop.key.value) === key;\n  });\n\n  if (!property) {\n    property = b.property('init', b.identifier(key), defaultValueNode);\n    (objExpr.properties as any[]).push(property);\n  }\n\n  return property;\n};\n\n/**\n * Sets (or replaces) a property's value on an object expression. When the\n * property already exists only its value node is swapped, which keeps the\n * leading documentation comment in place.\n */\nconst setObjectPropertyValue = (\n  objExpr: any,\n  key: string,\n  valueNode: any\n): void => {\n  const property = (objExpr.properties as any[]).find((prop: any) => {\n    if (!prop?.key) return false;\n    return (prop.key.name ?? prop.key.value) === key;\n  });\n\n  if (property) {\n    property.value = valueNode;\n    return;\n  }\n\n  (objExpr.properties as any[]).push(\n    b.property('init', b.identifier(key), valueNode)\n  );\n};\n\n/**\n * Adds a `process.env.<envVar>` reference property to an object expression when\n * the property is not already present. Existing values are left untouched.\n */\nconst addEnvReferenceProperty = (\n  objExpr: any,\n  key: string,\n  envVar: string\n): void => {\n  const hasProperty = (objExpr.properties as any[]).some((prop: any) => {\n    if (!prop?.key) return false;\n    return (prop.key.name ?? prop.key.value) === key;\n  });\n\n  if (hasProperty) return;\n\n  (objExpr.properties as any[]).push(\n    b.property(\n      'init',\n      b.identifier(key),\n      b.memberExpression(\n        b.memberExpression(b.identifier('process'), b.identifier('env')),\n        b.identifier(envVar)\n      )\n    )\n  );\n};\n\n/**\n * Sets `routing.mode` in an Intlayer configuration file to the requested\n * strategy. Idempotent: re-running with the same mode produces identical\n * output. Supports `.ts`, `.mjs`, `.js` and `.cjs` configs; JSON configs are\n * handled with a scoped string replacement since they cannot be parsed by the\n * TypeScript recast parser.\n */\nexport const setIntlayerConfigRoutingMode = (\n  content: string,\n  extension: string,\n  mode: RoutingMode\n): string => {\n  if (extension === 'json') {\n    return content.replace(\n      /(\"mode\"\\s*:\\s*)\"(?:prefix-no-default|prefix-all|no-prefix|search-params)\"/,\n      `$1\"${mode}\"`\n    );\n  }\n\n  const ast = recast.parse(content, {\n    parser: typescriptParser,\n  });\n\n  genericRecastVisit(ast, (objExpr) => {\n    if (!isObjectExpression(objExpr)) return;\n\n    const routingProperty = ensureObjectProperty(\n      objExpr,\n      'routing',\n      b.objectExpression([])\n    );\n\n    if (!isObjectExpression(routingProperty.value)) return;\n\n    setObjectPropertyValue(\n      routingProperty.value,\n      'mode',\n      b.stringLiteral(mode)\n    );\n  });\n\n  return recast.print(ast).code;\n};\n\n/**\n * Sets `compiler.output` in an Intlayer configuration file to the given path\n * template (the `{{variable}}` string form, e.g.\n * `/locales/{{locale}}/{{key}}.content.json`). Idempotent: re-running with the\n * same template produces identical output. Supports `.ts`, `.mjs`, `.js` and\n * `.cjs` configs; JSON configs are supported too since the template is a plain\n * string.\n */\nexport const setIntlayerConfigCompilerOutput = (\n  content: string,\n  extension: string,\n  outputTemplate: string\n): string => {\n  if (extension === 'json') {\n    const parsed = JSON.parse(content);\n    parsed.compiler = { ...parsed.compiler, output: outputTemplate };\n    return JSON.stringify(parsed, null, 2);\n  }\n\n  const ast = recast.parse(content, {\n    parser: typescriptParser,\n  });\n\n  genericRecastVisit(ast, (objExpr) => {\n    if (!isObjectExpression(objExpr)) return;\n\n    const compilerProperty = ensureObjectProperty(\n      objExpr,\n      'compiler',\n      b.objectExpression([])\n    );\n\n    if (!isObjectExpression(compilerProperty.value)) return;\n\n    setObjectPropertyValue(\n      compilerProperty.value,\n      'output',\n      b.stringLiteral(outputTemplate)\n    );\n  });\n\n  return recast.print(ast).code;\n};\n\n/**\n * Enables the Intlayer visual editor in a configuration file: sets\n * `editor.enabled` to `true` and wires `clientId` / `clientSecret` to the\n * `INTLAYER_CLIENT_ID` / `INTLAYER_CLIENT_SECRET` environment variables.\n * Idempotent and non-destructive — existing `clientId` / `clientSecret` values\n * are preserved. Only `.ts`, `.mjs`, `.js` and `.cjs` configs are supported\n * (JSON cannot reference `process.env`).\n */\nexport const enableIntlayerEditorConfig = (content: string): string => {\n  const ast = recast.parse(content, {\n    parser: typescriptParser,\n  });\n\n  genericRecastVisit(ast, (objExpr) => {\n    if (!isObjectExpression(objExpr)) return;\n\n    const editorProperty = ensureObjectProperty(\n      objExpr,\n      'editor',\n      b.objectExpression([])\n    );\n\n    if (!isObjectExpression(editorProperty.value)) return;\n\n    const editorObject = editorProperty.value;\n\n    setObjectPropertyValue(editorObject, 'enabled', b.booleanLiteral(true));\n    addEnvReferenceProperty(editorObject, 'clientId', 'INTLAYER_CLIENT_ID');\n    addEnvReferenceProperty(\n      editorObject,\n      'clientSecret',\n      'INTLAYER_CLIENT_SECRET'\n    );\n  });\n\n  return recast.print(ast).code;\n};\n\n/**\n * True when `statement` is one of the module's own import statements —\n * `import … from '…'` in ESM, `const … = require('…')` in CJS.\n */\nconst isImportStatement = (statement: any, isCJS: boolean): boolean => {\n  if (!isCJS) return n.ImportDeclaration.check(statement);\n\n  return (\n    n.VariableDeclaration.check(statement) &&\n    statement.declarations.some(\n      (declarator: any) =>\n        n.VariableDeclarator.check(declarator) &&\n        n.CallExpression.check(declarator.init) &&\n        n.Identifier.check(declarator.init.callee) &&\n        declarator.init.callee.name === 'require'\n    )\n  );\n};\n\n/**\n * Adds `declaration` to the top of the module, after the leading import block\n * so the injected import is grouped with the existing ones.\n *\n * Unshifting blindly would push the file's leading comments down one\n * statement, which silently disables directives that only apply on the first\n * line — `// @ts-check`, present in the config Astro and Vite scaffold.\n */\nconst insertImportDeclaration = (\n  ast: any,\n  isCJS: boolean,\n  declaration: any\n): void => {\n  const body = ast.program.body;\n\n  let insertionIndex = 0;\n  while (\n    insertionIndex < body.length &&\n    isImportStatement(body[insertionIndex], isCJS)\n  ) {\n    insertionIndex++;\n  }\n\n  // No import to group with: keep the file's leading comments on the first\n  // line by moving them onto the injected statement.\n  if (insertionIndex === 0 && body.length > 0) {\n    const leadingComments = (body[0].comments ?? []).filter(\n      (comment: any) => comment.leading\n    );\n\n    if (leadingComments.length > 0) {\n      body[0].comments = (body[0].comments ?? []).filter(\n        (comment: any) => !comment.leading\n      );\n      declaration.comments = leadingComments;\n    }\n  }\n\n  body.splice(insertionIndex, 0, declaration);\n};\n\nconst injectImport = (\n  ast: any,\n  isCJS: boolean,\n  importName: string,\n  source: string\n) => {\n  // Never redeclare an identifier already bound at module scope (e.g. imported\n  // from another source or declared locally) — that would be a parse error.\n  if (!isCJS && isModuleScopeBinding(ast, importName)) return;\n\n  const body = ast.program.body;\n  const hasImport = body.some((stmt: any) => {\n    if (isCJS) {\n      return (\n        n.VariableDeclaration.check(stmt) &&\n        stmt.declarations.some(\n          (decl: any) =>\n            n.VariableDeclarator.check(decl) &&\n            n.CallExpression.check(decl.init) &&\n            n.Identifier.check(decl.init.callee) &&\n            decl.init.callee.name === 'require' &&\n            n.StringLiteral.check(decl.init.arguments[0]) &&\n            decl.init.arguments[0].value === source\n        )\n      );\n    }\n    return (\n      n.ImportDeclaration.check(stmt) &&\n      (stmt.source.value === source ||\n        stmt.specifiers?.some(\n          (spec: any) =>\n            (n.ImportSpecifier.check(spec) &&\n              spec.imported.name === importName) ||\n            (n.ImportDefaultSpecifier.check(spec) &&\n              spec.local?.name === importName)\n        ))\n    );\n  });\n\n  if (hasImport) return;\n\n  const declaration = isCJS\n    ? b.variableDeclaration('const', [\n        b.variableDeclarator(\n          b.identifier(`{ ${importName} }`),\n          b.callExpression(b.identifier('require'), [b.stringLiteral(source)])\n        ),\n      ])\n    : b.importDeclaration(\n        [b.importSpecifier(b.identifier(importName))],\n        b.stringLiteral(source)\n      );\n\n  insertImportDeclaration(ast, isCJS, declaration);\n};\n\nconst updatePluginArray = (\n  objExpr: any,\n  propertyName: string,\n  pluginName: string\n) => {\n  if (\n    !objExpr ||\n    (objExpr.type !== 'ObjectExpression' && !n.ObjectExpression.check(objExpr))\n  )\n    return;\n\n  let prop = objExpr.properties.find((p: any) => {\n    if (!p?.key) return false;\n    const keyName = p.key.name || p.key.value;\n    return keyName === propertyName;\n  }) as any;\n\n  if (!prop) {\n    prop = b.property(\n      'init',\n      b.identifier(propertyName),\n      b.arrayExpression([])\n    );\n    objExpr.properties.push(prop);\n  }\n\n  const arrayValue = prop.value;\n\n  if (\n    arrayValue &&\n    (arrayValue.type === 'ArrayExpression' ||\n      n.ArrayExpression.check(arrayValue))\n  ) {\n    const hasPlugin = arrayValue.elements.some((el: any) => {\n      const callee = el?.callee;\n      if (!callee) return false;\n      const name = callee.name || callee.id?.name;\n      return name === pluginName || name === 'il';\n    });\n\n    if (!hasPlugin) {\n      arrayValue.elements.push(b.callExpression(b.identifier(pluginName), []));\n    }\n  }\n};\n\nconst genericRecastVisit = (\n  ast: any,\n  updateConfigObject: (obj: any) => void,\n  callNames: string[] = ['defineConfig']\n) => {\n  /**\n   * Resolves an identifier reference (e.g. `export default config` /\n   * `module.exports = config`) back to the object expression it was declared\n   * with, then runs the updater on it.\n   */\n  const resolveIdentifierConfig = (name: string) => {\n    ast.program.body.forEach((stmt: any) => {\n      if (n.VariableDeclaration.check(stmt)) {\n        stmt.declarations.forEach((vdecl: any) => {\n          if (\n            n.VariableDeclarator.check(vdecl) &&\n            n.Identifier.check(vdecl.id) &&\n            vdecl.id.name === name &&\n            n.ObjectExpression.check(vdecl.init)\n          ) {\n            updateConfigObject(vdecl.init);\n          }\n        });\n      }\n    });\n  };\n\n  recast.visit(ast, {\n    visitExportDefaultDeclaration(path) {\n      const decl = path.node.declaration;\n\n      if (n.ObjectExpression.check(decl)) {\n        updateConfigObject(decl);\n      } else if (\n        n.CallExpression.check(decl) &&\n        n.Identifier.check(decl.callee) &&\n        callNames.includes(decl.callee.name)\n      ) {\n        if (n.ObjectExpression.check(decl.arguments[0])) {\n          updateConfigObject(decl.arguments[0]);\n        }\n      } else if (n.Identifier.check(decl)) {\n        resolveIdentifierConfig(decl.name);\n      }\n      return false;\n    },\n    visitAssignmentExpression(path) {\n      const { left, right } = path.node;\n\n      if (\n        n.MemberExpression.check(left) &&\n        recast.print(left).code === 'module.exports'\n      ) {\n        if (n.ObjectExpression.check(right)) {\n          updateConfigObject(right);\n        } else if (\n          n.CallExpression.check(right) &&\n          n.Identifier.check(right.callee) &&\n          callNames.includes(right.callee.name)\n        ) {\n          if (n.ObjectExpression.check(right.arguments[0])) {\n            updateConfigObject(right.arguments[0]);\n          }\n        } else if (n.Identifier.check(right)) {\n          resolveIdentifierConfig(right.name);\n        }\n      }\n      return false;\n    },\n  });\n};\n\n/**\n * Detects whether a Vite config already wires in an Intlayer plugin — either the\n * base `vite-intlayer` plugin or one of the compat adapters (e.g.\n * `reactI18nextVitePlugin` from `@intlayer/react-i18next/plugin`). The compat\n * plugins internally wrap `intlayer()`, so a standalone `intlayer()` must not be\n * appended when one is already present, otherwise the plugin runs twice.\n */\nexport const hasIntlayerVitePlugin = (content: string): boolean =>\n  content.includes('vite-intlayer') ||\n  /@intlayer\\/[^'\"]+\\/plugin/.test(content);\n\nexport const updateViteConfig = (\n  content: string,\n  extension: string\n): string => {\n  const ast = recast.parse(content, {\n    parser: typescriptParser,\n  });\n\n  const isCJSFile =\n    extension === 'cjs' ||\n    (content.includes('module.exports') && !content.includes('import '));\n\n  injectImport(ast, isCJSFile, 'intlayer', 'vite-intlayer');\n\n  genericRecastVisit(ast, (obj) =>\n    updatePluginArray(obj, 'plugins', 'intlayer')\n  );\n\n  return recast.print(ast).code;\n};\n\nexport const updateAstroConfig = (\n  content: string,\n  extension: string\n): string => {\n  const ast = recast.parse(content, {\n    parser: typescriptParser,\n  });\n\n  const isCJSFile =\n    extension === 'cjs' ||\n    (content.includes('module.exports') && !content.includes('import '));\n\n  injectImport(ast, isCJSFile, 'intlayer', 'astro-intlayer');\n\n  genericRecastVisit(ast, (obj) =>\n    updatePluginArray(obj, 'integrations', 'intlayer')\n  );\n\n  return recast.print(ast).code;\n};\n\nexport const updateNextConfig = (\n  content: string,\n  extension: string\n): string => {\n  const ast = recast.parse(content, {\n    parser: typescriptParser,\n  });\n\n  const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n\n  injectImport(ast, isCJSFile, 'withIntlayer', 'next-intlayer/server');\n\n  recast.visit(ast, {\n    visitExportDefaultDeclaration(path) {\n      const declaration = path.node.declaration;\n      if (\n        n.Expression.check(declaration) &&\n        !(\n          n.CallExpression.check(declaration) &&\n          n.Identifier.check(declaration.callee) &&\n          declaration.callee.name === 'withIntlayer'\n        )\n      ) {\n        path\n          .get('declaration')\n          .replace(\n            b.callExpression(b.identifier('withIntlayer'), [declaration as any])\n          );\n      }\n      return false;\n    },\n    visitAssignmentExpression(path) {\n      const { left, right } = path.node;\n\n      if (\n        n.MemberExpression.check(left) &&\n        recast.print(left).code === 'module.exports' &&\n        !(\n          n.CallExpression.check(right) &&\n          n.Identifier.check(right.callee) &&\n          right.callee.name === 'withIntlayer'\n        )\n      ) {\n        path\n          .get('right')\n          .replace(b.callExpression(b.identifier('withIntlayer'), [right]));\n      }\n      return false;\n    },\n  });\n\n  return recast.print(ast).code;\n};\n\n/**\n * Returns true when the expression looks like an Immediately Invoked Function\n * Expression (e.g. `(async () => { ... })()`). Such custom async exports cannot\n * be safely wrapped with the synchronous Metro helper, so they are skipped.\n */\nconst isImmediatelyInvokedFunction = (node: any): boolean =>\n  n.CallExpression.check(node) &&\n  (n.ArrowFunctionExpression.check(node.callee) ||\n    n.FunctionExpression.check(node.callee));\n\n/**\n * Wraps a React Native Metro config's exported value with\n * `configMetroIntlayerSync` from `react-native-intlayer/metro`, injecting the\n * import. The synchronous helper is used because it wraps a plain config object\n * and needs no IIFE, making it safe to inject into existing configs without\n * restructuring them.\n *\n * Non-destructive: returns the content unchanged when the export is already\n * wrapped, when the Intlayer Metro plugin is already present, or when the export\n * is a custom async IIFE that cannot be wrapped synchronously. Callers should\n * compare the result with the input to detect the skipped case.\n */\nexport const updateMetroConfig = (\n  content: string,\n  extension: string\n): string => {\n  if (content.includes('react-native-intlayer')) {\n    return content;\n  }\n\n  const ast = recast.parse(content, {\n    parser: typescriptParser,\n  });\n\n  const isCJSFile =\n    extension === 'cjs' ||\n    (content.includes('module.exports') && !content.includes('import '));\n\n  const wrapperName = 'configMetroIntlayerSync';\n\n  const isWrappable = (node: any): boolean =>\n    n.Expression.check(node) &&\n    !isImmediatelyInvokedFunction(node) &&\n    !(\n      n.CallExpression.check(node) &&\n      n.Identifier.check(node.callee) &&\n      node.callee.name === wrapperName\n    );\n\n  let wrapped = false;\n\n  recast.visit(ast, {\n    visitExportDefaultDeclaration(path) {\n      const declaration = path.node.declaration;\n      if (isWrappable(declaration)) {\n        path\n          .get('declaration')\n          .replace(\n            b.callExpression(b.identifier(wrapperName), [declaration as any])\n          );\n        wrapped = true;\n      }\n      return false;\n    },\n    visitAssignmentExpression(path) {\n      const { left, right } = path.node;\n\n      if (\n        n.MemberExpression.check(left) &&\n        recast.print(left).code === 'module.exports' &&\n        isWrappable(right)\n      ) {\n        path\n          .get('right')\n          .replace(b.callExpression(b.identifier(wrapperName), [right]));\n        wrapped = true;\n      }\n      return false;\n    },\n  });\n\n  // Only inject the import when an export was actually wrapped, so an\n  // un-wrappable config is left completely untouched.\n  if (!wrapped) {\n    return content;\n  }\n\n  injectImport(ast, isCJSFile, wrapperName, 'react-native-intlayer/metro');\n\n  return recast.print(ast).code;\n};\n\n/**\n * Builds the contents of a fresh `metro.config.js` wired with the Intlayer\n * Metro plugin. Uses the async `configMetroIntlayer` helper (which can build\n * dictionaries on server start) and picks the default-config source based on\n * whether the project is an Expo app.\n */\nexport const getMetroConfigTemplate = (isExpo: boolean): string => {\n  const defaultConfigSource = isExpo\n    ? 'expo/metro-config'\n    : '@react-native/metro-config';\n\n  return `const { getDefaultConfig } = require(\"${defaultConfigSource}\");\nconst { configMetroIntlayer } = require(\"react-native-intlayer/metro\");\n\nmodule.exports = (async () => {\n  const defaultConfig = getDefaultConfig(__dirname);\n\n  return await configMetroIntlayer(defaultConfig);\n})();\n`;\n};\n\nexport const updateNuxtConfig = (content: string): string => {\n  const ast = recast.parse(content, {\n    parser: typescriptParser,\n  });\n\n  const updateConfigObject = (objExpr: any) => {\n    if (\n      !objExpr ||\n      (objExpr.type !== 'ObjectExpression' &&\n        !n.ObjectExpression.check(objExpr))\n    )\n      return;\n\n    let modulesProp = objExpr.properties.find((p: any) => {\n      if (!p?.key) return false;\n      const keyName = p.key.name || p.key.value;\n      return keyName === 'modules';\n    }) as any;\n\n    if (!modulesProp) {\n      modulesProp = b.property(\n        'init',\n        b.identifier('modules'),\n        b.arrayExpression([])\n      );\n      objExpr.properties.push(modulesProp);\n    }\n\n    const modulesValue = modulesProp.value;\n\n    if (\n      modulesValue &&\n      (modulesValue.type === 'ArrayExpression' ||\n        n.ArrayExpression.check(modulesValue))\n    ) {\n      const hasModule = modulesValue.elements.some((el: any) => {\n        if (\n          n.StringLiteral.check(el) ||\n          el.type === 'StringLiteral' ||\n          el.type === 'Literal'\n        ) {\n          return (el.value || el.extra?.rawValue) === 'nuxt-intlayer';\n        }\n        return false;\n      });\n\n      if (!hasModule) {\n        modulesValue.elements.push(b.stringLiteral('nuxt-intlayer'));\n      }\n    }\n  };\n\n  genericRecastVisit(ast, updateConfigObject, ['defineNuxtConfig']);\n\n  return recast.print(ast).code;\n};\n\n/**\n * Updates a Vite config for vue-i18n compat: injects `vueI18nVitePlugin` from\n * `@intlayer/vue-i18n/plugin` into the plugins array.\n */\nexport const updateViteConfigForVueI18n = (\n  content: string,\n  extension: string\n): string => {\n  const ast = recast.parse(content, {\n    parser: typescriptParser,\n  });\n\n  const isCJSFile =\n    extension === 'cjs' ||\n    (content.includes('module.exports') && !content.includes('import '));\n\n  injectImport(\n    ast,\n    isCJSFile,\n    'vueI18nVitePlugin',\n    '@intlayer/vue-i18n/plugin'\n  );\n\n  genericRecastVisit(ast, (obj) =>\n    updatePluginArray(obj, 'plugins', 'vueI18nVitePlugin')\n  );\n\n  return recast.print(ast).code;\n};\n\n/**\n * Generic vite config updater for any compat plugin that uses alias injection.\n * Injects the named import from `pluginPackageSource` and appends the plugin\n * call to the `plugins` array.\n */\nexport const updateViteConfigForCompatPlugin = (\n  content: string,\n  extension: string,\n  pluginConfig: CompatVitePluginConfig\n): string => {\n  const ast = recast.parse(content, {\n    parser: typescriptParser,\n  });\n\n  const isCJSFile =\n    extension === 'cjs' ||\n    (content.includes('module.exports') && !content.includes('import '));\n\n  injectImport(\n    ast,\n    isCJSFile,\n    pluginConfig.pluginFunctionName,\n    pluginConfig.pluginPackageSource\n  );\n\n  genericRecastVisit(ast, (obj) =>\n    updatePluginArray(obj, 'plugins', pluginConfig.pluginFunctionName)\n  );\n\n  return recast.print(ast).code;\n};\n\n/**\n * Rewrites the module source of an existing named import in a vite config,\n * keeping the imported binding and its call site untouched. Used when a compat\n * plugin is a drop-in replacement for an i18n library's own vite plugin — e.g.\n * lingui: `import { lingui } from \"@lingui/vite-plugin\"` becomes\n * `import { lingui } from \"@intlayer/lingui/plugin\"`, leaving `lingui()` in the\n * `plugins` array as-is. Returns the content unchanged when no matching import\n * is found.\n */\nexport const replaceViteConfigPluginImportSource = (\n  content: string,\n  importName: string,\n  fromPackageSource: string,\n  toPackageSource: string\n): string => {\n  const ast = recast.parse(content, {\n    parser: typescriptParser,\n  });\n\n  let changed = false;\n\n  recast.visit(ast, {\n    visitImportDeclaration(path) {\n      const { source, specifiers } = path.node;\n      const importsBinding = (specifiers ?? []).some(\n        (specifier) =>\n          n.ImportSpecifier.check(specifier) &&\n          specifier.imported.name === importName\n      );\n\n      if (\n        n.StringLiteral.check(source) &&\n        source.value === fromPackageSource &&\n        importsBinding\n      ) {\n        source.value = toPackageSource;\n        changed = true;\n      }\n\n      return false;\n    },\n  });\n\n  if (!changed) return content;\n  return recast.print(ast).code;\n};\n\n/**\n * Generic Next.js config wrapper for compat plugins. Injects the import and\n * wraps the default export / `module.exports` with a HOC call.\n */\nconst wrapNextConfigWithHoc = (\n  content: string,\n  extension: string,\n  hocFunctionName: string,\n  pluginPackageSource: string\n): string => {\n  const ast = recast.parse(content, {\n    parser: typescriptParser,\n  });\n\n  const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n\n  injectImport(ast, isCJSFile, hocFunctionName, pluginPackageSource);\n\n  recast.visit(ast, {\n    visitExportDefaultDeclaration(path) {\n      const declaration = path.node.declaration;\n      if (\n        n.Expression.check(declaration) &&\n        !(\n          n.CallExpression.check(declaration) &&\n          n.Identifier.check(declaration.callee) &&\n          declaration.callee.name === hocFunctionName\n        )\n      ) {\n        path\n          .get('declaration')\n          .replace(\n            b.callExpression(b.identifier(hocFunctionName), [\n              declaration as any,\n            ])\n          );\n      }\n      return false;\n    },\n    visitAssignmentExpression(path) {\n      const { left, right } = path.node;\n\n      if (\n        n.MemberExpression.check(left) &&\n        recast.print(left).code === 'module.exports' &&\n        !(\n          n.CallExpression.check(right) &&\n          n.Identifier.check(right.callee) &&\n          right.callee.name === hocFunctionName\n        )\n      ) {\n        path\n          .get('right')\n          .replace(b.callExpression(b.identifier(hocFunctionName), [right]));\n      }\n      return false;\n    },\n  });\n\n  return recast.print(ast).code;\n};\n\n/**\n * Updates a Next.js config for next-translate compat: wraps the default export\n * with `withNextTranslate` from `@intlayer/next-translate/plugin`.\n */\nexport const updateNextConfigForNextTranslate = (\n  content: string,\n  extension: string\n): string =>\n  wrapNextConfigWithHoc(\n    content,\n    extension,\n    'withNextTranslate',\n    '@intlayer/next-translate/plugin'\n  );\n\n/**\n * Updates a Nuxt config for nuxtjs-i18n compat: adds `@intlayer/nuxtjs-i18n`\n * to the `modules` array.\n */\nexport const updateNuxtConfigForNuxtjsI18n = (content: string): string => {\n  const ast = recast.parse(content, {\n    parser: typescriptParser,\n  });\n\n  const updateConfigObject = (objExpr: any) => {\n    if (\n      !objExpr ||\n      (objExpr.type !== 'ObjectExpression' &&\n        !n.ObjectExpression.check(objExpr))\n    )\n      return;\n\n    let modulesProp = (objExpr.properties as any[]).find((p: any) => {\n      if (!p?.key) return false;\n      const keyName = p.key.name || p.key.value;\n      return keyName === 'modules';\n    }) as any;\n\n    if (!modulesProp) {\n      modulesProp = b.property(\n        'init',\n        b.identifier('modules'),\n        b.arrayExpression([])\n      );\n      (objExpr.properties as any[]).push(modulesProp);\n    }\n\n    const modulesValue = modulesProp.value;\n\n    if (\n      modulesValue &&\n      (modulesValue.type === 'ArrayExpression' ||\n        n.ArrayExpression.check(modulesValue))\n    ) {\n      const hasModule = (modulesValue.elements as any[]).some((el: any) => {\n        if (\n          n.StringLiteral.check(el) ||\n          el.type === 'StringLiteral' ||\n          el.type === 'Literal'\n        ) {\n          return (el.value ?? el.extra?.rawValue) === '@intlayer/nuxtjs-i18n';\n        }\n        return false;\n      });\n\n      if (!hasModule) {\n        (modulesValue.elements as any[]).push(\n          b.stringLiteral('@intlayer/nuxtjs-i18n')\n        );\n      }\n    }\n  };\n\n  genericRecastVisit(ast, updateConfigObject, ['defineNuxtConfig']);\n\n  return recast.print(ast).code;\n};\n\n/**\n * Updates a Next.js config for next-i18next compat: wraps the default export\n * with `withI18next` from `@intlayer/next-i18next/plugin`.\n */\nexport const updateNextConfigForNextI18next = (\n  content: string,\n  extension: string\n): string =>\n  wrapNextConfigWithHoc(\n    content,\n    extension,\n    'withI18next',\n    '@intlayer/next-i18next/plugin'\n  );\n\n/**\n * Updates a Next.js config for next-intl compat: replaces any existing\n * `next-intl/plugin` import source with `@intlayer/next-intl/plugin`, or\n * injects `createNextIntlPlugin` with a factory-call wrapper when no such\n * import is present.\n */\nexport const updateNextConfigForNextIntl = (\n  content: string,\n  extension: string\n): string => {\n  const ast = recast.parse(content, {\n    parser: typescriptParser,\n  });\n\n  const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n  let replacedExistingSource = false;\n\n  // Replace 'next-intl/plugin' import source with the compat package.\n  recast.visit(ast, {\n    visitImportDeclaration(path) {\n      if (path.node.source.value === 'next-intl/plugin') {\n        path.node.source = b.stringLiteral('@intlayer/next-intl/plugin');\n        replacedExistingSource = true;\n      }\n      return false;\n    },\n  });\n\n  if (replacedExistingSource) {\n    return recast.print(ast).code;\n  }\n\n  // No existing next-intl/plugin import: check whether createNextIntlPlugin is\n  // already present from any source before injecting the full factory pattern.\n  const hasCreatePlugin = (ast.program.body as any[]).some((stmt: any) => {\n    if (!n.ImportDeclaration.check(stmt)) return false;\n    return (stmt.specifiers ?? []).some(\n      (spec: any) =>\n        (n.ImportSpecifier.check(spec) &&\n          spec.imported.name === 'createNextIntlPlugin') ||\n        (n.ImportDefaultSpecifier.check(spec) &&\n          spec.local?.name === 'createNextIntlPlugin')\n    );\n  });\n\n  if (hasCreatePlugin) {\n    return recast.print(ast).code;\n  }\n\n  // Inject the import.\n  injectImport(\n    ast,\n    isCJSFile,\n    'createNextIntlPlugin',\n    '@intlayer/next-intl/plugin'\n  );\n\n  // Insert a factory-call variable declaration after the last import.\n  const lastImportIndex = (ast.program.body as any[]).reduce(\n    (lastIndex: number, stmt: any, index: number) => {\n      if (n.ImportDeclaration.check(stmt)) return index;\n      return lastIndex;\n    },\n    -1\n  );\n\n  const factoryCallDeclaration = b.variableDeclaration('const', [\n    b.variableDeclarator(\n      b.identifier('_withNextIntlayer'),\n      b.callExpression(b.identifier('createNextIntlPlugin'), [])\n    ),\n  ]);\n\n  (ast.program.body as any[]).splice(\n    lastImportIndex + 1,\n    0,\n    factoryCallDeclaration\n  );\n\n  // Wrap the default export with _withNextIntlayer(...).\n  recast.visit(ast, {\n    visitExportDefaultDeclaration(path) {\n      const declaration = path.node.declaration;\n      if (\n        n.Expression.check(declaration) &&\n        !(\n          n.CallExpression.check(declaration) &&\n          n.Identifier.check(declaration.callee) &&\n          declaration.callee.name === '_withNextIntlayer'\n        )\n      ) {\n        path\n          .get('declaration')\n          .replace(\n            b.callExpression(b.identifier('_withNextIntlayer'), [\n              declaration as any,\n            ])\n          );\n      }\n      return false;\n    },\n    visitAssignmentExpression(path) {\n      const { left, right } = path.node;\n\n      if (\n        n.MemberExpression.check(left) &&\n        recast.print(left).code === 'module.exports' &&\n        !(\n          n.CallExpression.check(right) &&\n          n.Identifier.check(right.callee) &&\n          right.callee.name === '_withNextIntlayer'\n        )\n      ) {\n        path\n          .get('right')\n          .replace(\n            b.callExpression(b.identifier('_withNextIntlayer'), [right])\n          );\n      }\n      return false;\n    },\n  });\n\n  return recast.print(ast).code;\n};\n\n/** The sync plugin used to ingest a compat library's catalogs. */\ntype SyncPluginInfo = {\n  /** Called function name, e.g. `'syncJSON'`. */\n  functionName: string;\n  /** Package the function is imported from. */\n  packageSource: string;\n};\n\n/** Resolves the sync plugin (function + package) for a compat sync config. */\nconst getSyncPluginInfo = (syncConfig: CompatSyncConfig): SyncPluginInfo =>\n  syncConfig.plugin === 'po'\n    ? { functionName: 'syncPO', packageSource: '@intlayer/sync-po-plugin' }\n    : { functionName: 'syncJSON', packageSource: '@intlayer/sync-json-plugin' };\n\n/**\n * Parses a `syncJSON({ ... })` / `syncPO({ ... })` call expression from a source\n * snippet so it can be injected into a config AST without manually constructing\n * template-literal nodes via builders.\n *\n * The destructuring parameters adapt to whether the source template uses the\n * `key` placeholder (nested pattern) or only `locale` (flat pattern).\n *\n * For `syncJSON` every option is emitted explicitly — `source`, then `format`\n * and `splitKeys` — each preceded by an explanatory JSDoc block, so the\n * generated config self-documents the two knobs a user is most likely to tweak.\n * `syncPO` takes neither `format` (gettext is always the serialization) nor\n * `splitKeys`, so it keeps a bare `source`-only call.\n */\nconst buildSyncCallNode = (syncConfig: CompatSyncConfig): any => {\n  const { functionName } = getSyncPluginInfo(syncConfig);\n  const usesKey = syncConfig.sourceTemplate.includes('${key}');\n  const paramDestructuring = !usesKey\n    ? '{ locale }'\n    : // `icu` (and PO, which is ICU-dialect) reads `{ key, locale }`; the\n      // i18next/vue-i18n JSON dialects keep their established `{ locale, key }`.\n      syncConfig.format === 'icu' || syncConfig.plugin === 'po'\n      ? '{ key, locale }'\n      : '{ locale, key }';\n\n  // The sourceTemplate contains ${locale} / ${key} as literal characters;\n  // they become proper template expressions once the snippet is parsed by recast.\n  const sourceProperty = `source: (${paramDestructuring}) => \\`${syncConfig.sourceTemplate}\\``;\n\n  const parseSnippet = (snippet: string): any => {\n    const snippetAst = recast.parse(snippet, {\n      parser: typescriptParser,\n    });\n    return (snippetAst.program.body[0] as any).expression;\n  };\n\n  // `syncPO` always serializes gettext, so it exposes neither `format` nor\n  // `splitKeys`: emit a bare `source`-only call.\n  if (syncConfig.plugin === 'po') {\n    return parseSnippet(`${functionName}({ ${sourceProperty} })`);\n  }\n\n  // `splitKeys: true` is forced only for the single-file namespace model\n  // (next-intl / use-intl); every other library keeps a single dictionary per\n  // file. It is now written explicitly (rather than relying on syncJSON's\n  // auto-detection) so the generated config documents the choice.\n  const splitKeys = Boolean(syncConfig.splitKeys);\n\n  // The JSDoc blocks are embedded in the snippet and preserved by recast when\n  // the parsed call node is printed back into the config AST.\n  const snippet = `${functionName}({\n  ${sourceProperty},\n\n  /**\n   * Parsing of json respecting the syntax\n   * Default \\`'intlayer'\\` message format\n   */\n  format: '${syncConfig.format}',\n\n  /**\n   * \\`true\\`:\n   * \\`en.json\\` ->  \\`useTranslation('home')\\` -> \\`t(\"title\")\\`\n   *\n   * \\`false\\`:\n   * \\`en.json\\` ->  \\`useTranslation()\\` -> \\`t(\"home.title\")\\`\n   */\n  splitKeys: ${splitKeys},\n})`;\n\n  return parseSnippet(snippet);\n};\n\n/**\n * Injects or ensures `dictionary: { format: '<value>' }` exists in an object\n * expression.  Leaves any pre-existing `dictionary` properties untouched —\n * only the `format` sub-property is added when absent.\n */\nconst injectDictionaryFormat = (objExpr: any, format: string): void => {\n  if (\n    !objExpr ||\n    (objExpr.type !== 'ObjectExpression' && !n.ObjectExpression.check(objExpr))\n  )\n    return;\n\n  let dictionaryProp = (objExpr.properties as any[]).find((prop: any) => {\n    if (!prop?.key) return false;\n    return (prop.key.name ?? prop.key.value) === 'dictionary';\n  });\n\n  if (!dictionaryProp) {\n    dictionaryProp = b.property(\n      'init',\n      b.identifier('dictionary'),\n      b.objectExpression([])\n    );\n    (objExpr.properties as any[]).push(dictionaryProp);\n  }\n\n  const dictionaryObj = dictionaryProp.value;\n  if (\n    !dictionaryObj ||\n    (dictionaryObj.type !== 'ObjectExpression' &&\n      !n.ObjectExpression.check(dictionaryObj))\n  )\n    return;\n\n  const hasFormat = (dictionaryObj.properties as any[]).some((prop: any) => {\n    if (!prop?.key) return false;\n    return (prop.key.name ?? prop.key.value) === 'format';\n  });\n\n  if (!hasFormat) {\n    (dictionaryObj.properties as any[]).push(\n      b.property('init', b.identifier('format'), b.stringLiteral(format))\n    );\n  }\n};\n\n/**\n * Injects the sync plugin import (`syncJSON` / `syncPO`) and a configured\n * `syncJSON(...)` / `syncPO(...)` call into the plugins array of an intlayer\n * config file. Idempotent: skips when the plugin call is already present.\n */\nexport const updateIntlayerConfigWithSyncPlugin = (\n  content: string,\n  extension: string,\n  syncConfig: CompatSyncConfig\n): string => {\n  const ast = recast.parse(content, {\n    parser: typescriptParser,\n  });\n\n  const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n\n  const { functionName, packageSource } = getSyncPluginInfo(syncConfig);\n\n  injectImport(ast, isCJSFile, functionName, packageSource);\n\n  const callNode = buildSyncCallNode(syncConfig);\n\n  // PO catalogs are serialized as gettext; JSON catalogs carry the dialect.\n  const dictionaryFormat =\n    syncConfig.plugin === 'po' ? 'po' : syncConfig.format;\n\n  genericRecastVisit(ast, (objExpr) => {\n    if (\n      !objExpr ||\n      (objExpr.type !== 'ObjectExpression' &&\n        !n.ObjectExpression.check(objExpr))\n    )\n      return;\n\n    // Inject dictionary.format alongside the plugin so intlayer knows how to\n    // interpret dictionary content at runtime.\n    injectDictionaryFormat(objExpr, dictionaryFormat);\n\n    let pluginsProp = (objExpr.properties as any[]).find((prop: any) => {\n      if (!prop?.key) return false;\n      const keyName = prop.key.name ?? prop.key.value;\n      return keyName === 'plugins';\n    });\n\n    if (!pluginsProp) {\n      pluginsProp = b.property(\n        'init',\n        b.identifier('plugins'),\n        b.arrayExpression([])\n      );\n      (objExpr.properties as any[]).push(pluginsProp);\n    }\n\n    const arrayValue = pluginsProp.value;\n\n    if (\n      arrayValue &&\n      (arrayValue.type === 'ArrayExpression' ||\n        n.ArrayExpression.check(arrayValue))\n    ) {\n      const hasSyncPlugin = (arrayValue.elements as any[]).some(\n        (element: any) => {\n          const callee = element?.callee;\n          if (!callee) return false;\n          const name: string = callee.name ?? callee.id?.name;\n          return name === functionName;\n        }\n      );\n\n      if (!hasSyncPlugin) {\n        (arrayValue.elements as any[]).push(callNode);\n      }\n    }\n  });\n\n  return recast.print(ast).code;\n};\n"],"mappings":";;;;;AASA,MAAM,EAAE,UAAU,GAAG,YAAY,MAAM,OAAO;;AAM9C,MAAM,sBAAsB,SAC1B,QAAQ,IAAI,MACX,KAAK,SAAS,sBAAsB,EAAE,iBAAiB,MAAM,IAAI;;;;;;AAOpE,MAAM,wBACJ,SACA,KACA,qBACQ;CACR,IAAI,WAAY,QAAQ,WAAqB,MAAM,SAAc;EAC/D,IAAI,CAAC,MAAM,KAAK,OAAO;EACvB,QAAQ,KAAK,IAAI,QAAQ,KAAK,IAAI,WAAW;CAC/C,CAAC;CAED,IAAI,CAAC,UAAU;EACb,WAAW,EAAE,SAAS,QAAQ,EAAE,WAAW,GAAG,GAAG,gBAAgB;EACjE,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