/**
 * Sticky Session Manager Module
 *
 * Sticky session and alias lease management extracted from VirtualRouterEngine.
 */
export class StickySessionManager {
    aliasQueueStore = new Map();
    antigravityAliasLeaseStore = new Map();
    antigravitySessionAliasStore = new Map();
    antigravityAliasReuseCooldownMs = 5 * 60_000;
    constructor(aliasReuseCooldownMs) {
        if (typeof aliasReuseCooldownMs === 'number' && aliasReuseCooldownMs > 0) {
            this.antigravityAliasReuseCooldownMs = aliasReuseCooldownMs;
        }
    }
    // Alias queue management
    getAliasQueue(alias) {
        return this.aliasQueueStore.get(alias);
    }
    setAliasQueue(alias, queue) {
        this.aliasQueueStore.set(alias, queue);
    }
    // Antigravity alias lease
    getAliasLease(alias) {
        return this.antigravityAliasLeaseStore.get(alias);
    }
    setAliasLease(alias, lease) {
        this.antigravityAliasLeaseStore.set(alias, lease);
    }
    // Session alias mapping
    getSessionAlias(sessionKey) {
        return this.antigravitySessionAliasStore.get(sessionKey);
    }
    setSessionAlias(sessionKey, alias) {
        this.antigravitySessionAliasStore.set(sessionKey, alias);
    }
    // Cooldown resolution
    getAliasReuseCooldownMs() {
        return this.antigravityAliasReuseCooldownMs;
    }
    // Hydrate from external store (placeholder for future persistence)
    hydrateFromStore(store) {
        for (const [alias, lease] of store.entries()) {
            this.antigravityAliasLeaseStore.set(alias, lease);
        }
    }
    // Get all stores for persistence
    getAllStores() {
        return {
            aliasQueueStore: this.aliasQueueStore,
            aliasLeaseStore: this.antigravityAliasLeaseStore,
            sessionAliasStore: this.antigravitySessionAliasStore
        };
    }
}
