"use strict";
var import_vitest = require("vitest");
var import_chat_context = require("../llm/chat_context.cjs");
var import_log = require("../log.cjs");
var import_audio_recognition = require("./audio_recognition.cjs");
var import_endpointing = require("./turn_config/endpointing.cjs");
function createHooks() {
  return {
    onInterruption: () => {
    },
    onStartOfSpeech: () => {
    },
    onVADInferenceDone: () => {
    },
    onEndOfSpeech: () => {
    },
    onInterimTranscript: () => {
    },
    onFinalTranscript: () => {
    },
    onPreemptiveGeneration: () => {
    },
    onAgentBackchannelOpportunity: () => {
    },
    retrieveChatCtx: () => import_chat_context.ChatContext.empty(),
    onEndOfTurn: async () => true
  };
}
class RecordingEndpointing extends import_endpointing.BaseEndpointing {
  speechStarts = [];
  onStartOfSpeech(startedAt, overlapping = false) {
    super.onStartOfSpeech(startedAt, overlapping);
    this.speechStarts.push({ startedAt, overlapping });
  }
}
(0, import_vitest.describe)("AudioRecognition endpointing integration", () => {
  (0, import_log.initializeLogger)({ pretty: false, level: "silent" });
  (0, import_vitest.it)("marks endpointing overlap when audio activity starts while the agent is speaking", async () => {
    const endpointing = new RecordingEndpointing({ minDelay: 300, maxDelay: 3e3 });
    const recognition = new import_audio_recognition.AudioRecognition({
      recognitionHooks: createHooks(),
      endpointing
    });
    await recognition.onStartOfAgentSpeech(1e3);
    await recognition.onStartOfOverlapSpeech(0, 1200);
    await recognition.onStartOfOverlapSpeech(0, 1300);
    (0, import_vitest.expect)(endpointing.speechStarts).toEqual([{ startedAt: 1200, overlapping: true }]);
    (0, import_vitest.expect)(endpointing.overlapping).toBe(true);
  });
});
//# sourceMappingURL=audio_recognition_endpointing.test.cjs.map