/**
 * CMS ELEMENT: sidebar-filter
 * Shopware element type `sidebar-filter` — the filter panel marker used in
 * product-listing (category) CMS layouts.
 *
 * Shopware does not resolve listing aggregations into the slot itself; they
 * come from the product-listing route. The category page renders such layouts
 * with its own grid + <CategoryFilters/>. This component only renders when a
 * caller has injected aggregations into the slot (slot.data.aggregations),
 * so the element is also usable inside a generic CmsPage render.
 */

import CategoryFilters from '@/components/category/CategoryFilters';
import type { ProductListAggregations } from '@/lib/shopware-api';
import type { CmsSlot } from '@/components/cms/types';

export default function CmsElementSidebarFilter({ slot }: { slot: CmsSlot }) {
  const aggregations: ProductListAggregations | undefined =
    slot.data?.aggregations ?? slot.data?.listing?.aggregations;
  if (!aggregations) return null;
  return <CategoryFilters aggregations={aggregations} />;
}
