<?php

declare(strict_types=1);

namespace App\Domain\Ai;

use App\Contracts\LlmProvider;

class StubLlmProvider implements LlmProvider
{
    public function complete(string $prompt, array $context = []): array
    {
        $title = trim((string) ($context['title'] ?? 'Untitled'));

        return [
            'summary' => 'Stub summary for «'.$title.'».',
            'description' => 'Stub SEO description for '.$title.'.',
            'polished_content' => trim($prompt)."\n\n<!-- stub polished -->",
            'suggestions' => [
                'Review headings for clarity.',
                'Add a concise meta description.',
            ],
        ];
    }

    public function moderate(string $content): array
    {
        $blocked = str_contains(strtolower($content), 'spam');

        return [
            'status' => $blocked ? 'rejected' : 'approved',
            'reason' => $blocked ? 'Detected spam keyword in stub provider.' : null,
        ];
    }
}
