import { computeEffectiveSafeWindowTokens } from '../context-weighted.js';
export function computeContextWeightMultipliers(opts) {
    const { candidates, usage, warnRatio, cfg } = opts;
    if (!cfg.enabled) {
        return null;
    }
    const eff = {};
    let ref = 1;
    for (const key of candidates) {
        const entry = usage?.[key];
        const limit = entry && typeof entry.limit === 'number' && Number.isFinite(entry.limit) ? Math.floor(entry.limit) : 0;
        const safeEff = computeEffectiveSafeWindowTokens({
            modelMaxTokens: Math.max(1, limit),
            warnRatio,
            clientCapTokens: cfg.clientCapTokens
        });
        eff[key] = safeEff;
        if (safeEff > ref) {
            ref = safeEff;
        }
    }
    return { ref, eff };
}
