import * as i0 from '@angular/core';
import { Injectable } from '@angular/core';
import { addToCart, addManyToCart, removeFromCart, selectCartItems, updateCartItem, resetCart, selectCartItemCount } from '@testlocallibrary/shared-kernel/store';
import * as i1 from '@ngrx/store';

class CartService {
    constructor(store) {
        this.store = store;
    }
    addToCart(product) {
        this.store.dispatch(addToCart({ product }));
    }
    addManyToCart(products) {
        this.store.dispatch(addManyToCart({ products }));
    }
    removeFromCart(productId) {
        this.store.dispatch(removeFromCart({ productId }));
    }
    getCartItems() {
        return this.store.select(selectCartItems);
    }
    updateCartItem(productId, updates) {
        this.store.dispatch(updateCartItem({ productId, updates }));
    }
    resetCartItems() {
        this.store.dispatch(resetCart());
    }
    getCartItemCount() {
        return this.store.select(selectCartItemCount);
    }
    sync(cartItems) {
        this.store.dispatch({ type: '[Cart] Set All Items', items: cartItems });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CartService, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CartService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CartService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }], ctorParameters: function () { return [{ type: i1.Store }]; } });

/**
 * Generated bundle index. Do not edit.
 */

export { CartService };
//# sourceMappingURL=testlocallibrary-shared-kernel-services-cart-service.mjs.map
