import { pLimit } from "./pLimit.mjs";

//#region ../@intlayer/cli/dist/esm/chokidar/dist/esm/utils/parallelizeGlobal.mjs
let _globalLimiter = null;
/** Get (and optionally configure) the single, shared limiter. */
const getGlobalLimiter = (concurrency) => {
	if (!_globalLimiter) _globalLimiter = pLimit(concurrency ?? 10);
	else if (typeof concurrency === "number") _globalLimiter.concurrency = concurrency;
	return _globalLimiter;
};
let _taskLimiter = null;
/** Limits how many *tasks* run concurrently (independent from AI calls). */
const getTaskLimiter = (concurrency) => {
	if (!_taskLimiter) _taskLimiter = pLimit(concurrency ?? 5);
	else if (typeof concurrency === "number") _taskLimiter.concurrency = concurrency;
	return _taskLimiter;
};

//#endregion
export { getGlobalLimiter, getTaskLimiter };
//# sourceMappingURL=parallelizeGlobal.mjs.map