function generateTsConfig(context) {
  const { manifest, spec } = context;
  const mergedOptions = extractTsConfigOptions(context.implementationTypes || []);
  const hasViews = spec && (spec.views || Array.isArray(spec.views) && spec.views.length > 0);
  const usesReact = hasViews && (context.implementationTypes || []).some(
    (implType) => implType.capabilities?.provides?.includes("ui.components") && implType.technology?.framework === "react"
  );
  const tsconfig = {
    compilerOptions: {
      // Defaults
      target: "ES2022",
      module: "ESNext",
      moduleResolution: "node",
      lib: ["ES2022"],
      outDir: "./dist",
      rootDir: "./src",
      // Strict mode
      strict: true,
      esModuleInterop: true,
      skipLibCheck: true,
      forceConsistentCasingInFileNames: true,
      // Module resolution
      resolveJsonModule: true,
      allowSyntheticDefaultImports: true,
      // Output
      declaration: true,
      declarationMap: true,
      sourceMap: true,
      // Merge options from implementation types
      ...mergedOptions
    },
    include: usesReact ? ["src/**/*.ts"] : ["src/**/*"],
    // Exclude .tsx files if React is used
    exclude: usesReact ? ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts", "src/components/**", "src/hooks/**", "src/types/**"] : ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"],
    ...usesReact && {
      references: [{ path: "./tsconfig.react.json" }]
      // Reference React config
    }
  };
  return JSON.stringify(tsconfig, null, 2);
}
function extractTsConfigOptions(implementationTypes) {
  const options = {};
  if (!implementationTypes || implementationTypes.length === 0) {
    return options;
  }
  for (const implType of implementationTypes) {
    if (implType.requirements?.configuration?.tsconfig?.compilerOptions) {
      Object.assign(options, implType.requirements.configuration.tsconfig.compilerOptions);
    }
  }
  return options;
}
export {
  generateTsConfig as default
};
