"use strict";
/* Socket Lib - Built with esbuild */
"use strict";
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 exec_exports = {};
__export(exec_exports, {
  execYarn: () => execYarn
});
module.exports = __toCommonJS(exec_exports);
var import_exec = require("../../../../bin/exec");
var import_namespace = require("../../../../debug/namespace");
var import_array = require("../../../../primordials/array");
var import_flags = require("../../npm/flags");
var import_flags2 = require("../../pnpm/flags");
var import_map_set = require("../../../../primordials/map-set");
const yarnInstallLikeCommands = new import_map_set.SetCtor([
  "add",
  "import",
  "install",
  "link",
  "remove",
  "unlink",
  "upgrade"
]);
function execYarn(args, options) {
  const useDebug = (0, import_namespace.isDebug)();
  const terminatorPos = (0, import_array.ArrayPrototypeIndexOf)(args, "--");
  const yarnArgs = (terminatorPos === -1 ? args : (0, import_array.ArrayPrototypeSlice)(args, 0, terminatorPos)).filter((a) => !(0, import_flags.isNpmProgressFlag)(a));
  const otherArgs = terminatorPos === -1 ? [] : (0, import_array.ArrayPrototypeSlice)(args, terminatorPos);
  const firstArg = yarnArgs[0];
  const supportsIgnoreScripts = firstArg ? yarnInstallLikeCommands.has(firstArg) : false;
  const logLevelArgs = useDebug || yarnArgs.some(import_flags.isNpmLoglevelFlag) ? [] : ["--silent"];
  const hasIgnoreScriptsFlag = yarnArgs.some(import_flags2.isPnpmIgnoreScriptsFlag);
  const ignoreScriptsArgs = !supportsIgnoreScripts || hasIgnoreScriptsFlag ? [] : ["--ignore-scripts"];
  return (0, import_exec.execBin)(
    "yarn",
    [...logLevelArgs, ...ignoreScriptsArgs, ...yarnArgs, ...otherArgs],
    {
      __proto__: null,
      ...options
    }
  );
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  execYarn
});
