import{a as f}from"./chunk-FIAOKTUU.js";import{p as d}from"./chunk-7WGMNLRJ.js";import{i as l}from"./chunk-YMOV4UGM.js";import{$ as c,K as n,ga as a,la as p}from"./chunk-I3FGJX2C.js";import{a as s}from"./chunk-B7YGBANW.js";var m=(()=>{let r=class r{constructor(t){this._http=t}getAll(){return this._http.get("/api/quick-group/all")}getById(t){return this._http.get(`/api/quick-group/${t}`)}create(t){return this._http.post("/api/quick-group",s({},t))}update(t,e){return this._http.put(`/api/quick-group/${t}`,s({},e))}delete(t){return this._http.delete(`/api/quick-group/${t}`)}};r.\u0275fac=function(e){return new(e||r)(p(l))},r.\u0275prov=a({token:r,factory:r.\u0275fac,providedIn:"root"});let o=r;return o})();var v=(()=>{let r=class r{constructor(t,e){this._store=t,this._quickGroupServiceApi=e}getQuickGroups(){return this._quickGroupServiceApi.getAll().pipe(c(t=>this._store.dispatch(new f({quickGroups:t}))),n(1))}createQuickGroup(t){let e={nameRu:t.name,nameKk:t.name,parentId:t.parentId};return this._quickGroupServiceApi.create(e).pipe(c(()=>this.getQuickGroups().subscribe()),n(1))}editQuickGroup(t,e){let i={nameRu:e.name,nameKk:e.name,parentId:e.parentId};return this._quickGroupServiceApi.update(t,i).pipe(c(()=>this.getQuickGroups().subscribe()),n(1))}deleteQuickGroup(t){return this._quickGroupServiceApi.delete(t).pipe(c(()=>this.getQuickGroups().subscribe()),n(1))}findParentId(t,e){return e?this._searchForParentId(t,e,null):null}isNameDuplicate(t,e,i){return this._checkNameDuplicate(t,e.trim().toLowerCase(),i)}isGroupAChild(t,e){for(let i of t)for(let u of i.children)if(u.id===e)return!0;return!1}_checkNameDuplicate(t,e,i){for(let u of t)if(u.id!==i&&u.name.trim().toLowerCase()===e||this._checkNameDuplicate(u.children,e,i))return!0;return!1}_searchForParentId(t,e,i){for(let u of t){if(u.id===e)return i;if(u.children){let h=this._searchForParentId(u.children,e,u.id);if(h!==null)return h}}return null}};r.\u0275fac=function(e){return new(e||r)(p(d),p(m))},r.\u0275prov=a({token:r,factory:r.\u0275fac,providedIn:"root"});let o=r;return o})();export{v as a};
//# sourceMappingURL=chunk-TVCY3TBL.js.map
