import { buildCart, } from '../../../../controllers/commerce/context/cart/headless-cart.js';
import { MissingControllerProps } from '../../../common/errors.js';
import { createControllerWithKind, Kind } from '../../types/kind.js';
/**
 * Defines a `Cart` controller instance.
 * @group Definers
 *
 * @returns The `Cart` controller definition.
 */
export function defineCart() {
    return {
        listing: true,
        search: true,
        standalone: true,
        recommendation: true,
        buildWithProps: (engine, props) => {
            if (props === undefined) {
                throw new MissingControllerProps(Kind.Cart);
            }
            const controller = buildCart(engine, { initialState: props.initialState });
            return createControllerWithKind(controller, Kind.Cart);
        },
    };
}
