"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleProfessionalTone = void 0;
const invariant_1 = __importDefault(require("../../util/invariant"));
const handleProfessionalTone = async ({ assertion, renderedValue, prompt, output, test, evaluateResult, }) => {
    if (evaluateResult) {
        (0, invariant_1.default)(typeof output === 'object' && output !== null, 'Expected output to be an object with agent and customer tone evaluations');
        // Define expected structure
        const tones = output;
        const agentTone = (tones.agent || '').toLowerCase();
        const customerTone = (tones.customer || '').toLowerCase();
        const offenders = [];
        if (agentTone === 'unprofessional') {
            offenders.push('agent');
        }
        if (customerTone === 'unprofessional') {
            offenders.push('customer');
        }
        const pass = offenders.length === 0;
        const reason = pass
            ? 'Both maintained professional tone.'
            : `Unprofessional tone used by: ${offenders.join(', ')}`;
        return {
            pass,
            score: pass ? 1 : 0,
            reason,
            assertion,
        };
    }
    else {
        return {
            pass: true,
            score: 1,
            reason: '',
            metadata: {
                prompt: `Analyze the tone of the audio for each speaker and classify their tone individually as either 'professional' or 'unprofessional'. Provide the result in a JSON object using the metric 'professional-tone' with keys 'agent' and 'customer'.`,
                metric: `"professional-tone": { "agent": "professional", "customer": "professional" },`,
            },
        };
    }
};
exports.handleProfessionalTone = handleProfessionalTone;
//# sourceMappingURL=audioProfessionalTone.js.map