<?php

declare(strict_types=1);

namespace KupShop\ComponentsBundle\Twig\Components\Section;

use KupShop\CatalogBundle\ProductList\DynamicFilterAttributes;
use KupShop\CatalogBundle\Util\FilterUtil;
use KupShop\ComponentsBundle\Attributes\Component;
use KupShop\ComponentsBundle\Attributes\Version;
use KupShop\ComponentsBundle\Twig\BaseComponent;
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

#[AsTwigComponent(template: '@Components/components/Section/Filter/Filter.1.html.twig')]
#[Component(1, [
    new Version(1, newJs: null),
])]
class Filter extends BaseComponent
{
    public DynamicFilterAttributes $filterAttributes;
    public \Filter $dynamicFilter;
    public \FilterParams $baseFilterParams;

    public function __construct(
        private readonly FilterUtil $filterUtil,
    ) {
    }

    public function config(): array
    {
        return $this->filterUtil->getSectionFiltersConfig(
            $this->dynamicFilter,
            $this->filterAttributes ?? null,
        );
    }
}
