import{p as d}from"./chunk-JBWPPKX4.js";import{i as l}from"./chunk-NDLDFKR2.js";import{$ as n,K as c,fa as s,ka as p}from"./chunk-PVUKHE45.js";import{a}from"./chunk-MZPAXKJS.js";var f=(()=>{let e=class e{constructor(t){this.quickGroup=t}};e.type="[QuickGroup] Set Quick Groups";let i=e;return i})(),g=(()=>{let e=class e{};e.type="[QuickGroup] Clear Quick Groups";let i=e;return i})();var k=(()=>{let e=class e{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",a({},t))}update(t,r){return this._http.put(`/api/quick-group/${t}`,a({},r))}delete(t){return this._http.delete(`/api/quick-group/${t}`)}};e.\u0275fac=function(r){return new(r||e)(p(l))},e.\u0275prov=s({token:e,factory:e.\u0275fac,providedIn:"root"});let i=e;return i})();var v=(()=>{let e=class e{constructor(t,r){this._store=t,this._quickGroupServiceApi=r}getQuickGroups(){return this._quickGroupServiceApi.getAll().pipe(n(t=>this._store.dispatch(new f({quickGroups:t}))),c(1))}createQuickGroup(t){let r={nameRu:t.name,nameKk:t.name,parentId:t.parentId};return this._quickGroupServiceApi.create(r).pipe(n(()=>this.getQuickGroups().subscribe()),c(1))}editQuickGroup(t,r){let u={nameRu:r.name,nameKk:r.name,parentId:r.parentId};return this._quickGroupServiceApi.update(t,u).pipe(n(()=>this.getQuickGroups().subscribe()),c(1))}deleteQuickGroup(t){return this._quickGroupServiceApi.delete(t).pipe(n(()=>this.getQuickGroups().subscribe()),c(1))}findParentId(t,r){return r?this._searchForParentId(t,r,null):null}isNameDuplicate(t,r,u){return this._checkNameDuplicate(t,r.trim().toLowerCase(),u)}isGroupAChild(t,r){for(let u of t)for(let o of u.children)if(o.id===r)return!0;return!1}_checkNameDuplicate(t,r,u){for(let o of t)if(o.id!==u&&o.name.trim().toLowerCase()===r||this._checkNameDuplicate(o.children,r,u))return!0;return!1}_searchForParentId(t,r,u){for(let o of t){if(o.id===r)return u;if(o.children){let h=this._searchForParentId(o.children,r,o.id);if(h!==null)return h}}return null}};e.\u0275fac=function(r){return new(r||e)(p(d),p(k))},e.\u0275prov=s({token:e,factory:e.\u0275fac,providedIn:"root"});let i=e;return i})();export{f as a,g as b,v as c};
//# sourceMappingURL=chunk-PEX7YGG3.js.map
