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 `Summary` controller instance.
 * @group Definers
 *
 * @returns The `Summary` controller definition.
 */
export function defineSummary(options) {
    ensureAtLeastOneSolutionType(options);
    return {
        listing: true,
        search: true,
        ...options,
        build: (engine, solutionType) => solutionType === SolutionType.listing
            ? buildProductListing(engine).summary()
            : buildSearch(engine).summary(),
    };
}
