<?php
declare(strict_types=1);

namespace ROITheme\Admin\TopNotificationBar\Infrastructure\FieldMapping;

use ROITheme\Admin\Shared\Domain\Contracts\FieldMapperInterface;

/**
 * Field Mapper para Top Notification Bar
 *
 * RESPONSABILIDAD:
 * - Mapear field IDs del formulario a atributos de BD
 * - Solo conoce sus propios campos (modularidad)
 */
final class TopNotificationBarFieldMapper implements FieldMapperInterface
{
    public function getComponentName(): string
    {
        return 'top-notification-bar';
    }

    public function getFieldMapping(): array
    {
        return [
            // Visibility
            'topBarEnabled' => ['group' => 'visibility', 'attribute' => 'is_enabled'],
            'topBarShowOnMobile' => ['group' => 'visibility', 'attribute' => 'show_on_mobile'],
            'topBarShowOnDesktop' => ['group' => 'visibility', 'attribute' => 'show_on_desktop'],
            'topBarIsCritical' => ['group' => 'visibility', 'attribute' => 'is_critical'],
            'topBarHideForLoggedIn' => ['group' => 'visibility', 'attribute' => 'hide_for_logged_in'],

            // Page Visibility (grupo especial _page_visibility)
            'topBarVisibilityHome' => ['group' => '_page_visibility', 'attribute' => 'show_on_home'],
            'topBarVisibilityPosts' => ['group' => '_page_visibility', 'attribute' => 'show_on_posts'],
            'topBarVisibilityPages' => ['group' => '_page_visibility', 'attribute' => 'show_on_pages'],
            'topBarVisibilityArchives' => ['group' => '_page_visibility', 'attribute' => 'show_on_archives'],
            'topBarVisibilitySearch' => ['group' => '_page_visibility', 'attribute' => 'show_on_search'],

            // Exclusions (grupo especial _exclusions - Plan 99.11)
            'topBarExclusionsEnabled' => ['group' => '_exclusions', 'attribute' => 'exclusions_enabled'],
            'topBarExcludeCategories' => ['group' => '_exclusions', 'attribute' => 'exclude_categories', 'type' => 'json_array'],
            'topBarExcludePostIds' => ['group' => '_exclusions', 'attribute' => 'exclude_post_ids', 'type' => 'json_array_int'],
            'topBarExcludeUrlPatterns' => ['group' => '_exclusions', 'attribute' => 'exclude_url_patterns', 'type' => 'json_array_lines'],

            // Content
            'topBarIconClass' => ['group' => 'content', 'attribute' => 'icon_class'],
            'topBarLabelText' => ['group' => 'content', 'attribute' => 'label_text'],
            'topBarMessageText' => ['group' => 'content', 'attribute' => 'message_text'],
            'topBarLinkText' => ['group' => 'content', 'attribute' => 'link_text'],
            'topBarLinkUrl' => ['group' => 'content', 'attribute' => 'link_url'],

            // Colors
            'topBarBackgroundColor' => ['group' => 'colors', 'attribute' => 'background_color'],
            'topBarTextColor' => ['group' => 'colors', 'attribute' => 'text_color'],
            'topBarLabelColor' => ['group' => 'colors', 'attribute' => 'label_color'],
            'topBarIconColor' => ['group' => 'colors', 'attribute' => 'icon_color'],
            'topBarLinkColor' => ['group' => 'colors', 'attribute' => 'link_color'],
            'topBarLinkHoverColor' => ['group' => 'colors', 'attribute' => 'link_hover_color'],

            // Spacing
            'topBarFontSize' => ['group' => 'spacing', 'attribute' => 'font_size'],
            'topBarPadding' => ['group' => 'spacing', 'attribute' => 'padding'],
        ];
    }
}
