<?php
declare(strict_types=1);

require_once __DIR__ . '/../includes/LegalTools.php';

dbnToolsRequireMethod('POST');
dbnToolsRequireAuth();
$input = dbnToolsJsonInput(70000);
$language = dbnToolsNormalizeLanguage($input['language'] ?? 'en');

dbnToolsWithTelemetry('summarize', $language, function () use ($input, $language): array {
    $text = dbnToolsString($input, 'text', 32000);
    return (new DbnLegalToolsService())->summarize($text, $language);
});
