import{a as l}from"./chunk-COH3AWY5.js";import{p as S}from"./chunk-EO7RCNTX.js";import{Ca as c,ga as w,ma as u}from"./chunk-I3FGJX2C.js";import{a as h,b as n}from"./chunk-B7YGBANW.js";var A=(()=>{let r=class r{constructor(){this._showcaseServiceApi=u(l),this._localStorageService=u(S),this.loadingShowcase=c(!1),this.showcase=c(null),this.id=c(null),this.showcaseCart=c([]),this.openBottomSheet=c(!1),this.openDialog=c(!1)}saveShowcaseToLocalStorage(e){this._localStorageService.set(`showcase:${e}`,this.showcaseCart())}createShowcase(e){return this._showcaseServiceApi.create(e)}editShowcase(e,s){return this._showcaseServiceApi.edit(e,s)}currentShowcase(){return this._showcaseServiceApi.current()}getShowcase(e){return this._showcaseServiceApi.get(e)}suspendShowcase(e){return this._showcaseServiceApi.suspend(e)}activateShowcase(e){return this._showcaseServiceApi.activate(e)}productsShowcase(e,s){return this._showcaseServiceApi.products(e,s)}getProductsShowcase(e,s,a){let i={criteria:{search:e!==null?{name:e}:null},take:s,skip:0,orderBy:"Current",isAscending:!1};return this.productsShowcase(i,a)}addProductToCart(e){let a=this.showcaseCart()??[],i=a.findIndex(t=>t.id===e.id),o;i!==-1?o=a.map((t,g)=>g===i?n(h({},t),{quantity:t.quantity+1}):t):o=[...a,n(h({},e),{quantity:1})],this.showcaseCart.set(o),this.saveShowcaseToLocalStorage(this.id())}removeCartProduct(e){let s=this.showcaseCart();if(!s)return;let a=s??[],i=a.find(t=>t.id===e);if(!i)return;let o;i.quantity>1?o=a.map(t=>t.id===e?n(h({},t),{quantity:t.quantity-1}):t):o=a.filter(t=>t.id!==e),this.showcaseCart.set(o),this.saveShowcaseToLocalStorage(this.id())}clearCart(){this.showcaseCart.set([]),this.saveShowcaseToLocalStorage(this.id())}removeCartPosition(e){let a=this.showcaseCart().filter((i,o)=>o!==e);this.showcaseCart.set(a),this.saveShowcaseToLocalStorage(this.id())}};r.\u0275fac=function(s){return new(s||r)},r.\u0275prov=w({token:r,factory:r.\u0275fac});let d=r;return d})();export{A as a};
//# sourceMappingURL=chunk-FRO5HMTS.js.map
