/* Socket Lib - Built with esbuild */
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var prompts_exports = {};
__export(prompts_exports, {
  Separator: () => ActualSeparator,
  confirm: () => confirm,
  input: () => input,
  password: () => password,
  search: () => search,
  select: () => select,
  wrapPrompt: () => wrapPrompt
});
module.exports = __toCommonJS(prompts_exports);
var import_process = require("#constants/process");
const abortSignal = (0, import_process.getAbortSignal)();
const spinner = (0, import_process.getSpinner)();
// @__NO_SIDE_EFFECTS__
function wrapPrompt(inquirerPrompt) {
  return async (...args) => {
    const origContext = args.length > 1 ? args[1] : void 0;
    const { spinner: contextSpinner, ...contextWithoutSpinner } = origContext ?? {};
    const spinnerInstance = contextSpinner !== void 0 ? contextSpinner : spinner;
    const signal = abortSignal;
    if (origContext) {
      args[1] = {
        signal,
        ...contextWithoutSpinner
      };
    } else {
      args[1] = { signal };
    }
    const wasSpinning = !!spinnerInstance?.isSpinning;
    spinnerInstance?.stop();
    let result;
    try {
      result = await inquirerPrompt(...args);
    } catch (e) {
      if (e instanceof TypeError) {
        throw e;
      }
    }
    if (wasSpinning) {
      spinnerInstance.start();
    }
    return typeof result === "string" ? result.trim() : result;
  };
}
const confirmExport = require("../../external/@inquirer/confirm");
const inputExport = require("../../external/@inquirer/input");
const passwordExport = require("../../external/@inquirer/password");
const searchExport = require("../../external/@inquirer/search");
const selectExport = require("../../external/@inquirer/select");
const confirmRaw = confirmExport.default ?? confirmExport;
const inputRaw = inputExport.default ?? inputExport;
const passwordRaw = passwordExport.default ?? passwordExport;
const searchRaw = searchExport.default ?? searchExport;
const selectRaw = selectExport.default ?? selectExport;
const ActualSeparator = selectExport.Separator;
const confirm = /* @__PURE__ */ wrapPrompt(confirmRaw);
const input = /* @__PURE__ */ wrapPrompt(inputRaw);
const password = /* @__PURE__ */ wrapPrompt(passwordRaw);
const search = /* @__PURE__ */ wrapPrompt(searchRaw);
const select = /* @__PURE__ */ wrapPrompt(selectRaw);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  Separator,
  confirm,
  input,
  password,
  search,
  select,
  wrapPrompt
});
//# sourceMappingURL=prompts.js.map
