import { defineHandler } from '@kb-labs/sdk';
import { loadHistory, analyzeEnrichedTrends, analyzeTrends } from '@kb-labs/qa-core';
import { TRENDS_WINDOW } from '@kb-labs/qa-contracts';

// src/rest/handlers/trends-handler.ts
var trends_handler_default = defineHandler({
  async execute(ctx, input) {
    const window = input.query?.window ? Number(input.query.window) : TRENDS_WINDOW;
    const enriched = String(input.query?.enriched) === "true";
    const history = loadHistory(ctx.cwd);
    if (enriched) {
      const trends2 = analyzeEnrichedTrends(history, window);
      return {
        trends: trends2,
        historyCount: history.length,
        window
      };
    }
    const trends = analyzeTrends(history, window);
    return {
      trends,
      historyCount: history.length,
      window
    };
  }
});

export { trends_handler_default as default };
//# sourceMappingURL=trends-handler.js.map
//# sourceMappingURL=trends-handler.js.map