"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var frameworks_exports = {};
__export(frameworks_exports, {
  FACADE_MAPPINGS: () => import_laravel.FACADE_MAPPINGS,
  amplifyResolver: () => import_amplify.amplifyResolver,
  angularResolver: () => import_angular.angularResolver,
  ansibleResolver: () => import_ansible.ansibleResolver,
  aspnetResolver: () => import_csharp.aspnetResolver,
  cdkResolver: () => import_iac.cdkResolver,
  cloudformationResolver: () => import_cloudformation.cloudformationResolver,
  detectFrameworks: () => detectFrameworks,
  djangoResolver: () => import_python.djangoResolver,
  dockerComposeResolver: () => import_docker.dockerComposeResolver,
  expressResolver: () => import_express.expressResolver,
  fastapiResolver: () => import_python.fastapiResolver,
  flaskResolver: () => import_python.flaskResolver,
  getAllFrameworkResolvers: () => getAllFrameworkResolvers,
  getFrameworkResolver: () => getFrameworkResolver,
  goResolver: () => import_go.goResolver,
  kubernetesResolver: () => import_kubernetes.kubernetesResolver,
  laravelResolver: () => import_laravel.laravelResolver,
  nuxtResolver: () => import_vue.nuxtResolver,
  phoenixResolver: () => import_elixir.phoenixResolver,
  playResolver: () => import_scala.playResolver,
  pulumiResolver: () => import_pulumi.pulumiResolver,
  railsResolver: () => import_ruby.railsResolver,
  reactResolver: () => import_react.reactResolver,
  registerFrameworkResolver: () => registerFrameworkResolver,
  rustResolver: () => import_rust.rustResolver,
  samResolver: () => import_iac.samResolver,
  serverlessResolver: () => import_iac.serverlessResolver,
  solidityResolver: () => import_solidity.solidityResolver,
  springResolver: () => import_java.springResolver,
  sstResolver: () => import_iac.sstResolver,
  svelteResolver: () => import_svelte.svelteResolver,
  swiftUIResolver: () => import_swift.swiftUIResolver,
  terraformResolver: () => import_terraform.terraformResolver,
  uikitResolver: () => import_swift.uikitResolver,
  vaporResolver: () => import_swift.vaporResolver,
  vueResolver: () => import_vue.vueResolver
});
module.exports = __toCommonJS(frameworks_exports);
var fs = __toESM(require("fs"));
var path = __toESM(require("path"));
var import_errors = require("../errors");
var import_config = require("../config");
var import_react = require("./react");
var import_svelte = require("./svelte");
var import_express = require("./express");
var import_python = require("./python");
var import_ruby = require("./ruby");
var import_java = require("./java");
var import_go = require("./go");
var import_rust = require("./rust");
var import_csharp = require("./csharp");
var import_swift = require("./swift");
var import_laravel = require("./laravel");
var import_elixir = require("./elixir");
var import_scala = require("./scala");
var import_vue = require("./vue");
var import_solidity = require("./solidity");
var import_iac = require("./iac");
var import_terraform = require("./terraform");
var import_pulumi = require("./pulumi");
var import_cloudformation = require("./cloudformation");
var import_kubernetes = require("./kubernetes");
var import_docker = require("./docker");
var import_ansible = require("./ansible");
var import_angular = require("./angular");
var import_amplify = require("./amplify");
var import_react2 = require("./react");
var import_svelte2 = require("./svelte");
var import_express2 = require("./express");
var import_python2 = require("./python");
var import_ruby2 = require("./ruby");
var import_java2 = require("./java");
var import_go2 = require("./go");
var import_rust2 = require("./rust");
var import_csharp2 = require("./csharp");
var import_swift2 = require("./swift");
var import_laravel2 = require("./laravel");
var import_elixir2 = require("./elixir");
var import_scala2 = require("./scala");
var import_vue2 = require("./vue");
var import_solidity2 = require("./solidity");
var import_iac2 = require("./iac");
var import_terraform2 = require("./terraform");
var import_pulumi2 = require("./pulumi");
var import_cloudformation2 = require("./cloudformation");
var import_kubernetes2 = require("./kubernetes");
var import_docker2 = require("./docker");
var import_ansible2 = require("./ansible");
var import_angular2 = require("./angular");
var import_amplify2 = require("./amplify");
const FRAMEWORK_RESOLVERS = [
  // PHP
  import_laravel2.laravelResolver,
  // JavaScript / TypeScript
  import_express2.expressResolver,
  import_react2.reactResolver,
  import_svelte2.svelteResolver,
  import_angular2.angularResolver,
  // Vue / Nuxt
  import_vue2.nuxtResolver,
  import_vue2.vueResolver,
  // Python
  import_python2.djangoResolver,
  import_python2.flaskResolver,
  import_python2.fastapiResolver,
  // Ruby
  import_ruby2.railsResolver,
  // Java
  import_java2.springResolver,
  // Go
  import_go2.goResolver,
  // Rust
  import_rust2.rustResolver,
  // C#
  import_csharp2.aspnetResolver,
  // Swift
  import_swift2.swiftUIResolver,
  import_swift2.uikitResolver,
  import_swift2.vaporResolver,
  // Elixir
  import_elixir2.phoenixResolver,
  // Scala
  import_scala2.playResolver,
  // Solidity
  import_solidity2.solidityResolver,
  // Infrastructure as Code
  import_iac2.sstResolver,
  import_iac2.cdkResolver,
  import_iac2.serverlessResolver,
  import_iac2.samResolver,
  import_terraform2.terraformResolver,
  import_pulumi2.pulumiResolver,
  import_cloudformation2.cloudformationResolver,
  import_amplify2.amplifyResolver,
  // Containers & Orchestration
  import_kubernetes2.kubernetesResolver,
  import_docker2.dockerComposeResolver,
  // Configuration Management
  import_ansible2.ansibleResolver
];
function getAllFrameworkResolvers() {
  return FRAMEWORK_RESOLVERS;
}
function getFrameworkResolver(name) {
  return FRAMEWORK_RESOLVERS.find((r) => r.name === name);
}
function registerFrameworkResolver(resolver) {
  const index = FRAMEWORK_RESOLVERS.findIndex((r) => r.name === resolver.name);
  if (index !== -1) FRAMEWORK_RESOLVERS.splice(index, 1);
  FRAMEWORK_RESOLVERS.push(resolver);
}
function buildResolutionContext(projectRoot, db) {
  const fileCache = /* @__PURE__ */ new Map();
  const nodeCache = /* @__PURE__ */ new Map();
  return {
    getNodesInFile(filePath) {
      if (!nodeCache.has(filePath)) {
        nodeCache.set(filePath, db.getNodesByFile(filePath));
      }
      return nodeCache.get(filePath);
    },
    getNodesByName(name) {
      return db.findNodesByExactName(name);
    },
    getNodesByKind(kind) {
      return db.getNodesByKind(kind);
    },
    fileExists(filePath) {
      return fs.existsSync(path.join(projectRoot, filePath));
    },
    readFile(filePath) {
      if (fileCache.has(filePath)) return fileCache.get(filePath);
      try {
        const content = fs.readFileSync(path.join(projectRoot, filePath), "utf8");
        fileCache.set(filePath, content);
        return content;
      } catch {
        fileCache.set(filePath, null);
        return null;
      }
    },
    getProjectRoot() {
      return projectRoot;
    },
    getAllFiles() {
      return db.getAllFiles().map((f) => f.path);
    }
  };
}
async function detectFrameworks(projectRoot, db) {
  if (!db) {
    return detectFromPackageJson(projectRoot);
  }
  const context = buildResolutionContext(projectRoot, db);
  const detected = [];
  for (const resolver of FRAMEWORK_RESOLVERS) {
    try {
      if (resolver.detect(context)) {
        (0, import_errors.logDebug)(`detectFrameworks: detected ${resolver.name}`);
        detected.push(resolver);
      }
    } catch (err) {
      (0, import_errors.logWarn)(`detectFrameworks: error detecting ${resolver.name}`, { error: String(err) });
    }
  }
  if (detected.length > 0) {
    await (0, import_config.updateConfig)(projectRoot, { frameworkHints: detected.map((f) => f.name) });
  }
  return detected;
}
async function detectFromPackageJson(projectRoot) {
  const pkgPath = path.join(projectRoot, "package.json");
  if (!fs.existsSync(pkgPath)) return [];
  let pkg;
  try {
    pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
  } catch {
    return [];
  }
  const deps = {
    ...pkg.dependencies ?? {},
    ...pkg.devDependencies ?? {}
  };
  const PACKAGE_TO_RESOLVER = {
    react: "react",
    next: "react",
    "react-native": "react",
    svelte: "svelte",
    "@sveltejs/kit": "svelte",
    express: "express",
    fastify: "express",
    koa: "express"
  };
  const detectedNames = /* @__PURE__ */ new Set();
  const detected = [];
  for (const [pkg2, resolverName] of Object.entries(PACKAGE_TO_RESOLVER)) {
    if (Object.prototype.hasOwnProperty.call(deps, pkg2) && !detectedNames.has(resolverName)) {
      const resolver = getFrameworkResolver(resolverName);
      if (resolver) {
        detectedNames.add(resolverName);
        detected.push(resolver);
      }
    }
  }
  if (detected.length > 0) {
    await (0, import_config.updateConfig)(projectRoot, { frameworkHints: detected.map((f) => f.name) });
  }
  return detected;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  FACADE_MAPPINGS,
  amplifyResolver,
  angularResolver,
  ansibleResolver,
  aspnetResolver,
  cdkResolver,
  cloudformationResolver,
  detectFrameworks,
  djangoResolver,
  dockerComposeResolver,
  expressResolver,
  fastapiResolver,
  flaskResolver,
  getAllFrameworkResolvers,
  getFrameworkResolver,
  goResolver,
  kubernetesResolver,
  laravelResolver,
  nuxtResolver,
  phoenixResolver,
  playResolver,
  pulumiResolver,
  railsResolver,
  reactResolver,
  registerFrameworkResolver,
  rustResolver,
  samResolver,
  serverlessResolver,
  solidityResolver,
  springResolver,
  sstResolver,
  svelteResolver,
  swiftUIResolver,
  terraformResolver,
  uikitResolver,
  vaporResolver,
  vueResolver
});
//# sourceMappingURL=index.js.map
