"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EchoProvider = void 0;
const time_1 = require("../util/time");
class EchoProvider {
    constructor(options = {}) {
        this.options = options;
        this.id = options.id ? () => options.id : this.id;
        this.label = options.label;
        this.config = options.config;
        this.delay = options.delay;
    }
    id() {
        return 'echo';
    }
    toString() {
        return '[Echo Provider]';
    }
    async callApi(input, options, context) {
        if (this.delay && this.delay > 0) {
            await (0, time_1.sleep)(this.delay);
        }
        let inputJson = {};
        try {
            inputJson = JSON.parse(input);
        }
        catch { }
        // Create a complete ProviderResponse object
        let response = {};
        if (inputJson && inputJson.type === 'audio') {
            response = {
                output: 'no-transcript',
                audio: {
                    data: inputJson?.data,
                    transcript: inputJson?.transcript,
                    format: inputJson?.format || 'wav',
                },
                raw: input,
                cost: 0,
                cached: false,
                tokenUsage: {
                    total: 0,
                    prompt: 0,
                    completion: 0,
                },
                isRefusal: false,
                metadata: context?.metadata || {},
            };
        }
        else if (inputJson && inputJson.type === 'video') {
            response = {
                output: inputJson?.caption || 'no-caption',
                video: {
                    data: inputJson?.data,
                    caption: inputJson?.caption,
                    format: inputJson?.format || 'mp4',
                    url: inputJson?.url,
                },
                raw: input,
                cost: 0,
                cached: false,
                tokenUsage: {
                    total: 0,
                    prompt: 0,
                    completion: 0,
                },
                isRefusal: false,
                metadata: context?.metadata || {},
            };
        }
        else {
            response = {
                output: input,
                raw: input,
                cost: 0,
                cached: false,
                tokenUsage: {
                    total: 0,
                    prompt: 0,
                    completion: 0,
                },
                isRefusal: false,
                metadata: context?.metadata || {},
            };
        }
        return response;
    }
}
exports.EchoProvider = EchoProvider;
//# sourceMappingURL=echo.js.map