/**
 * SectionItemGrid – generic grid of items from SectionSearchProvider (primitive)
 */
import React from 'react';
import { useSectionSearchContext } from './SectionSearchContext';
import { ItemGrid } from '../suggestions-primitives/ItemGrid';
import { SectionError } from './SectionError';
export function SectionItemGrid({ columns = 4, maxItems = 12, className, style, getItemId = (i) => i.id ?? String(i?.objectID ?? ''), getItemTitle = (i) => i.title ?? i?.title ?? '', getItemImage = (i) => i.image ?? i?.image, getItemDescription = (i) => i.description ?? i?.description, getItemUrl = (i) => i.url ?? i?.url, renderItem, }) {
    const { items, loading, error, trackClick } = useSectionSearchContext();
    if (error)
        return React.createElement(SectionError, { className: className, style: style });
    // When loading with previous items, show them (no loading screen)
    return (React.createElement(ItemGrid, { items: items, maxItems: maxItems, columns: columns, className: className, style: style, getItemId: getItemId, getItemTitle: getItemTitle, getItemImage: getItemImage, getItemDescription: getItemDescription, getItemUrl: getItemUrl, renderItem: renderItem, onItemClick: (item, index) => trackClick(item, index) }));
}
