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K1D,GAChB2D,EAAsB,CAAC,KAAK9D,IAC3B,KAAKC,IAAkB,KAAKC,IAC5B,KAAKQ,GAAO,KAAO,EACtBoD,IAAwBD,IACxB,KAAK1D,GAAyB2D,EAC9B,KAAK,KAAKA,EAAsB,YAAc,kBAAkB,EAExE,CAIA,IAAI,eAAgB,CAChB,OAAO,KAAK3D,EAChB,CA2BA,IAAI,aAAc,CACd,OAAQ,KAAKS,KAAa,KAAKC,IAAgB,KAAKH,GAAO,KAAO,GAC1D,KAAK,eAAiB,KAAKA,GAAO,KAAO,CACrD,CA8BA,IAAI,cAAe,CAEf,MAAO,CAAC,GAAG,KAAKM,GAAc,OAAO,CAAC,EAAE,IAAI+C,IAAS,CAAE,GAAGA,CAAK,EAAE,CACrE,CACJ","names":["require_eventemitter3","__commonJSMin","exports","module","has","prefix","Events","EE","fn","context","once","addListener","emitter","event","listener","evt","clearEvent","EventEmitter","names","events","name","handlers","i","l","ee","listeners","a1","a2","a3","a4","a5","len","args","length","j","import_index","TimeoutError","_TimeoutError","message","options","getAbortedReason","signal","pTimeout","promise","milliseconds","fallback","customTimers","timer","abortHandler","cancelablePromise","resolve","reject","timeoutError","error","lowerBound","array","value","comparator","first","count","step","it","PriorityQueue","#queue","run","options","priority","id","element","index","lowerBound","a","b","item","PQueue","EventEmitter","#carryoverIntervalCount","#isIntervalIgnored","#intervalCount","#intervalCap","#rateLimitedInInterval","#rateLimitFlushScheduled","#interval","#intervalEnd","#lastExecutionTime","#intervalId","#timeoutId","#queue","#queueClass","#pending","#concurrency","#isPaused","#idAssigner","#runningTasks","options","PriorityQueue","#setupRateLimitTracking","#doesIntervalAllowAnother","#doesConcurrentAllowAnother","#next","#tryToStartAnother","#onResumeInterval","#onInterval","#initializeIntervalIfNeeded","#isIntervalPaused","now","delay","timeSinceLastExecution","#createIntervalTimeout","#clearIntervalTimer","#clearTimeoutTimer","taskStarted","canInitializeInterval","job","#scheduleRateLimitUpdate","#processQueue","newConcurrency","id","priority","function_","resolve","reject","taskSymbol","eventListener","error","operation","pTimeout","signal","_resolve","result","functions","#updateRateLimitState","#onEvent","limit","handleError","event","filter","listener","previous","shouldBeRateLimited","task"],"sources":["../esm/npm/p-queue@9.0.1/node_modules/eventemitter3/index.js","../esm/npm/p-queue@9.0.1/node_modules/eventemitter3/index.mjs","../esm/npm/p-queue@9.0.1/node_modules/p-timeout/index.js","../esm/npm/p-queue@9.0.1/node_modules/p-queue/dist/lower-bound.js","../esm/npm/p-queue@9.0.1/node_modules/p-queue/dist/priority-queue.js","../esm/npm/p-queue@9.0.1/node_modules/p-queue/dist/index.js"],"sourcesContent":["'use strict';\n\nvar has = Object.prototype.hasOwnProperty\n  , prefix = '~';\n\n/**\n * Constructor to create a storage for our `EE` objects.\n * An `Events` instance is a plain object whose properties are event names.\n *\n * @constructor\n * @private\n */\nfunction Events() {}\n\n//\n// We try to not inherit from `Object.prototype`. In some engines creating an\n// instance in this way is faster than calling `Object.create(null)` directly.\n// If `Object.create(null)` is not supported we prefix the event names with a\n// character to make sure that the built-in object properties are not\n// overridden or used as an attack vector.\n//\nif (Object.create) {\n  Events.prototype = Object.create(null);\n\n  //\n  // This hack is needed because the `__proto__` property is still inherited in\n  // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.\n  //\n  if (!new Events().__proto__) prefix = false;\n}\n\n/**\n * Representation of a single event listener.\n *\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} [once=false] Specify if the listener is a one-time listener.\n * @constructor\n * @private\n */\nfunction EE(fn, context, once) {\n  this.fn = fn;\n  this.context = context;\n  this.once = once || false;\n}\n\n/**\n * Add a listener for a given event.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} once Specify if the listener is a one-time listener.\n * @returns {EventEmitter}\n * @private\n */\nfunction addListener(emitter, event, fn, context, once) {\n  if (typeof fn !== 'function') {\n    throw new TypeError('The listener must be a function');\n  }\n\n  var listener = new EE(fn, context || emitter, once)\n    , evt = prefix ? prefix + event : event;\n\n  if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;\n  else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);\n  else emitter._events[evt] = [emitter._events[evt], listener];\n\n  return emitter;\n}\n\n/**\n * Clear event by name.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} evt The Event name.\n * @private\n */\nfunction clearEvent(emitter, evt) {\n  if (--emitter._eventsCount === 0) emitter._events = new Events();\n  else delete emitter._events[evt];\n}\n\n/**\n * Minimal `EventEmitter` interface that is molded against the Node.js\n * `EventEmitter` interface.\n *\n * @constructor\n * @public\n */\nfunction EventEmitter() {\n  this._events = new Events();\n  this._eventsCount = 0;\n}\n\n/**\n * Return an array listing the events for which the emitter has registered\n * listeners.\n *\n * @returns {Array}\n * @public\n */\nEventEmitter.prototype.eventNames = function eventNames() {\n  var names = []\n    , events\n    , name;\n\n  if (this._eventsCount === 0) return names;\n\n  for (name in (events = this._events)) {\n    if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);\n  }\n\n  if (Object.getOwnPropertySymbols) {\n    return names.concat(Object.getOwnPropertySymbols(events));\n  }\n\n  return names;\n};\n\n/**\n * Return the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Array} The registered listeners.\n * @public\n */\nEventEmitter.prototype.listeners = function listeners(event) {\n  var evt = prefix ? prefix + event : event\n    , handlers = this._events[evt];\n\n  if (!handlers) return [];\n  if (handlers.fn) return [handlers.fn];\n\n  for (var i = 0, l = handlers.length, ee = new Array(l); i \u003c l; i++) {\n    ee[i] = handlers[i].fn;\n  }\n\n  return ee;\n};\n\n/**\n * Return the number of listeners listening to a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Number} The number of listeners.\n * @public\n */\nEventEmitter.prototype.listenerCount = function listenerCount(event) {\n  var evt = prefix ? prefix + event : event\n    , listeners = this._events[evt];\n\n  if (!listeners) return 0;\n  if (listeners.fn) return 1;\n  return listeners.length;\n};\n\n/**\n * Calls each of the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Boolean} `true` if the event had listeners, else `false`.\n * @public\n */\nEventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {\n  var evt = prefix ? prefix + event : event;\n\n  if (!this._events[evt]) return false;\n\n  var listeners = this._events[evt]\n    , len = arguments.length\n    , args\n    , i;\n\n  if (listeners.fn) {\n    if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);\n\n    switch (len) {\n      case 1: return listeners.fn.call(listeners.context), true;\n      case 2: return listeners.fn.call(listeners.context, a1), true;\n      case 3: return listeners.fn.call(listeners.context, a1, a2), true;\n      case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;\n      case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;\n      case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;\n    }\n\n    for (i = 1, args = new Array(len -1); i \u003c len; i++) {\n      args[i - 1] = arguments[i];\n    }\n\n    listeners.fn.apply(listeners.context, args);\n  } else {\n    var length = listeners.length\n      , j;\n\n    for (i = 0; i \u003c length; i++) {\n      if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);\n\n      switch (len) {\n        case 1: listeners[i].fn.call(listeners[i].context); break;\n        case 2: listeners[i].fn.call(listeners[i].context, a1); break;\n        case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;\n        case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;\n        default:\n          if (!args) for (j = 1, args = new Array(len -1); j \u003c len; j++) {\n            args[j - 1] = arguments[j];\n          }\n\n          listeners[i].fn.apply(listeners[i].context, args);\n      }\n    }\n  }\n\n  return true;\n};\n\n/**\n * Add a listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.on = function on(event, fn, context) {\n  return addListener(this, event, fn, context, false);\n};\n\n/**\n * Add a one-time listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.once = function once(event, fn, context) {\n  return addListener(this, event, fn, context, true);\n};\n\n/**\n * Remove the listeners of a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn Only remove the listeners that match this function.\n * @param {*} context Only remove the listeners that have this context.\n * @param {Boolean} once Only remove one-time listeners.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {\n  var evt = prefix ? prefix + event : event;\n\n  if (!this._events[evt]) return this;\n  if (!fn) {\n    clearEvent(this, evt);\n    return this;\n  }\n\n  var listeners = this._events[evt];\n\n  if (listeners.fn) {\n    if (\n      listeners.fn === fn \u0026\u0026\n      (!once || listeners.once) \u0026\u0026\n      (!context || listeners.context === context)\n    ) {\n      clearEvent(this, evt);\n    }\n  } else {\n    for (var i = 0, events = [], length = listeners.length; i \u003c length; i++) {\n      if (\n        listeners[i].fn !== fn ||\n        (once \u0026\u0026 !listeners[i].once) ||\n        (context \u0026\u0026 listeners[i].context !== context)\n      ) {\n        events.push(listeners[i]);\n      }\n    }\n\n    //\n    // Reset the array, or remove it completely if we have no more listeners.\n    //\n    if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;\n    else clearEvent(this, evt);\n  }\n\n  return this;\n};\n\n/**\n * Remove all listeners, or those of the specified event.\n *\n * @param {(String|Symbol)} [event] The event name.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {\n  var evt;\n\n  if (event) {\n    evt = prefix ? prefix + event : event;\n    if (this._events[evt]) clearEvent(this, evt);\n  } else {\n    this._events = new Events();\n    this._eventsCount = 0;\n  }\n\n  return this;\n};\n\n//\n// Alias methods names because people roll like that.\n//\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\nEventEmitter.prototype.addListener = EventEmitter.prototype.on;\n\n//\n// Expose the prefix.\n//\nEventEmitter.prefixed = prefix;\n\n//\n// Allow `EventEmitter` to be imported as module namespace.\n//\nEventEmitter.EventEmitter = EventEmitter;\n\n//\n// Expose the module.\n//\nif ('undefined' !== typeof module) {\n  module.exports = EventEmitter;\n}\n","import EventEmitter from './index.js'\n\nexport { EventEmitter }\nexport default EventEmitter\n","export class TimeoutError extends Error {\n\tname = 'TimeoutError';\n\n\tconstructor(message, options) {\n\t\tsuper(message, options);\n\t\tError.captureStackTrace?.(this, TimeoutError);\n\t}\n}\n\nconst getAbortedReason = signal =\u003e signal.reason ?? new DOMException('This operation was aborted.', 'AbortError');\n\nexport default function pTimeout(promise, options) {\n\tconst {\n\t\tmilliseconds,\n\t\tfallback,\n\t\tmessage,\n\t\tcustomTimers = {setTimeout, clearTimeout},\n\t\tsignal,\n\t} = options;\n\n\tlet timer;\n\tlet abortHandler;\n\n\tconst wrappedPromise = new Promise((resolve, reject) =\u003e {\n\t\tif (typeof milliseconds !== 'number' || Math.sign(milliseconds) !== 1) {\n\t\t\tthrow new TypeError(`Expected \\`milliseconds\\` to be a positive number, got \\`${milliseconds}\\``);\n\t\t}\n\n\t\tif (signal?.aborted) {\n\t\t\treject(getAbortedReason(signal));\n\t\t\t// The input still needs a rejection handler even though cancellation won.\n\t\t\t// eslint-disable-next-line promise/prefer-await-to-then, promise/prefer-catch\n\t\t\tpromise.then(resolve, reject);\n\t\t\treturn;\n\t\t}\n\n\t\tif (signal) {\n\t\t\tabortHandler = () =\u003e {\n\t\t\t\treject(getAbortedReason(signal));\n\t\t\t};\n\n\t\t\tsignal.addEventListener('abort', abortHandler, {once: true});\n\t\t}\n\n\t\t// Use .then() instead of async IIFE to preserve stack traces\n\t\t// eslint-disable-next-line promise/prefer-await-to-then, promise/prefer-catch\n\t\tpromise.then(resolve, reject);\n\n\t\tif (milliseconds === Number.POSITIVE_INFINITY) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We create the error outside of `setTimeout` to preserve the stack trace.\n\t\tconst timeoutError = new TimeoutError();\n\n\t\t// `.call(undefined, ...)` is needed for custom timers to avoid context issues\n\t\ttimer = customTimers.setTimeout.call(undefined, () =\u003e {\n\t\t\tif (fallback) {\n\t\t\t\ttry {\n\t\t\t\t\tresolve(fallback());\n\t\t\t\t} catch (error) {\n\t\t\t\t\treject(error);\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (typeof promise.cancel === 'function') {\n\t\t\t\tpromise.cancel();\n\t\t\t}\n\n\t\t\tif (message === false) {\n\t\t\t\tresolve();\n\t\t\t} else if (message instanceof Error) {\n\t\t\t\treject(message);\n\t\t\t} else {\n\t\t\t\ttimeoutError.message = message ?? `Promise timed out after ${milliseconds} milliseconds`;\n\t\t\t\treject(timeoutError);\n\t\t\t}\n\t\t}, milliseconds);\n\t});\n\n\t// eslint-disable-next-line promise/prefer-await-to-then\n\tconst cancelablePromise = wrappedPromise.finally(() =\u003e {\n\t\tcancelablePromise.clear();\n\t\tif (abortHandler \u0026\u0026 signal) {\n\t\t\tsignal.removeEventListener('abort', abortHandler);\n\t\t}\n\t});\n\n\tcancelablePromise.clear = () =\u003e {\n\t\t// `.call(undefined, ...)` is needed for custom timers to avoid context issues\n\t\tcustomTimers.clearTimeout.call(undefined, timer);\n\t\ttimer = undefined;\n\t};\n\n\treturn cancelablePromise;\n}\n","// Port of lower_bound from https://en.cppreference.com/w/cpp/algorithm/lower_bound\n// Used to compute insertion index to keep queue sorted after insertion\nexport default function lowerBound(array, value, comparator) {\n    let first = 0;\n    let count = array.length;\n    while (count \u003e 0) {\n        const step = Math.trunc(count / 2);\n        let it = first + step;\n        if (comparator(array[it], value) \u003c= 0) {\n            first = ++it;\n            count -= step + 1;\n        }\n        else {\n            count = step;\n        }\n    }\n    return first;\n}\n","import lowerBound from './lower-bound.js';\nexport default class PriorityQueue {\n    #queue = [];\n    enqueue(run, options) {\n        const { priority = 0, id, } = options ?? {};\n        const element = {\n            priority,\n            id,\n            run,\n        };\n        if (this.size === 0 || this.#queue[this.size - 1].priority \u003e= priority) {\n            this.#queue.push(element);\n            return;\n        }\n        const index = lowerBound(this.#queue, element, (a, b) =\u003e b.priority - a.priority);\n        this.#queue.splice(index, 0, element);\n    }\n    setPriority(id, priority) {\n        const index = this.#queue.findIndex((element) =\u003e element.id === id);\n        if (index === -1) {\n            throw new ReferenceError(`No promise function with the id \"${id}\" exists in the queue.`);\n        }\n        const [item] = this.#queue.splice(index, 1);\n        this.enqueue(item.run, { priority, id });\n    }\n    dequeue() {\n        const item = this.#queue.shift();\n        return item?.run;\n    }\n    filter(options) {\n        return this.#queue.filter((element) =\u003e element.priority === options.priority).map((element) =\u003e element.run);\n    }\n    get size() {\n        return this.#queue.length;\n    }\n}\n","import { EventEmitter } from 'eventemitter3';\nimport pTimeout from 'p-timeout';\nimport PriorityQueue from './priority-queue.js';\n/**\nPromise queue with concurrency control.\n*/\nexport default class PQueue extends EventEmitter {\n    #carryoverIntervalCount;\n    #isIntervalIgnored;\n    #intervalCount = 0;\n    #intervalCap;\n    #rateLimitedInInterval = false;\n    #rateLimitFlushScheduled = false;\n    #interval;\n    #intervalEnd = 0;\n    #lastExecutionTime = 0;\n    #intervalId;\n    #timeoutId;\n    #queue;\n    #queueClass;\n    #pending = 0;\n    // The `!` is needed because of https://github.com/microsoft/TypeScript/issues/32194\n    #concurrency;\n    #isPaused;\n    // Use to assign a unique identifier to a promise function, if not explicitly specified\n    #idAssigner = 1n;\n    // Track currently running tasks for debugging\n    #runningTasks = new Map();\n    /**\n    Get or set the default timeout for all tasks. Can be changed at runtime.\n\n    Operations will throw a `TimeoutError` if they don't complete within the specified time.\n\n    The timeout begins when the operation is dequeued and starts execution, not while it's waiting in the queue.\n\n    @example\n    ```\n    const queue = new PQueue({timeout: 5000});\n\n    // Change timeout for all future tasks\n    queue.timeout = 10000;\n    ```\n    */\n    timeout;\n    constructor(options) {\n        super();\n        // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n        options = {\n            carryoverIntervalCount: false,\n            intervalCap: Number.POSITIVE_INFINITY,\n            interval: 0,\n            concurrency: Number.POSITIVE_INFINITY,\n            autoStart: true,\n            queueClass: PriorityQueue,\n            ...options,\n        };\n        if (!(typeof options.intervalCap === 'number' \u0026\u0026 options.intervalCap \u003e= 1)) {\n            throw new TypeError(`Expected \\`intervalCap\\` to be a number from 1 and up, got \\`${options.intervalCap?.toString() ?? ''}\\` (${typeof options.intervalCap})`);\n        }\n        if (options.interval === undefined || !(Number.isFinite(options.interval) \u0026\u0026 options.interval \u003e= 0)) {\n            throw new TypeError(`Expected \\`interval\\` to be a finite number \u003e= 0, got \\`${options.interval?.toString() ?? ''}\\` (${typeof options.interval})`);\n        }\n        // TODO: Remove this fallback in the next major version\n        // eslint-disable-next-line @typescript-eslint/no-deprecated\n        this.#carryoverIntervalCount = options.carryoverIntervalCount ?? options.carryoverConcurrencyCount ?? false;\n        this.#isIntervalIgnored = options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0;\n        this.#intervalCap = options.intervalCap;\n        this.#interval = options.interval;\n        this.#queue = new options.queueClass();\n        this.#queueClass = options.queueClass;\n        this.concurrency = options.concurrency;\n        if (options.timeout !== undefined \u0026\u0026 !(Number.isFinite(options.timeout) \u0026\u0026 options.timeout \u003e 0)) {\n            throw new TypeError(`Expected \\`timeout\\` to be a positive finite number, got \\`${options.timeout}\\` (${typeof options.timeout})`);\n        }\n        this.timeout = options.timeout;\n        this.#isPaused = options.autoStart === false;\n        this.#setupRateLimitTracking();\n    }\n    get #doesIntervalAllowAnother() {\n        return this.#isIntervalIgnored || this.#intervalCount \u003c this.#intervalCap;\n    }\n    get #doesConcurrentAllowAnother() {\n        return this.#pending \u003c this.#concurrency;\n    }\n    #next() {\n        this.#pending--;\n        if (this.#pending === 0) {\n            this.emit('pendingZero');\n        }\n        this.#tryToStartAnother();\n        this.emit('next');\n    }\n    #onResumeInterval() {\n        this.#onInterval(); // Already schedules update\n        this.#initializeIntervalIfNeeded();\n        this.#timeoutId = undefined;\n    }\n    get #isIntervalPaused() {\n        const now = Date.now();\n        if (this.#intervalId === undefined) {\n            const delay = this.#intervalEnd - now;\n            if (delay \u003c 0) {\n                // If the interval has expired while idle, check if we should enforce the interval\n                // from the last task execution. This ensures proper spacing between tasks even\n                // when the queue becomes empty and then new tasks are added.\n                if (this.#lastExecutionTime \u003e 0) {\n                    const timeSinceLastExecution = now - this.#lastExecutionTime;\n                    if (timeSinceLastExecution \u003c this.#interval) {\n                        // Not enough time has passed since the last task execution\n                        this.#createIntervalTimeout(this.#interval - timeSinceLastExecution);\n                        return true;\n                    }\n                }\n                // Enough time has passed or no previous execution, allow execution\n                this.#intervalCount = (this.#carryoverIntervalCount) ? this.#pending : 0;\n            }\n            else {\n                // Act as the interval is pending\n                this.#createIntervalTimeout(delay);\n                return true;\n            }\n        }\n        return false;\n    }\n    #createIntervalTimeout(delay) {\n        if (this.#timeoutId !== undefined) {\n            return;\n        }\n        this.#timeoutId = setTimeout(() =\u003e {\n            this.#onResumeInterval();\n        }, delay);\n    }\n    #clearIntervalTimer() {\n        if (this.#intervalId) {\n            clearInterval(this.#intervalId);\n            this.#intervalId = undefined;\n        }\n    }\n    #clearTimeoutTimer() {\n        if (this.#timeoutId) {\n            clearTimeout(this.#timeoutId);\n            this.#timeoutId = undefined;\n        }\n    }\n    #tryToStartAnother() {\n        if (this.#queue.size === 0) {\n            // We can clear the interval (\"pause\")\n            // Because we can redo it later (\"resume\")\n            this.#clearIntervalTimer();\n            this.emit('empty');\n            if (this.#pending === 0) {\n                // Clear timeout as well when completely idle\n                this.#clearTimeoutTimer();\n                this.emit('idle');\n            }\n            return false;\n        }\n        let taskStarted = false;\n        if (!this.#isPaused) {\n            const canInitializeInterval = !this.#isIntervalPaused;\n            if (this.#doesIntervalAllowAnother \u0026\u0026 this.#doesConcurrentAllowAnother) {\n                const job = this.#queue.dequeue();\n                // Increment interval count immediately to prevent race conditions\n                if (!this.#isIntervalIgnored) {\n                    this.#intervalCount++;\n                    this.#scheduleRateLimitUpdate();\n                }\n                this.emit('active');\n                this.#lastExecutionTime = Date.now();\n                job();\n                if (canInitializeInterval) {\n                    this.#initializeIntervalIfNeeded();\n                }\n                taskStarted = true;\n            }\n        }\n        return taskStarted;\n    }\n    #initializeIntervalIfNeeded() {\n        if (this.#isIntervalIgnored || this.#intervalId !== undefined) {\n            return;\n        }\n        this.#intervalId = setInterval(() =\u003e {\n            this.#onInterval();\n        }, this.#interval);\n        this.#intervalEnd = Date.now() + this.#interval;\n    }\n    #onInterval() {\n        if (this.#intervalCount === 0 \u0026\u0026 this.#pending === 0 \u0026\u0026 this.#intervalId) {\n            this.#clearIntervalTimer();\n        }\n        this.#intervalCount = this.#carryoverIntervalCount ? this.#pending : 0;\n        this.#processQueue();\n        this.#scheduleRateLimitUpdate();\n    }\n    /**\n    Executes all queued functions until it reaches the limit.\n    */\n    #processQueue() {\n        // eslint-disable-next-line no-empty\n        while (this.#tryToStartAnother()) { }\n    }\n    get concurrency() {\n        return this.#concurrency;\n    }\n    set concurrency(newConcurrency) {\n        if (!(typeof newConcurrency === 'number' \u0026\u0026 newConcurrency \u003e= 1)) {\n            throw new TypeError(`Expected \\`concurrency\\` to be a number from 1 and up, got \\`${newConcurrency}\\` (${typeof newConcurrency})`);\n        }\n        this.#concurrency = newConcurrency;\n        this.#processQueue();\n    }\n    /**\n    Updates the priority of a promise function by its id, affecting its execution order. Requires a defined concurrency limit to take effect.\n\n    For example, this can be used to prioritize a promise function to run earlier.\n\n    ```js\n    import PQueue from 'p-queue';\n\n    const queue = new PQueue({concurrency: 1});\n\n    queue.add(async () =\u003e '🦄', {priority: 1});\n    queue.add(async () =\u003e '🦀', {priority: 0, id: '🦀'});\n    queue.add(async () =\u003e '🦄', {priority: 1});\n    queue.add(async () =\u003e '🦄', {priority: 1});\n\n    queue.setPriority('🦀', 2);\n    ```\n\n    In this case, the promise function with `id: '🦀'` runs second.\n\n    You can also deprioritize a promise function to delay its execution:\n\n    ```js\n    import PQueue from 'p-queue';\n\n    const queue = new PQueue({concurrency: 1});\n\n    queue.add(async () =\u003e '🦄', {priority: 1});\n    queue.add(async () =\u003e '🦀', {priority: 1, id: '🦀'});\n    queue.add(async () =\u003e '🦄');\n    queue.add(async () =\u003e '🦄', {priority: 0});\n\n    queue.setPriority('🦀', -1);\n    ```\n    Here, the promise function with `id: '🦀'` executes last.\n    */\n    setPriority(id, priority) {\n        if (typeof priority !== 'number' || !Number.isFinite(priority)) {\n            throw new TypeError(`Expected \\`priority\\` to be a finite number, got \\`${priority}\\` (${typeof priority})`);\n        }\n        this.#queue.setPriority(id, priority);\n    }\n    async add(function_, options = {}) {\n        // In case `id` is not defined.\n        options.id ??= (this.#idAssigner++).toString();\n        options = {\n            timeout: this.timeout,\n            ...options,\n        };\n        return new Promise((resolve, reject) =\u003e {\n            // Create a unique symbol for tracking this task\n            const taskSymbol = Symbol(`task-${options.id}`);\n            this.#queue.enqueue(async () =\u003e {\n                this.#pending++;\n                // Track this running task\n                this.#runningTasks.set(taskSymbol, {\n                    id: options.id,\n                    priority: options.priority ?? 0, // Match priority-queue default\n                    startTime: Date.now(),\n                    timeout: options.timeout,\n                });\n                let eventListener;\n                try {\n                    // Check abort signal - if aborted, need to decrement the counter\n                    // that was incremented in tryToStartAnother\n                    try {\n                        options.signal?.throwIfAborted();\n                    }\n                    catch (error) {\n                        // Decrement the counter that was already incremented\n                        if (!this.#isIntervalIgnored) {\n                            this.#intervalCount--;\n                        }\n                        // Clean up tracking before throwing\n                        this.#runningTasks.delete(taskSymbol);\n                        throw error;\n                    }\n                    let operation = function_({ signal: options.signal });\n                    if (options.timeout) {\n                        operation = pTimeout(Promise.resolve(operation), {\n                            milliseconds: options.timeout,\n                            message: `Task timed out after ${options.timeout}ms (queue has ${this.#pending} running, ${this.#queue.size} waiting)`,\n                        });\n                    }\n                    if (options.signal) {\n                        const { signal } = options;\n                        operation = Promise.race([operation, new Promise((_resolve, reject) =\u003e {\n                                eventListener = () =\u003e {\n                                    reject(signal.reason);\n                                };\n                                signal.addEventListener('abort', eventListener, { once: true });\n                            })]);\n                    }\n                    const result = await operation;\n                    resolve(result);\n                    this.emit('completed', result);\n                }\n                catch (error) {\n                    reject(error);\n                    this.emit('error', error);\n                }\n                finally {\n                    // Clean up abort event listener\n                    if (eventListener) {\n                        options.signal?.removeEventListener('abort', eventListener);\n                    }\n                    // Remove from running tasks\n                    this.#runningTasks.delete(taskSymbol);\n                    // Use queueMicrotask to prevent deep recursion while maintaining timing\n                    queueMicrotask(() =\u003e {\n                        this.#next();\n                    });\n                }\n            }, options);\n            this.emit('add');\n            this.#tryToStartAnother();\n        });\n    }\n    async addAll(functions, options) {\n        return Promise.all(functions.map(async (function_) =\u003e this.add(function_, options)));\n    }\n    /**\n    Start (or resume) executing enqueued tasks within concurrency limit. No need to call this if queue is not paused (via `options.autoStart = false` or by `.pause()` method.)\n    */\n    start() {\n        if (!this.#isPaused) {\n            return this;\n        }\n        this.#isPaused = false;\n        this.#processQueue();\n        return this;\n    }\n    /**\n    Put queue execution on hold.\n    */\n    pause() {\n        this.#isPaused = true;\n    }\n    /**\n    Clear the queue.\n    */\n    clear() {\n        this.#queue = new this.#queueClass();\n        // Note: We don't clear #runningTasks as those tasks are still running\n        // They will be removed when they complete in the finally block\n        // Force synchronous update since clear() should have immediate effect\n        this.#updateRateLimitState();\n    }\n    /**\n    Can be called multiple times. Useful if you for example add additional items at a later time.\n\n    @returns A promise that settles when the queue becomes empty.\n    */\n    async onEmpty() {\n        // Instantly resolve if the queue is empty\n        if (this.#queue.size === 0) {\n            return;\n        }\n        await this.#onEvent('empty');\n    }\n    /**\n    @returns A promise that settles when the queue size is less than the given limit: `queue.size \u003c limit`.\n\n    If you want to avoid having the queue grow beyond a certain size you can `await queue.onSizeLessThan()` before adding a new item.\n\n    Note that this only limits the number of items waiting to start. There could still be up to `concurrency` jobs already running that this call does not include in its calculation.\n    */\n    async onSizeLessThan(limit) {\n        // Instantly resolve if the queue is empty.\n        if (this.#queue.size \u003c limit) {\n            return;\n        }\n        await this.#onEvent('next', () =\u003e this.#queue.size \u003c limit);\n    }\n    /**\n    The difference with `.onEmpty` is that `.onIdle` guarantees that all work from the queue has finished. `.onEmpty` merely signals that the queue is empty, but it could mean that some promises haven't completed yet.\n\n    @returns A promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 \u0026\u0026 queue.pending === 0`.\n    */\n    async onIdle() {\n        // Instantly resolve if none pending and if nothing else is queued\n        if (this.#pending === 0 \u0026\u0026 this.#queue.size === 0) {\n            return;\n        }\n        await this.#onEvent('idle');\n    }\n    /**\n    The difference with `.onIdle` is that `.onPendingZero` only waits for currently running tasks to finish, ignoring queued tasks.\n\n    @returns A promise that settles when all currently running tasks have completed; `queue.pending === 0`.\n    */\n    async onPendingZero() {\n        if (this.#pending === 0) {\n            return;\n        }\n        await this.#onEvent('pendingZero');\n    }\n    /**\n    @returns A promise that settles when the queue becomes rate-limited due to intervalCap.\n    */\n    async onRateLimit() {\n        if (this.isRateLimited) {\n            return;\n        }\n        await this.#onEvent('rateLimit');\n    }\n    /**\n    @returns A promise that settles when the queue is no longer rate-limited.\n    */\n    async onRateLimitCleared() {\n        if (!this.isRateLimited) {\n            return;\n        }\n        await this.#onEvent('rateLimitCleared');\n    }\n    /**\n    @returns A promise that rejects when any task in the queue errors.\n\n    Use with `Promise.race([queue.onError(), queue.onIdle()])` to fail fast on the first error while still resolving normally when the queue goes idle.\n\n    Important: The promise returned by `add()` still rejects. You must handle each `add()` promise (for example, `.catch(() =\u003e {})`) to avoid unhandled rejections.\n\n    @example\n    ```\n    import PQueue from 'p-queue';\n\n    const queue = new PQueue({concurrency: 2});\n\n    queue.add(() =\u003e fetchData(1)).catch(() =\u003e {});\n    queue.add(() =\u003e fetchData(2)).catch(() =\u003e {});\n    queue.add(() =\u003e fetchData(3)).catch(() =\u003e {});\n\n    // Stop processing on first error\n    try {\n        await Promise.race([\n            queue.onError(),\n            queue.onIdle()\n        ]);\n    } catch (error) {\n        queue.pause(); // Stop processing remaining tasks\n        console.error('Queue failed:', error);\n    }\n    ```\n    */\n    // eslint-disable-next-line @typescript-eslint/promise-function-async\n    async onError() {\n        return new Promise((_resolve, reject) =\u003e {\n            const handleError = (error) =\u003e {\n                this.off('error', handleError);\n                reject(error);\n            };\n            this.on('error', handleError);\n        });\n    }\n    async #onEvent(event, filter) {\n        return new Promise(resolve =\u003e {\n            const listener = () =\u003e {\n                if (filter \u0026\u0026 !filter()) {\n                    return;\n                }\n                this.off(event, listener);\n                resolve();\n            };\n            this.on(event, listener);\n        });\n    }\n    /**\n    Size of the queue, the number of queued items waiting to run.\n    */\n    get size() {\n        return this.#queue.size;\n    }\n    /**\n    Size of the queue, filtered by the given options.\n\n    For example, this can be used to find the number of items remaining in the queue with a specific priority level.\n    */\n    sizeBy(options) {\n        // eslint-disable-next-line unicorn/no-array-callback-reference\n        return this.#queue.filter(options).length;\n    }\n    /**\n    Number of running items (no longer in the queue).\n    */\n    get pending() {\n        return this.#pending;\n    }\n    /**\n    Whether the queue is currently paused.\n    */\n    get isPaused() {\n        return this.#isPaused;\n    }\n    #setupRateLimitTracking() {\n        // Only schedule updates when rate limiting is enabled\n        if (this.#isIntervalIgnored) {\n            return;\n        }\n        // Wire up to lifecycle events that affect rate limit state\n        // Only 'add' and 'next' can actually change rate limit state\n        this.on('add', () =\u003e {\n            if (this.#queue.size \u003e 0) {\n                this.#scheduleRateLimitUpdate();\n            }\n        });\n        this.on('next', () =\u003e {\n            this.#scheduleRateLimitUpdate();\n        });\n    }\n    #scheduleRateLimitUpdate() {\n        // Skip if rate limiting is not enabled or already scheduled\n        if (this.#isIntervalIgnored || this.#rateLimitFlushScheduled) {\n            return;\n        }\n        this.#rateLimitFlushScheduled = true;\n        queueMicrotask(() =\u003e {\n            this.#rateLimitFlushScheduled = false;\n            this.#updateRateLimitState();\n        });\n    }\n    #updateRateLimitState() {\n        const previous = this.#rateLimitedInInterval;\n        const shouldBeRateLimited = !this.#isIntervalIgnored\n            \u0026\u0026 this.#intervalCount \u003e= this.#intervalCap\n            \u0026\u0026 this.#queue.size \u003e 0;\n        if (shouldBeRateLimited !== previous) {\n            this.#rateLimitedInInterval = shouldBeRateLimited;\n            this.emit(shouldBeRateLimited ? 'rateLimit' : 'rateLimitCleared');\n        }\n    }\n    /**\n    Whether the queue is currently rate-limited due to intervalCap.\n    */\n    get isRateLimited() {\n        return this.#rateLimitedInInterval;\n    }\n    /**\n    Whether the queue is saturated. Returns `true` when:\n    - All concurrency slots are occupied and tasks are waiting, OR\n    - The queue is rate-limited and tasks are waiting\n\n    Useful for detecting backpressure and potential hanging tasks.\n\n    ```js\n    import PQueue from 'p-queue';\n\n    const queue = new PQueue({concurrency: 2});\n\n    // Backpressure handling\n    if (queue.isSaturated) {\n        console.log('Queue is saturated, waiting for capacity...');\n        await queue.onSizeLessThan(queue.concurrency);\n    }\n\n    // Monitoring for stuck tasks\n    setInterval(() =\u003e {\n        if (queue.isSaturated) {\n            console.warn(`Queue saturated: ${queue.pending} running, ${queue.size} waiting`);\n        }\n    }, 60000);\n    ```\n    */\n    get isSaturated() {\n        return (this.#pending === this.#concurrency \u0026\u0026 this.#queue.size \u003e 0)\n            || (this.isRateLimited \u0026\u0026 this.#queue.size \u003e 0);\n    }\n    /**\n    The tasks currently being executed. Each task includes its `id`, `priority`, `startTime`, and `timeout` (if set).\n\n    Returns an array of task info objects.\n\n    ```js\n    import PQueue from 'p-queue';\n\n    const queue = new PQueue({concurrency: 2});\n\n    // Add tasks with IDs for better debugging\n    queue.add(() =\u003e fetchUser(123), {id: 'user-123'});\n    queue.add(() =\u003e fetchPosts(456), {id: 'posts-456', priority: 1});\n\n    // Check what's running\n    console.log(queue.runningTasks);\n    // =\u003e [{\n    //   id: 'user-123',\n    //   priority: 0,\n    //   startTime: 1759253001716,\n    //   timeout: undefined\n    // }, {\n    //   id: 'posts-456',\n    //   priority: 1,\n    //   startTime: 1759253001916,\n    //   timeout: undefined\n    // }]\n    ```\n    */\n    get runningTasks() {\n        // Return fresh array with fresh objects to prevent mutations\n        return [...this.#runningTasks.values()].map(task =\u003e ({ ...task }));\n    }\n}\n/**\nError thrown when a task times out.\n\n@example\n```\nimport PQueue, {TimeoutError} from 'p-queue';\n\nconst queue = new PQueue({timeout: 1000});\n\ntry {\n    await queue.add(() =\u003e someTask());\n} catch (error) {\n    if (error instanceof TimeoutError) {\n        console.log('Task timed out');\n    }\n}\n```\n*/\nexport { TimeoutError } from 'p-timeout';\n"],"version":3}
