import{a as d}from"./chunk-WKS4J6VW.js";import{m as g}from"./chunk-H7LDOWEY.js";import{f as u}from"./chunk-ZGXE2QDV.js";import{$ as o,K as n,da as s,ja as c}from"./chunk-ZGECHOBP.js";import{a as p}from"./chunk-K4ALXBGI.js";var l=(()=>{class r{constructor(t){this._http=t}getCategories(){return this._http.get("/api/category")}getCategoryById(t){return this._http.get(`/api/category/${t}`)}createCategory(t){return this._http.post("/api/category",p({},t))}editCategory(t,e){return this._http.put(`/api/category/${t}`,p({},e))}deleteCategory(t){return this._http.delete(`/api/category/${t}`)}static{this.\u0275fac=function(e){return new(e||r)(c(u))}}static{this.\u0275prov=s({token:r,factory:r.\u0275fac})}}return r})();var k=(()=>{class r{constructor(t,e){this._store=t,this._categoryServiceApi=e}getCategories(){return this._categoryServiceApi.getCategories().pipe(o(t=>this._store.dispatch(new d({categories:t}))),n(1))}deleteCategory(t){return this._categoryServiceApi.deleteCategory(t).pipe(o(()=>this.getCategories().subscribe()),n(1))}editCategory(t,e){let i={nameRu:e.name,nameKk:e.name,isQuick:e.isQuick,parentId:e.parentId,comment:e.comment};return this._categoryServiceApi.editCategory(t,i).pipe(o(()=>this.getCategories().subscribe()),n(1))}createCategory(t){let e={nameRu:t.name,nameKk:t.name,isQuick:t.isQuick,parentId:t.parentId,comment:t.comment};return this._categoryServiceApi.createCategory(e).pipe(o(()=>this.getCategories().subscribe()),n(1))}findParentId(t,e){return e?this._searchForParentId(t,e,null):null}findCategoryChildren(t,e){for(let i of t){if(i.id===e)return i.children??[];if(i.children){let a=this.findCategoryChildren(i.children,e);if(a.length>0)return a}}return[]}_searchForParentId(t,e,i){for(let a of t){if(a.id===e)return i;if(a.children){let h=this._searchForParentId(a.children,e,a.id);if(h!==null)return h}}return null}static{this.\u0275fac=function(e){return new(e||r)(c(g),c(l))}}static{this.\u0275prov=s({token:r,factory:r.\u0275fac})}}return r})();export{l as a,k as b};
