/**
 * History Store
 * Phase 4: Rolling buffer for sparkline data
 */
import { SPARKLINE_HISTORY_SIZE } from '../core/constants.js';
/**
 * Rolling buffer for metric samples
 */
class HistoryStore {
    buffers = new Map();
    constructor() {
        // Initialize buffers
        this.buffers.set('cpu', []);
        this.buffers.set('ram', []);
        this.buffers.set('latency', []);
    }
    /**
     * Add sample to metric buffer
     * Maintains last N samples, discards oldest
     */
    addSample(key, value) {
        const buffer = this.buffers.get(key);
        if (!buffer)
            return;
        buffer.push(value);
        // Keep only last N samples
        if (buffer.length > SPARKLINE_HISTORY_SIZE) {
            buffer.shift();
        }
    }
    /**
     * Get last N samples for metric
     */
    getSamples(key) {
        const buffer = this.buffers.get(key);
        return buffer ? [...buffer] : [];
    }
    /**
     * Clear all buffers
     */
    clear() {
        this.buffers.forEach(buffer => buffer.length = 0);
    }
    /**
     * Clear specific metric buffer
     */
    clearMetric(key) {
        const buffer = this.buffers.get(key);
        if (buffer) {
            buffer.length = 0;
        }
    }
}
/**
 * Global history store instance
 */
export const historyStore = new HistoryStore();
//# sourceMappingURL=historyStore.js.map