import { ensureAtLeastOneSolutionType } from '../../../app/commerce-ssr-engine/common.js';
import { SolutionType, } from '../../../app/commerce-ssr-engine/types/common.js';
import { buildProductListing, } from '../product-listing/headless-product-listing.js';
import { buildSearch } from '../search/headless-search.js';
/**
 * Defines a `ProductList` controller instance.
 * @group Definers
 *
 * @returns The `ProductList` controller definition.
 */
export function defineProductList(options) {
    ensureAtLeastOneSolutionType(options);
    return {
        listing: true,
        search: true,
        ...options,
        build: (engine, solutionType) => solutionType === SolutionType.listing
            ? buildProductListing(engine)
            : buildSearch(engine),
    };
}
