/**
* Request deduplication utility
* Manages pending requests to prevent concurrent duplicate requests
*/
var RequestDeduplicator = class {
	constructor() {
		this.pendingRequests = /* @__PURE__ */ new Map();
	}
	/**
	* Execute a request with deduplication
	* If a request with the same key is already pending, return the existing promise
	* Otherwise, execute the request factory and track the promise
	*/
	async executeRequest(key, requestFactory) {
		const existingRequest = this.pendingRequests.get(key);
		if (existingRequest) return existingRequest;
		const requestPromise = requestFactory();
		this.pendingRequests.set(key, requestPromise);
		try {
			const result = await requestPromise;
			this.pendingRequests.delete(key);
			return result;
		} catch (error) {
			this.pendingRequests.delete(key);
			throw error;
		}
	}
	/**
	* Clear all pending requests (used in cache clearing)
	*/
	clear() {
		this.pendingRequests.clear();
	}
	/**
	* Get number of pending requests
	*/
	getPendingCount() {
		return this.pendingRequests.size;
	}
	/**
	* Check if a request is pending
	*/
	isPending(key) {
		return this.pendingRequests.has(key);
	}
	/**
	* Get all pending request keys
	*/
	getPendingKeys() {
		return Array.from(this.pendingRequests.keys());
	}
};
export { RequestDeduplicator };
