/* Socket Lib - Built with esbuild */
var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var d=(t,e)=>{for(var n in e)i(t,n,{get:e[n],enumerable:!0})},c=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let u of o(e))!h.call(t,u)&&u!==n&&i(t,u,{get:()=>e[u],enumerable:!(r=a(e,u))||r.enumerable});return t};var m=t=>c(i({},"__esModule",{value:!0}),t);var l={};d(l,{PromiseQueue:()=>g});module.exports=m(l);class g{queue=[];running=0;maxConcurrency;maxQueueLength;constructor(e,n){if(this.maxConcurrency=e,this.maxQueueLength=n,e<1)throw new Error("maxConcurrency must be at least 1")}async add(e){return await new Promise((n,r)=>{const u={fn:e,resolve:n,reject:r};if(this.maxQueueLength&&this.queue.length>=this.maxQueueLength){const s=this.queue.shift();s&&s.reject(new Error("Task dropped: queue length exceeded"))}this.queue.push(u),this.runNext()})}runNext(){if(this.running>=this.maxConcurrency||this.queue.length===0)return;const e=this.queue.shift();e&&(this.running++,e.fn().then(e.resolve).catch(e.reject).finally(()=>{this.running--,this.runNext()}))}async onIdle(){return await new Promise(e=>{const n=()=>{this.running===0&&this.queue.length===0?e():setImmediate(n)};n()})}get activeCount(){return this.running}get pendingCount(){return this.queue.length}clear(){this.queue=[]}}0&&(module.exports={PromiseQueue});
//# sourceMappingURL=promise-queue.js.map
