<?php

namespace GriffinForms\Includes\Ai\PromptRegistry;

use GriffinForms\Includes\Ai\PromptRegistry\Handlers\BasePromptHandler;
use GriffinForms\Includes\Ai\PromptRegistry\Handlers\AdvisoryResponsePromptHandler;
use GriffinForms\Includes\Ai\PromptRegistry\Handlers\GenerateBulkTextMutationPromptHandler;
use GriffinForms\Includes\Ai\PromptRegistry\Handlers\GenerateFieldLabelPromptHandler;
use GriffinForms\Includes\Ai\PromptRegistry\Handlers\GeneratePlaceholderPromptHandler;
use GriffinForms\Includes\Ai\PromptRegistry\Handlers\GenerateFormThemePromptHandler;
use GriffinForms\Includes\Ai\PromptRegistry\Handlers\GenerateSelectFieldOptionsPromptHandler;
use GriffinForms\Includes\Ai\PromptRegistry\Handlers\GeneratePatchPlanPromptHandler;
use GriffinForms\Includes\Ai\PromptRegistry\Handlers\GenerateFoundationPromptHandler;
// Issue 4 — new operation type handlers
use GriffinForms\Includes\Ai\PromptRegistry\Handlers\GenerateStepLabelsPromptHandler;
use GriffinForms\Includes\Ai\PromptRegistry\Handlers\GenerateFieldOptionsPromptHandler;
use GriffinForms\Includes\Ai\PromptRegistry\Handlers\GeneratePaymentProductsPromptHandler;
use GriffinForms\Includes\Ai\PromptRegistry\Handlers\GenerateFieldImageOptionsPromptHandler;
use GriffinForms\Includes\Ai\PromptRegistry\Handlers\GenerateRatingFieldPromptHandler;
use GriffinForms\Includes\Ai\PromptRegistry\Handlers\GenerateNotificationActionPromptHandler;
use GriffinForms\Includes\Ai\PromptRegistry\Handlers\GenerateMessageMutationPromptHandler;
use GriffinForms\Includes\Ai\PromptRegistry\Handlers\GeneratePageLayoutPlanPromptHandler;

class PromptRegistry
{
    /**
     * @var array<string, BasePromptHandler>
     */
    protected array $handlers = [];

    public function __construct()
    {
        $this->register(new AdvisoryResponsePromptHandler());
        $this->register(new GenerateBulkTextMutationPromptHandler());
        $this->register(new GenerateFieldLabelPromptHandler());
        $this->register(new GeneratePlaceholderPromptHandler());
        $this->register(new GenerateFormThemePromptHandler());
        $this->register(new GenerateSelectFieldOptionsPromptHandler());
        $this->register(new GeneratePatchPlanPromptHandler());
        $this->register(new GenerateFoundationPromptHandler());
        // Issue 4 — new operation type handlers
        $this->register(new GenerateStepLabelsPromptHandler());
        $this->register(new GenerateFieldOptionsPromptHandler());
        $this->register(new GeneratePaymentProductsPromptHandler());
        $this->register(new GenerateFieldImageOptionsPromptHandler());
        $this->register(new GenerateRatingFieldPromptHandler());
        $this->register(new GenerateNotificationActionPromptHandler());
        $this->register(new GenerateMessageMutationPromptHandler());
        $this->register(new GeneratePageLayoutPlanPromptHandler());
    }

    public function register(BasePromptHandler $handler): void
    {
        $this->handlers[$handler->getPromptKey()] = $handler;
    }

    public function has(string $prompt_key): bool
    {
        return isset($this->handlers[$prompt_key]);
    }

    public function get(string $prompt_key): ?BasePromptHandler
    {
        return $this->handlers[$prompt_key] ?? null;
    }

    public function keys(): array
    {
        return array_keys($this->handlers);
    }
}
