import{a as $}from"./chunk-THKS2M3R.js";import{a as R,b as k,c as j,d as L}from"./chunk-TOJME4VO.js";import"./chunk-2CD72B3Z.js";import"./chunk-4TDNJBFX.js";import"./chunk-4LZAXRJQ.js";import"./chunk-BUHB7MLU.js";import{d as D}from"./chunk-KUS3L5XF.js";import{Ac as b,Ba as v,Bc as h,Ca as w,Eb as u,Ec as T,Fc as I,Fd as E,Kb as d,Vb as r,Vc as S,cc as m,dc as s,ec as l,fc as y,gc as x,ic as O,ka as M,lc as P,nc as a,pa as C,rb as i,sb as g,td as N,ud as F,w as _}from"./chunk-J476KISY.js";var f=(()=>{class n extends ${constructor(t){super(),this.http=t,this.dataMap=[],this.fetchReportTree("TPrometNeMat").subscribe(e=>{this.dataMap=[],this.populateTree(e)})}getChildren(t,e){return _(this.dataMap.find(o=>o.id===t&&o.level===e))}isExpandable(t,e,o){return this.dataMap.some(c=>(o>0?c.formName===e:c.id===t)&&c.children.length>0)}fetchReportTree(t){return this.http.get(`${this.basePath}/api/Reports/GetReportTreeForForm/`+t)}populateTree(t){t.forEach(e=>{var o=t.filter(c=>c.id===e.id&&c.level===e.level+1);this.dataMap.push({id:e.id,level:e.level,description:e.description,name:e.name,report:e.report,formName:e.formName,children:o})})}static{this.\u0275fac=function(e){return new(e||n)(C(D))}}static{this.\u0275prov=M({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();function H(n,p){if(n&1&&(m(0,"button",6),l(1,"i",7),s()),n&2){a();let t=b(3);r("matMenuTriggerFor",t)}}function q(n,p){if(n&1){let t=O();m(0,"button",8),P("menuOpened",function(){v(t);let o=a();return w(o.getData(o.trigger))}),h(1),s()}if(n&2){let t=a(),e=b(3);r("matMenuTriggerFor",e),i(),I(" ",t.trigger.description," ",t.trigger.report," ",t.trigger.name,`
`)}}function z(n,p){n&1&&l(0,"button",9)}function A(n,p){if(n&1&&l(0,"sb-print-tree-menu",12),n&2){let t=a().$implicit;r("trigger",t)}}function J(n,p){if(n&1&&(m(0,"button",13),h(1),s()),n&2){let t=a().$implicit;i(),T("",t.report," ",t.name,"")}}function K(n,p){if(n&1&&(y(0),m(1,"button",10),d(2,A,1,1,"sb-print-tree-menu",11),s(),d(3,J,2,2,"ng-template",null,1,S),x()),n&2){let t=p.$implicit,e=b(4),o=a();i(2),r("ngIf",o.isExpandable(t.id,t.formName,t.level))("ngIfElse",e)}}var G=(()=>{class n{constructor(t){this.database=t,this.data=[],this.trigger={id:"",level:0,description:"",name:"",report:"",formName:"",children:[]},this.isRootNode=!1,this.isLoading=!1,this.dataLoaded=!1}getData(t){this.dataLoaded||(this.isLoading=!0,this.database.getChildren(t.id,t.level).subscribe(e=>{e&&(this.data=e.children),this.isLoading=!1,this.dataLoaded=!0}))}isExpandable(t,e,o){return this.database.isExpandable(t,e,o)}static{this.\u0275fac=function(e){return new(e||n)(g(f))}}static{this.\u0275cmp=u({type:n,selectors:[["sb-print-tree-menu"]],inputs:{data:"data",trigger:"trigger",isRootNode:"isRootNode"},decls:6,vars:4,consts:[["menu","matMenu"],["menuItem",""],["mat-button","","class","paw-icon-btn paw-btn-primary",3,"matMenuTriggerFor",4,"ngIf"],["mat-menu-item","",3,"matMenuTriggerFor","menuOpened",4,"ngIf"],["mat-menu-item","","style","display: flex; justify-content: center; align-items: center",4,"ngIf"],[4,"ngFor","ngForOf"],["mat-button","",1,"paw-icon-btn","paw-btn-primary",3,"matMenuTriggerFor"],[1,"far","fa-print"],["mat-menu-item","",3,"menuOpened","matMenuTriggerFor"],["mat-menu-item","",2,"display","flex","justify-content","center","align-items","center"],["mat-menu-item","",2,"padding","0"],[3,"trigger",4,"ngIf","ngIfElse"],[3,"trigger"],["mat-menu-item",""]],template:function(e,o){e&1&&(d(0,H,2,1,"button",2)(1,q,2,4,"button",3),m(2,"mat-menu",null,0),d(4,z,1,0,"button",4)(5,K,5,2,"ng-container",5),s()),e&2&&(r("ngIf",o.isRootNode),i(),r("ngIf",!o.isRootNode),i(3),r("ngIf",o.isLoading),i(),r("ngForOf",o.data))},dependencies:[n,E,N,F,L,k,R,j],styles:["[_nghost-%COMP%]   .paw-btn-primary[_ngcontent-%COMP%]{background:var(--paw-color-primary);border-color:var(--paw-color-primary);color:var(--paw-contrast-color-primary)}[_nghost-%COMP%]   .paw-btn-primary[_ngcontent-%COMP%]:hover{background-color:var(--paw-color-primary-hover)}[_nghost-%COMP%]   .paw-icon-btn[_ngcontent-%COMP%]{background:none;border:1px solid var(--paw-color-divider);border-radius:4px;padding:10px 18px;background:var(--paw-color-content-bg);color:var(--paw-contrast-color-content-bg);cursor:pointer;min-height:33px}[_nghost-%COMP%]   .paw-icon-btn.paw-action-with-more-menu[_ngcontent-%COMP%]{padding:0}[_nghost-%COMP%]   .paw-icon-btn.paw-action-with-more-menu[_ngcontent-%COMP%]   .paw-action-inner[_ngcontent-%COMP%]   .paw-action-icon-holder[_ngcontent-%COMP%], [_nghost-%COMP%]   .paw-icon-btn.paw-action-with-more-menu[_ngcontent-%COMP%]   .paw-action-inner[_ngcontent-%COMP%]   .paw-action-label-holder[_ngcontent-%COMP%]{padding-top:10px;padding-bottom:10px}[_nghost-%COMP%]   .paw-icon-btn.paw-btn-primary[_ngcontent-%COMP%]{background:var(--paw-color-primary);border-color:var(--paw-color-primary);color:var(--paw-contrast-color-primary)}[_nghost-%COMP%]   .paw-icon-btn.paw-btn-primary[_ngcontent-%COMP%]:hover{background-color:var(--paw-color-primary-hover)}[_nghost-%COMP%]   .paw-icon-btn[_ngcontent-%COMP%]:not(.paw-btn-primary):hover{background-color:var(--paw-color-control-highlight)}[_nghost-%COMP%]   .paw-icon-btn[_ngcontent-%COMP%]:disabled{background:var(--paw-color-control-disabled);border-color:silver;color:var(--paw-contrast-color-control-disabled);cursor:default}[_nghost-%COMP%]   .paw-icon-btn[_ngcontent-%COMP%]:disabled:hover{background-color:var(--paw-color-control-disabled-highlight)}"]})}}return n})();var ot=(()=>{class n{constructor(t){this.database=t,this.title="mat-menu-dynamic-data",this.initialData=[],this.trigger={id:"",level:0,description:"",name:"",report:"",formName:"",children:[]},this.database.fetchReportTree("TPrometNeMat").subscribe(e=>{this.initialData=e.filter(o=>o.level===0)})}static{this.\u0275fac=function(e){return new(e||n)(g(f))}}static{this.\u0275cmp=u({type:n,selectors:[["sb-print-tree"]],decls:1,vars:3,consts:[[3,"trigger","data","isRootNode"]],template:function(e,o){e&1&&l(0,"sb-print-tree-menu",0),e&2&&r("trigger",o.trigger)("data",o.initialData)("isRootNode",!0)},dependencies:[G],encapsulation:2})}}return n})();export{ot as SbPrintTreeComponent};
