<?php

namespace IMATHUZH\Qfq\Core\Renderer\FormElement\Base;

use IMATHUZH\Qfq\Core\Form\FormElement\AbstractFormElement;
use IMATHUZH\Qfq\Core\Helper\Support;
use IMATHUZH\Qfq\Core\Renderer\FormElement\NativeRenderer;

/**
 * Class AiChatRenderer
 *
 * Renders the host element for a native 'aiChat' FormElement: an empty div carrying
 * the data attributes (data-ai-sip / data-ai-url / data-ai-chat-placeholder) and the
 * 'qfq-ai-chat' class. AiChat.js finds that div and replaces it with the chat widget.
 *
 * If AI/RAG is disabled, AiChatFormElement leaves the SIP/class unset and the div
 * renders inert (the form keeps working without the chatbot).
 *
 * @package qfq
 */
class AiChatRenderer extends NativeRenderer {

    /**
     * @inheritDoc
     */
    public function renderInput(AbstractFormElement $fe): string {
        return '<div ' . Support::arrayToXMLAttributes($fe->htmlAttributes)
            . ' class="' . implode(' ', $fe->cssClasses) . '"></div>';
    }
}
