"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StreamingTokenTracker = void 0;
/**
 * StreamingTokenTracker - Synchronous token counting for streaming deltas
 *
 * Simplified tracker that provides immediate token counts for each delta.
 * TPS calculation moved to frontend for better replay support and flexibility.
 */
const tokenizer_1 = require("./tokenizer");
/**
 * StreamingTokenTracker provides synchronous token counting
 */
class StreamingTokenTracker {
    tokenizer = null;
    /**
     * Initialize tokenizer for the current model
     * Should be called when model changes or on first stream
     */
    setModel(model) {
        this.tokenizer ?? (this.tokenizer = (0, tokenizer_1.getTokenizerForModel)(model));
    }
    /**
     * Count tokens in a text string synchronously
     * Performance: <1ms per delta with LRU caching
     */
    countTokens(text) {
        if (!this.tokenizer || !text)
            return 0;
        return this.tokenizer.countTokens(text);
    }
}
exports.StreamingTokenTracker = StreamingTokenTracker;
//# sourceMappingURL=StreamingTokenTracker.js.map