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