import { i as isMixedCurrencyError, n as MixedCurrencyError, r as isCartValidationError, t as CartValidationError } from "./errors-DXMuB65Y.js";
import { n as groupByVendor, t as cartReduce } from "./reduce-BZ5GXnIE.js";
//#region src/apply.ts
function emptyCart(cartId) {
	return {
		id: cartId,
		currency: "",
		lines: [],
		subtotal: 0n
	};
}
async function applyToCart(store, cartId, action) {
	const current = await store.load(cartId) ?? emptyCart(cartId);
	const next = cartReduce(current, action);
	await store.save(next);
	return next;
}
//#endregion
export { CartValidationError, MixedCurrencyError, applyToCart, cartReduce, groupByVendor, isCartValidationError, isMixedCurrencyError };
