<?php

namespace ViartasThemes\Protera\ThemeBuilder;

use Illuminate\Contracts\View\View;
use ViartasCore\Themes\ThemeBuilder\BaseSection;
use ViartasCore\Themes\ThemeBuilder\SectionContext;

/**
 * Visual-only stylised pullquote / manifesto block (`protera.manifesto_pullquote`).
 *
 * Theme-owned builder section. Renders a translatable quote with an optional
 * translatable author line. No data source — the copy is entered inline in the
 * builder and resolved to the active locale at render time.
 */
class ManifestoPullquoteSection extends BaseSection
{
    /**
     * Registry key — '{module}.{section}'.
     */
    public function key(): string
    {
        return 'protera.manifesto_pullquote';
    }

    /**
     * Library grouping.
     */
    public function module(): string
    {
        return 'protera';
    }

    /**
     * Translatable display label.
     */
    public function label(): string
    {
        return (string) __('protera::sections.manifesto_pullquote.label');
    }

    /**
     * Bootstrap icon class.
     */
    public function icon(): string
    {
        return 'bi-chat-quote';
    }

    /**
     * Translatable quote text + an optional translatable author attribution.
     *
     * @return array<string, array<string, mixed>>
     */
    public function settingsSchema(): array
    {
        return [
            'text' => [
                'type' => 'textarea',
                'translatable' => true,
                'default' => '',
            ],
            'author' => [
                'type' => 'text',
                'translatable' => true,
                'optional' => true,
                'default' => '',
            ],
        ];
    }

    /**
     * Visual-only — no data source.
     *
     * @return array<string, array<string, mixed>>
     */
    public function sources(): array
    {
        return [];
    }

    /**
     * Render the pullquote, resolving the translatable text + author to the
     * active locale (SectionContext::setting handles the locale fallback).
     */
    public function render(SectionContext $ctx): View
    {
        return view('theme::sections.manifesto-pullquote', [
            'text' => $ctx->setting('text', ''),
            'author' => $ctx->setting('author', ''),
        ]);
    }
}
