import{Hn as S,Qo as B}from"./chunk-RQDYBYBM.js";import{$d as g,N as u,ba as f,be as n,ga as p,la as b,o as l,oa as h,s as d}from"./chunk-N6B2OJOY.js";var V=n(B,e=>e.vmmState.breadcrumbs),c=n(V,e=>({breadcrumbsMap:e.breadcrumbsMap,loading:e.loading,loaded:e.loaded,error:e.error})),L=n(V,e=>e.loading);var j=(()=>{let m=class m{constructor(r){this.foerchStore=r}areVmmBreadcrumbsLoading(){return this.foerchStore.select(L)}loadVmmBreadcrumbs(r,t=!1){this.foerchStore.select(c).pipe(u(1),p(o=>{(t||!(o.loading||o.loaded||o.error))&&this.foerchStore.dispatch(S({customerCode:r}))})).subscribe()}getVmmBreadcrumbsMap(){return this.foerchStore.select(c).pipe(f(r=>!r.loaded),d(r=>r.breadcrumbsMap))}getVmmBreadcrumbForUnit(r,t=!0){return this.getVmmBreadcrumbsMap().pipe(d(o=>m.buildBreadcrumbsForUnit(o,r,t)))}isUnitChildOf(r,t){return r===t?l(!0):this.getVmmBreadcrumbsMap().pipe(d(o=>{let a=r,i=!1,s;do if(s=o[a]?o[a]:null,!s||(a=s.parentId,i=a===t,i))break;while(a!==0);return i}))}static buildBreadcrumbsForUnit(r,t,o){let a=[];if(r&&r.hasOwnProperty(t)){let i=r[t],s=!1;do a.push({label:i.name,link:o?`${i.id}`:null}),r.hasOwnProperty(i.parentId)?i=r[i.parentId]:s=!0;while(!s);a.reverse()}return a}};m.\u0275fac=function(t){return new(t||m)(h(g))},m.\u0275prov=b({token:m,factory:m.\u0275fac,providedIn:"root"});let e=m;return e})();export{j as a};