<?php

namespace ViartasThemes\Protera\ThemeBuilder;

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

/**
 * Visual-only horizontal separator (`protera.divider`).
 *
 * A theme-owned builder section: it lives in the Protera package, not in any
 * domain module, demonstrating that a THEME can contribute sections. Carries no
 * data source — render() draws an <hr> styled per the chosen line style and
 * vertical spacing.
 */
class DividerSection extends BaseSection
{
    /**
     * Registry key — '{module}.{section}'.
     */
    public function key(): string
    {
        return 'protera.divider';
    }

    /**
     * Library grouping — Protera-owned sections sit under 'protera'.
     */
    public function module(): string
    {
        return 'protera';
    }

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

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

    /**
     * Two visual settings: the line style and the vertical spacing.
     *
     * @return array<string, array<string, mixed>>
     */
    public function settingsSchema(): array
    {
        return [
            'style' => [
                'type' => 'select',
                'translatable' => false,
                'options' => [
                    'line' => __('protera::sections.divider.style_line'),
                    'dotted' => __('protera::sections.divider.style_dotted'),
                    'gradient' => __('protera::sections.divider.style_gradient'),
                ],
                'default' => 'line',
            ],
            'spacing' => [
                'type' => 'select',
                'translatable' => false,
                'options' => [
                    'sm' => __('protera::sections.divider.spacing_sm'),
                    'md' => __('protera::sections.divider.spacing_md'),
                    'lg' => __('protera::sections.divider.spacing_lg'),
                ],
                'default' => 'md',
            ],
        ];
    }

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

    /**
     * Render the divider from its stored style + spacing.
     */
    public function render(SectionContext $ctx): View
    {
        return view('theme::sections.divider', [
            'style' => $ctx->setting('style', 'line'),
            'spacing' => $ctx->setting('spacing', 'md'),
        ]);
    }
}
