import{D as d,E as P}from"./chunk-I7GW4F3B.js";import{Gb as l,Jb as o,Lb as p,Sa as v,Sb as u,be as A,g as m,ia as c,na as w}from"./chunk-WL5U2YIT.js";import{e as f}from"./chunk-ADEKKGI2.js";var U,V=f(()=>{w();v();A();P();U=(()=>{let s=class s{constructor(e,r,n){this.templateRef=e,this.viewContainer=r,this.currentUserService=n,this.permissions=[],this.requireAll=!1,this.elseTemplateRef=null,this.hasView=!1,this.destroy$=new m}set hasAdminPermission(e){this.permissions=e,this.updateView()}set hasAdminPermissionRequireAll(e){this.requireAll=e,this.updateView()}set hasAdminPermissionElse(e){this.elseTemplateRef=e,this.updateView()}ngOnInit(){this.currentUserService.permissionsChanged.pipe(c(this.destroy$)).subscribe(()=>{this.updateView()}),this.updateView()}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}updateView(){let e=this.checkPermission();e&&!this.hasView?(this.viewContainer.clear(),this.viewContainer.createEmbeddedView(this.templateRef),this.hasView=!0):!e&&this.hasView&&(this.viewContainer.clear(),this.hasView=!1),!e&&this.elseTemplateRef&&this.viewContainer.length===0&&this.viewContainer.createEmbeddedView(this.elseTemplateRef)}checkPermission(){if(!this.permissions)return!1;let e=this.currentUserService.permissionsSnapshot;if(!e||!e.activePermissions)return!1;let r=new Date,n=i=>i.endDateUtc?new Date(i.endDateUtc)>=r:!0;if(!Array.isArray(this.permissions))return e.activePermissions.some(i=>i.permission===this.permissions&&n(i));let h=this.permissions;return h.length===0?!1:this.requireAll?h.every(i=>e.activePermissions.some(t=>t.permission===i&&n(t))):h.some(i=>e.activePermissions.some(t=>t.permission===i&&n(t)))}};s.\u0275fac=function(r){return new(r||s)(o(l),o(p),o(d))},s.\u0275dir=u({type:s,selectors:[["","hasAdminPermission",""]],inputs:{hasAdminPermission:"hasAdminPermission",hasAdminPermissionRequireAll:"hasAdminPermissionRequireAll",hasAdminPermissionElse:"hasAdminPermissionElse"}});let a=s;return a})()});export{U as a,V as b};
