#!/usr/bin/env node
import {
  showDashboard
} from "../chunk-G6WHCALR.js";
import "../chunk-6G3KZSO4.js";
import "../chunk-52M2XF3W.js";
import "../chunk-SZRK3VOR.js";
import "../chunk-MKCHLXMY.js";
import "../chunk-EMIUPGPL.js";
import "../chunk-MMFQNJPE.js";
import "../chunk-HGTC76BX.js";
import "../chunk-SEJF7CGJ.js";
import "../chunk-TC3NHO34.js";
import "../chunk-K77I4XGL.js";
import "../chunk-KIWFEBKH.js";
import "../chunk-O6BA7Q2B.js";
import "../chunk-7SOPVGDV.js";
import "../chunk-SDKCQXWE.js";
import "../chunk-KUV24B5M.js";
import "../chunk-BMJZBLP7.js";
import "../chunk-X5EG4EFP.js";
import "../chunk-H7WJK7NJ.js";
import "../chunk-GG4BSB6S.js";
import "../chunk-TGLRDEEL.js";
import "../chunk-BKJHAJQW.js";
import "../chunk-CIG7IKX3.js";
import "../chunk-WYVDNGJB.js";
import "../chunk-MGNYPVOJ.js";
import "../chunk-BNQ5O6LE.js";
import "../chunk-52XO4ULK.js";
import "../chunk-WF6RM73R.js";
import "../chunk-XUDTFI4M.js";
import "../chunk-U3IGFMCY.js";
import "../chunk-MR6OBL3B.js";
import {
  detectInstallation,
  hasIndividualPlugins,
  resolveSource
} from "../chunk-TZXYBG3R.js";
import "../chunk-OCEFD7V6.js";
import "../chunk-T4EXUIBY.js";
import {
  EXIT_CODES
} from "../chunk-VR3CDXDT.js";
import "../chunk-LWXRUR6B.js";
import "../chunk-6OWHQ7HM.js";
import "../chunk-EC3UJRKZ.js";
import {
  init_esm_shims
} from "../chunk-DHET7RCE.js";

// src/cli/hooks/init.ts
init_esm_shims();
var hook = async function(options) {
  const projectDir = process.cwd();
  if (options.id === void 0) {
    const [installation, individualPlugins] = await Promise.all([
      detectInstallation(projectDir),
      hasIndividualPlugins(projectDir)
    ]);
    if (installation || individualPlugins) {
      const selectedCommand = await showDashboard(projectDir);
      if (selectedCommand) {
        await options.config.runCommand(selectedCommand);
      }
      this.exit(EXIT_CODES.SUCCESS);
    }
  }
  let sourceFlag;
  const sourceArgIndex = options.argv.indexOf("--source");
  if (sourceArgIndex !== -1 && sourceArgIndex + 1 < options.argv.length) {
    sourceFlag = options.argv[sourceArgIndex + 1];
  } else {
    const sourceFlagWithEquals = options.argv.find((arg) => arg.startsWith("--source="));
    if (sourceFlagWithEquals) {
      sourceFlag = sourceFlagWithEquals.split("=")[1];
    }
  }
  const sArgIndex = options.argv.indexOf("-s");
  if (sArgIndex !== -1 && sArgIndex + 1 < options.argv.length) {
    sourceFlag = options.argv[sArgIndex + 1];
  }
  try {
    const resolvedConfig = await resolveSource(sourceFlag, projectDir);
    options.config.sourceConfig = resolvedConfig;
  } catch (error) {
  }
};
var init_default = hook;
export {
  init_default as default
};
//# sourceMappingURL=init.js.map