"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 parallel_exports = {};
__export(parallel_exports, {
  parallelEach: () => parallelEach,
  parallelMap: () => parallelMap
});
module.exports = __toCommonJS(parallel_exports);
var import_streaming_iterables = require("../external/streaming-iterables");
var import_options = require("../promises/options");
var import_retry = require("../promises/retry");
// @__NO_SIDE_EFFECTS__
async function parallelEach(iterable, func, options) {
  for await (const _ of /* @__PURE__ */ parallelMap(iterable, func, options)) {
  }
}
// @__NO_SIDE_EFFECTS__
function parallelMap(iterable, func, options) {
  const opts = (0, import_options.normalizeIterationOptions)(options);
  const result = (0, import_streaming_iterables.parallelMap)(
    opts.concurrency,
    async (item) => {
      const result2 = await (0, import_retry.pRetry)((...args) => func(args[0]), {
        ...opts.retries,
        args: [item]
      });
      return result2;
    },
    iterable
  );
  return result;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  parallelEach,
  parallelMap
});
