import{a as $e,c as an,d as sn}from"./chunk-BPP4QS36.js";import{c as te}from"./chunk-PY36RJBP.js";import{a as Ue}from"./chunk-LTUVDLS3.js";import{b as rn}from"./chunk-5OZTUYJC.js";import{a as tn,b as We}from"./chunk-VXT7UTIK.js";import{a as on}from"./chunk-N2WXLUZD.js";import{a as N}from"./chunk-Y7IP5WLG.js";import{I as nn,a as be}from"./chunk-SLGBXDUF.js";import{a as Se}from"./chunk-LY6HB4BL.js";import{Qo as je,Vk as lt,_d as Ne,af as Qt,ef as en,hl as G}from"./chunk-RQDYBYBM.js";import{s as xe}from"./chunk-FBI7JGZC.js";import{a as H}from"./chunk-ILYMG6ZI.js";import{f as Zt,r as ee,t as _e,x as He}from"./chunk-MXUIPT66.js";import{I as Be,b as Q,c as Kt,f as U,l as $,o as Jt}from"./chunk-DX7LHTFF.js";import{$b as ke,$c as Oe,$d as Ae,Aa as d,Ab as p,Ba as f,Bb as v,Cb as T,Ce as De,Db as I,Dc as V,E as me,Eb as st,Fb as y,Ge as Re,Ja as Wt,Jd as Ve,Ka as D,Kb as u,La as Ut,Lb as c,M as Rt,N as Me,Ob as Yt,Og as Pe,Pb as Y,Q as Pt,Ua as a,Va as x,Vc as ge,Wc as Z,Xb as F,Xc as P,Yb as h,Zb as j,_b as S,a as pe,ad as Gt,ae as Ie,bb as $t,bd as Le,be as q,c as we,cc as k,d as Vt,dc as O,e as At,ea as Bt,ec as L,gb as ue,gd as E,hb as zt,ib as g,ic as Te,jc as R,jd as ct,kc as qt,la as de,lc as Ce,ma as Ht,oa as fe,ob as s,pa as ce,qb as at,qg as B,rc as C,rg as A,sa as Nt,sc as _,t as Dt,ta as M,tb as Xt,ua as jt,va as rt,vc as he,wc as w,yh as W,za as Ee,zb as l}from"./chunk-N6B2OJOY.js";import{a as Ot,b as Lt,h as ve,i as it,j as ot}from"./chunk-GHL4OFBQ.js";var Bn=q(je,t=>t.costCentersManagementState.costCenterSumChart),ze=q(Bn,t=>({costCenterSumList:t.costCenterSumList,loading:t.loading,loaded:t.loaded,error:t.error})),or=q(ze,t=>t.loading),cn=q(ze,t=>t.loaded);var Xe=(()=>{let e=class e{constructor(i,o){this.foerchStore=i,this.userIdService=o}get(){return this.foerchStore.pipe(Ie(ze))}load(i,o){this.userIdService.getUserId().pipe(me(r=>r!==De),Me(1)).subscribe(r=>{let m=G(o.start,{representation:"date"}),b=G(o.end,{representation:"date"});this.foerchStore.dispatch(new Qt({userId:r,codes:i,intervalStart:m,intervalEnd:b}))})}isLoaded(){return this.foerchStore.pipe(Ie(cn))}};e.\u0275fac=function(o){return new(o||e)(fe(Ae),fe(Re))},e.\u0275prov=de({token:e,factory:e.\u0275fac,providedIn:"root"});let t=e;return t})();var Un=t=>({height:t}),Ye=(()=>{let e=class e extends an{set pieChartData(i){this._data=i,this.updateSumValue(),this.updateChart()}get pieChartData(){return this._data}constructor(i,o,r){super(i,o,r),this.currencyService=i,this.languageService=o,this.currencyPipe=r,this.legend={itemGap:12,itemWidth:8,itemHeight:8,borderRadius:50,inactiveColor:"#999999",textStyle:{color:"#1a1a1a",fontFamily:"Helvetica",fontSize:14,padding:[0,12,0,4]}},this._sum="",this.titleOptions={text:this._sum,textAlign:"left",textVerticalAlign:"top",left:"center",top:"middle",textStyle:{fontSize:24}},this.seriesOptions=[{type:"pie",animation:!1,bottom:15,radius:["47%","70%"],labelLine:{show:!1},label:{show:!1,formatter:m=>`{amount|${this.currencyPipe.transform(m.value[1],this.currency,"symbol","1.0",this.localeCode)}}
{reason|${m.value[0]}}`,position:"center",verticalAlign:"middle"},emphasis:{label:{color:"#161616",show:!0,backgroundColor:"#ffffff",fontFamily:"Helvetica",rich:{amount:{fontSize:24,lineHeight:32,fontWeight:"bold"},reason:{fontSize:12,lineHeight:20}}}}}],this.canvasHeight="",this._data=[]}ngOnInit(){this.legendOptions=this.legend,this.tooltipOptions={trigger:"none"},this.datasetOptions={source:[]},this.updateSumValue(),this.titleOptions.text=this._sum,super.ngOnInit()}onChartInit(i){super.onChartInit(i),setTimeout(()=>{i.setOption({dataset:{source:this._data}})},0),i.on("mouseover","series",()=>{i.setOption({title:{show:!1}})}),i.on("mouseout","series",()=>{i.setOption({title:{show:!0}})}),i.on("highlight","series",o=>{let m=i.getOption().legend[0];(!m.selected||Object.keys(m.selected).indexOf(o.name)===-1||m.selected[o.name]===!0)&&i.setOption({title:{show:!1}})}),i.on("downplay","series",()=>{i.setOption({title:{show:!0}})}),i.on("legendselectchanged",o=>{this.updateSumValue(o.selected),i.setOption({title:{text:this._sum}})})}updateSumValue(i={}){let o=Object.keys(i).length===0,m=this._data.filter(b=>o||i[b[0]]===!0).reduce((b,se)=>b+se[1],0);this._sum=this.currencyPipe.transform(m,this.currency,"symbol","1.0",this.localeCode)}updateChart(){this.chartInstance&&this.chartInstance.setOption({title:{text:this._sum},dataset:{source:this._data}})}};e.\u0275fac=function(o){return new(o||e)(x(A),x(B),x(E))},e.\u0275cmp=M({type:e,selectors:[["foerch-donut-chart"]],inputs:{pieChartData:"pieChartData",legend:"legend",titleOptions:"titleOptions",seriesOptions:"seriesOptions",canvasHeight:"canvasHeight"},features:[ue],decls:1,vars:4,consts:[["echarts","",3,"chartInit","ngStyle","options"]],template:function(o,r){o&1&&(l(0,"div",0),u("chartInit",function(b){return r.onChartInit(b)}),p()),o&2&&s("ngStyle",R(2,Un,r.canvasHeight))("options",r.options)},dependencies:[Oe,$e],encapsulation:2});let t=e;return t})();var $n=t=>({height:t}),pn=(()=>{let e=class e extends sn{constructor(i,o,r){super(i,o,r),this.currencyService=i,this.languageService=o,this.currencyPipe=r,this.barWidth=20}ngOnInit(){super.ngOnInit()}onChartInit(i){super.onChartInit(i)}setBaseConfiguration(){this.legendOptions={itemGap:12,itemWidth:8,itemHeight:8,borderRadius:50,inactiveColor:"#999999",textStyle:{color:"#1a1a1a",fontFamily:"Helvetica",fontSize:14,padding:[0,12,0,4]}},this.tooltipOptions={trigger:"item",formatter:i=>{let o=this.currencyPipe.transform(i.data[i.seriesIndex+1],this.currency,"symbol","1.0",this.localeCode);return`${i.marker}${o} - ${i.seriesName}`},backgroundColor:"#ffffff",borderColor:"#002643",borderWidth:1,padding:8,textStyle:{color:"#1a1a1a",fontFamily:"Helvetica",fontSize:12,lineHeight:18},extraCssText:"box-shadow: 0 6px 6px 0 rgba(22, 37, 63, 0.23), 0 10px 20px 0 rgba(22, 37, 63, 0.19), inset 0 0 3px 0 rgba(0, 0, 0, 0.75); border-radius: 0;"},this.gridOptions={right:10,left:10,bottom:0,containLabel:!0},this.xAxisOptions={type:"value",axisLine:{lineStyle:{color:"#999999"}},axisTick:{length:8},axisLabel:{formatter:(i,o)=>this.currencyPipe.transform(i,this.currency,"symbol","1.0",this.localeCode),margin:21,color:"#161616",fontFamily:"Helvetica",fontSize:12,align:"center"},splitLine:{show:!1},splitArea:{show:!0,areaStyle:{color:["#f7f7f7","#ffffff"]}}},this.yAxisOptions={type:"category",axisLine:{show:!1},axisTick:{show:!1},axisLabel:{inside:!0,margin:5,color:"#161616",fontFamily:"Helvetica",fontSize:12,verticalAlign:"bottom",padding:[0,0,12,0]}},this.datasetOptions={source:[]},this.seriesOptions=[]}prepareBarChart(){if(this.chartInstance){let i=[],o=this.barChartData.length>0?this.barChartData[0].length-1:0;for(let r=0;r<o;r++)i.push({type:"bar",stack:"Foerch",animation:!1,barMaxWidth:this.barWidth});setTimeout(()=>{this.chartInstance.setOption({dataset:{source:this._data},series:i})},0)}}};e.\u0275fac=function(o){return new(o||e)(x(A),x(B),x(E))},e.\u0275cmp=M({type:e,selectors:[["foerch-stacked-bar-chart"]],features:[ue],decls:1,vars:4,consts:[["echarts","",3,"chartInit","ngStyle","options"]],template:function(o,r){o&1&&(l(0,"div",0),u("chartInit",function(b){return r.onChartInit(b)}),p()),o&2&&s("ngStyle",R(2,$n,r.canvasHeight))("options",r.options)},dependencies:[Oe,$e],encapsulation:2,changeDetection:0});let t=e;return t})();var qn=function(t,e,n,i){var o=arguments.length,r=o<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,n):i,m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(t,e,n,i);else for(var b=t.length-1;b>=0;b--)(m=t[b])&&(r=(o<3?m(r):o>3?m(e,n,r):m(e,n))||r);return o>3&&r&&Object.defineProperty(e,n,r),r},Gn=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)};function Kn(t,e){if(t&1&&v(0,"foerch-stacked-bar-chart",25),t&2){let n=c(2);s("barChartData",n.barChartData)("canvasHeight",n.barChartCanvasHeight)}}function Jn(t,e){if(t&1&&v(0,"foerch-donut-chart",26),t&2){let n=c(2);s("canvasHeight","400px")("pieChartData",n.pieChartData)("seriesOptions",n.seriesOptions)("titleOptions",n.titleOptions)}}function Zn(t,e){if(t&1){let n=y();T(0),l(1,"div",8)(2,"div",9)(3,"ng-select",10),C(4,"cxTranslate"),L("ngModelChange",function(o){d(n);let r=c();return O(r.selectedCostCenters,o)||(r.selectedCostCenters=o),f(o)}),u("change",function(){d(n);let o=c();return f(o.onChangeSelectedCostCenters())}),p()(),l(5,"div",11)(6,"div",8)(7,"div",12)(8,"button",13),u("click",function(){d(n);let o=c();return f(o.downloadAsPdf())}),v(9,"cx-icon",5),h(10),C(11,"cxTranslate"),p()(),l(12,"div",14)(13,"div",15)(14,"input",16),L("ngModelChange",function(o){d(n);let r=c();return O(r.isPieChart,o)||(r.isPieChart=o),f(o)}),u("ngModelChange",function(o){d(n);let r=c();return f(r.onSwitchChartType(o))}),p(),l(15,"label",17)(16,"div",18),v(17,"cx-icon",5),p()(),l(18,"input",19),L("ngModelChange",function(o){d(n);let r=c();return O(r.isPieChart,o)||(r.isPieChart=o),f(o)}),u("ngModelChange",function(o){d(n);let r=c();return f(r.onSwitchChartType(o))}),p(),l(19,"label",20)(20,"div",18),v(21,"cx-icon",5),p()()()()()()(),l(22,"div",21)(23,"div",22),g(24,Kn,1,2,"foerch-stacked-bar-chart",23)(25,Jn,1,4,"foerch-donut-chart",24),p()(),I()}if(t&2){let n=c();a(3),s("clearable",!1)("closeOnSelect",!1)("items",n.costCenters)("multiple",!0)("placeholder",_(4,21,"costCenterChart.activeCostCenters")),k("ngModel",n.selectedCostCenters),a(5),s("disabled",n.selectedCostCenters.length===0),a(),s("type",n.icons.PDF),a(),S(" ",_(11,23,"costCenterChart.downloadAsPdf")," "),a(4),s("value",!1),k("ngModel",n.isPieChart),a(2),at("btn-primary",!n.isPieChart),a(),s("type",n.icons.BAR_CHART),a(),s("value",!0),k("ngModel",n.isPieChart),a(2),at("btn-primary",n.isPieChart),a(),s("type",n.icons.PIE_CHART),a(3),s("ngIf",!n.isPieChart),a(),s("ngIf",n.isPieChart)}}function Qn(t,e){t&1&&(T(0),v(1,"cx-spinner",28),h(2),C(3,"cxTranslate"),I()),t&2&&(a(2),S(" ",_(3,1,"costCenterChart.loadingMessage")," "))}function ei(t,e){t&1&&(T(0),l(1,"div",29),h(2),C(3,"cxTranslate"),p(),I()),t&2&&(a(2),j(_(3,1,"common.errorMessage")))}function ti(t,e){if(t&1&&g(0,Qn,4,3,"ng-container",27)(1,ei,4,3,"ng-container",27),t&2){let n=c();s("ngIf",n.isLoading),a(),s("ngIf",n.isError)}}var ie,ye=(ie=class{set costCenterSums(e){this._costCenterSums=e,this._pieChartDataConverter.setCostCenterSumData(e),this._barChartDataConverter.setCostCenterSumData(e),this.extractCostCentersForSelection(),this.pieChartData=this._pieChartDataConverter.getPieChartDataForCostCenterSelection(this.selectedCostCenters),this.barChartData=this._barChartDataConverter.getBarChartDataForCostCenterSelection(this.selectedCostCenters)}get costCenterSums(){return this._costCenterSums}constructor(e,n,i,o,r,m,b){this.costCentersSumChartService=e,this.costCentersManagementService=n,this.currencyService=i,this.languageService=o,this.currencyPipe=r,this._modalService=m,this._cd=b,this.icons=H,this.isPieChart=!0,this.costCenters=[],this.selectedCostCenters=[],this.isLoaded=!1,this.isLoading=!1,this.isError=!1,this.pieChartData=[],this.barChartData=[],this.barChartCanvasHeight="400px",this.titleOptions={textAlign:"left",textVerticalAlign:"top",left:"center",top:"middle",textStyle:{fontSize:24}},this.currency="",this.localeCode="",this.seriesOptions=[{type:"pie",animation:!1,bottom:0,radius:["47%","72%"],labelLine:{show:!1},label:{show:!1,formatter:se=>`{amount|${this.currencyPipe.transform(se.value[1],this.currency,"symbol","1.0",this.localeCode)}}
{reason|${se.value[0]}}`,position:"center",verticalAlign:"middle"},emphasis:{label:{color:"#161616",show:!0,backgroundColor:"#ffffff",fontFamily:"Helvetica",rich:{amount:{fontSize:24,lineHeight:32,fontWeight:"bold"},reason:{fontSize:12,lineHeight:20}}}}}],this._pieChartDataConverter=new We,this._barChartDataConverter=new tn,this._minBarChartCanvasHeight=400,this._barChartBaseCanvasHeight=97,this._singleBarHeight=65,this._subs$=new pe}ngOnInit(){this._subs$.add(this.costCentersSumChartService.get().subscribe(e=>{e&&(this.handleCostCentersSumChartResult(e),this._cd.detectChanges())})),this._subs$.add(this.currencyService.getActive().subscribe(e=>this.currency=e)),this._subs$.add(this.languageService.getActive().subscribe(e=>{this.localeCode=e.replace("_","-")})),this.costCentersSumChartService.load(this.costCenterCodes,this.interval)}ngOnDestroy(){this._subs$.unsubscribe()}handleCostCentersSumChartResult(e){e.costCenterSumList&&(this.costCenterSums=e.costCenterSumList,this.costCenterSums.costCenters&&(this.selectedCostCenters=this.costCenterSums.costCenters.map(n=>n.code))),this.isLoaded=e.loaded,this.isLoading=e.loading,this.isError=e.error}dismissModal(){this._modalService.dismissActiveModal()}downloadAsPdf(){let e={interval:this.interval,chart:this.isPieChart?xe.PIE:xe.BAR,isPDF:!0,isTable:!1,costCenterCodes:this.selectedCostCenters};this.costCentersManagementService.createReport(e)}onChangeSelectedCostCenters(){this.isPieChart?this.pieChartData=this._pieChartDataConverter.getPieChartDataForCostCenterSelection(this.selectedCostCenters):this.barChartData=this._barChartDataConverter.getBarChartDataForCostCenterSelection(this.selectedCostCenters),this.calculateBarChartCanvasHeight(this.selectedCostCenters.length),this._cd.detectChanges()}onSwitchChartType(e){e?this.pieChartData=this._pieChartDataConverter.getPieChartDataForCostCenterSelection(this.selectedCostCenters):this.barChartData=this._barChartDataConverter.getBarChartDataForCostCenterSelection(this.selectedCostCenters)}extractCostCentersForSelection(){this.costCenters=Ne(this._pieChartDataConverter.getCostCenters(),"name"),this.selectedCostCenters=this.costCenters.map(e=>e.code),this.calculateBarChartCanvasHeight(this.costCenters.length)}calculateBarChartCanvasHeight(e){let n=Math.max(this._barChartBaseCanvasHeight+e*this._singleBarHeight,this._minBarChartCanvasHeight);this.barChartCanvasHeight=`${n}px`}},ie.\u0275fac=function(n){return new(n||ie)(x(Xe),x(te),x(A),x(B),x(E),x(N),x(V))},ie.\u0275cmp=M({type:ie,selectors:[["foerch-cost-center-chart-modal"]],decls:11,vars:6,consts:[["loadingOrError",""],[1,"modal-header"],[1,"modal-title"],["aria-label","Close","type","button",1,"close",3,"click"],["aria-hidden","true"],[3,"type"],[1,"modal-body","pt-2"],[4,"ngIf","ngIfElse"],[1,"row"],[1,"col-12","col-lg-8"],["bindLabel","name","bindValue","code",1,"ng-select-multiple_containerLight",3,"ngModelChange","change","clearable","closeOnSelect","items","multiple","placeholder","ngModel"],[1,"col","mt-2","mt-lg-0"],[1,"col","col-lg-12"],["type","button",1,"btn","btn-primary","btn-block","btn-icon_left","mb-lg-2",3,"click","disabled"],[1,"col-auto","col-auto","ms-lg-auto"],[1,"custom-buttonSwitch"],["name","chartType","id","chartType_bar","type","radio","autocomplete","off",1,"form-check-input","btn-check","custom-buttonSwitch-input",3,"ngModelChange","value","ngModel"],["for","chartType_bar"],[1,"btn","btn-block"],["name","chartType","id","chartType_pie","type","radio","autocomplete","off",1,"form-check-input","btn-check","custom-buttonSwitch-input",3,"ngModelChange","value","ngModel"],["for","chartType_pie"],[1,"row","mt-4"],[1,"col-12"],[3,"barChartData","canvasHeight",4,"ngIf"],[3,"canvasHeight","pieChartData","seriesOptions","titleOptions",4,"ngIf"],[3,"barChartData","canvasHeight"],[3,"canvasHeight","pieChartData","seriesOptions","titleOptions"],[4,"ngIf"],[1,"mb-4"],[1,"emptyState-text"]],template:function(n,i){if(n&1){let o=y();l(0,"div",1)(1,"h3",2),h(2),C(3,"cxTranslate"),p(),l(4,"button",3),u("click",function(){return d(o),f(i.dismissModal())}),l(5,"span",4),v(6,"cx-icon",5),p()()(),l(7,"div",6),g(8,Zn,26,25,"ng-container",7),p(),g(9,ti,2,2,"ng-template",null,0,w)}if(n&2){let o=F(10);a(2),S(" ",_(3,4,"costCenterChart.chartHeadline")," "),a(4),s("type",i.icons.CLOSE),a(2),s("ngIf",!i.isLoading&&!i.isError)("ngIfElse",o)}},dependencies:[P,ee,Be,Kt,Jt,U,$,_e,Ye,pn,W],encapsulation:2,changeDetection:0}),ie);ye=qn([Se(),Gn("design:paramtypes",[Xe,te,A,B,E,N,V])],ye);var dn=q(je,t=>t.costCentersManagementState.costCenterSum),Or=q(dn,t=>({entities:t.entities,entitiesLoading:t.entitiesLoading,entitiesLoaded:t.entitiesLoaded,entitiesError:t.entitiesError})),fn=q(dn,(t,{costCenterCode:e})=>({costCenterSumList:t.entities[e]||null,loading:t.entitiesLoading[e]||!1,loaded:t.entitiesLoaded[e]||!1,error:t.entitiesError[e]||!1}));var Ge=(()=>{let e=class e{constructor(i,o){this.foerchStore=i,this.userIdService=o}get(i){return this.foerchStore.pipe(Ie(fn,{costCenterCode:i}))}load(i,o){this.userIdService.getUserId().pipe(me(r=>r!==De),Me(1)).subscribe(r=>{let m=G(o.start,{representation:"date"}),b=G(o.end,{representation:"date"});this.foerchStore.dispatch(new en({userId:r,codeTopCostCenter:i,intervalStart:m,intervalEnd:b}))})}};e.\u0275fac=function(o){return new(o||e)(fe(Ae),fe(Re))},e.\u0275prov=de({token:e,factory:e.\u0275fac,providedIn:"root"});let t=e;return t})();var oi=typeof global=="object"&&global&&global.Object===Object&&global,un=oi;var ri=typeof self=="object"&&self&&self.Object===Object&&self,ai=un||ri||Function("return this")(),Cn=ai;var si=Cn.Symbol,K=si;var hn=Object.prototype,ci=hn.hasOwnProperty,li=hn.toString,Fe=K?K.toStringTag:void 0;function pi(t){var e=ci.call(t,Fe),n=t[Fe];try{t[Fe]=void 0;var i=!0}catch{}var o=li.call(t);return i&&(e?t[Fe]=n:delete t[Fe]),o}var gn=pi;var mi=Object.prototype,di=mi.toString;function fi(t){return di.call(t)}var _n=fi;var ui="[object Null]",Ci="[object Undefined]",xn=K?K.toStringTag:void 0;function hi(t){return t==null?t===void 0?Ci:ui:xn&&xn in Object(t)?gn(t):_n(t)}var X=hi;function gi(t){return t!=null&&typeof t=="object"}var oe=gi;var _i="[object Symbol]";function xi(t){return typeof t=="symbol"||oe(t)&&X(t)==_i}var Sn=xi;function Si(t,e){for(var n=-1,i=t==null?0:t.length,o=Array(i);++n<i;)o[n]=e(t[n],n,t);return o}var bn=Si;var bi=Array.isArray,Ke=bi;var yi=1/0,yn=K?K.prototype:void 0,vn=yn?yn.toString:void 0;function Tn(t){if(typeof t=="string")return t;if(Ke(t))return bn(t,Tn)+"";if(Sn(t))return vn?vn.call(t):"";var e=t+"";return e=="0"&&1/t==-yi?"-0":e}var In=Tn;function vi(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Fn=vi;var Ti="[object AsyncFunction]",Ii="[object Function]",Fi="[object GeneratorFunction]",wi="[object Proxy]";function Mi(t){if(!Fn(t))return!1;var e=X(t);return e==Ii||e==Fi||e==Ti||e==wi}var mt=Mi;function Ei(t){return t==null?"":In(t)}var wn=Ei;var ki="[object String]";function Oi(t){return typeof t=="string"||!Ke(t)&&oe(t)&&X(t)==ki}var dt=Oi;var Li="[object Boolean]";function Vi(t){return t===!0||t===!1||oe(t)&&X(t)==Li}var ft=Vi;var Ai="[object Number]";function Di(t){return typeof t=="number"||oe(t)&&X(t)==Ai}var ut=Di;function Ri(t){return t==null}var Je=Ri;var Pi=0;function Bi(t){var e=++Pi;return wn(t)+e}var Ct=Bi;var Mn=(()=>{let e=class e{constructor(){this.destroyed$$=new At(1),this.destroyed$=this.destroyed$$.asObservable()}ngOnDestroy(){this.destroyed$$&&!this.destroyed$$.closed&&(this.destroyed$$.next(),this.destroyed$$.complete())}};e.\u0275fac=function(o){return new(o||e)},e.\u0275dir=rt({type:e,selectors:[["","inViewportDestroyable",""]],standalone:!0});let t=e;return t})(),Hi=t=>Object.prototype.toString.call(t)==="[object Object]",ht=new WeakMap,Ni="in-viewport-empty-check-fn",gt=class{#e;#t;get value(){return this.#e}get id(){return this.#t}constructor(e){this.#e=mt(e)?e:void 0;let n=ht.get(e)??Ni;!Je(e)&&!ht.has(e)&&ht.set(e,n=Ct("in-viewport-check-fn-")),this.#t=n}},Qe=function(t){return t.BOTH="both",t.VERTICAL="vertical",t.HORIZONTAL="horizontal",t}(Qe||{}),_t=class extends TypeError{constructor(){let e=Object.values(Qe).join("|");super(`The provided value for the direction is incorrect. The value must be any of \`${e}\`.`)}},xt=class extends TypeError{constructor(){super("The provided value for the rootMargin is incorrect. The value must be specified in pixels or percent.")}},St=class extends TypeError{constructor(){super("The provided value for the root is incorrect. The value must be of type '(Document or Element)'.")}},bt=class extends TypeError{constructor(){super("The provided values for the threshold are incorrect. The values must be numbers between 0 and 1.")}},yt=class{#e;get value(){return this.#e}constructor(e=Qe.VERTICAL){if(!Object.values(Qe).includes(e))throw new _t;this.#e=e}},vt=class{#e;get value(){return this.#e}constructor(e){this.#e=ft(e)?e:!0}},Tt=class t{#e;get value(){return this.#e}constructor(e){this.#e=t.parse(e)}static parse(e){let i=(dt(e)?e.trim():"0px").split(/\s+/);if(i.length<=4&&i.every(o=>/^-?\d*\.?\d+(px|%)$/.test(o))){let[o,r=o,m=o,b=r]=i;return`${o} ${r} ${m} ${b}`}throw new xt}},It=class t{#e;get value(){return this.#e}constructor(e){this.#e=t.validate(e)}static validate(e){if(Je(e))return null;if(e instanceof Element&&e.nodeType===Node.ELEMENT_NODE)return e;throw new St}},Ft=class t{#e;get value(){return this.#e}constructor(e){this.#e=t.validate(e??[0,1])}static validate(e){if(t.isValid(e))return[e];if(Array.isArray(e)&&e.every(n=>t.isValid(n)))return e.sort();throw new bt}static isValid(e){return ut(e)&&e>=0&&e<=1}},En=Symbol("InViewportCheckFnId"),Ze=Symbol("InViewportConfigHash"),et=class{#e;#t;get root(){return this.#e.root.value}get rootMargin(){return this.#e.rootMargin.value}get threshold(){return this.#e.threshold.value}get partial(){return this.#e.partial.value}get direction(){return this.#e.direction.value}get checkFn(){return this.#e.checkFn.value}get[En](){return this.#e.checkFn.id}get[Ze](){return this.#t}constructor(e){e??={},this.#e=Object.freeze({root:new It(e.root),rootMargin:new Tt(e.rootMargin),threshold:new Ft(e.threshold),partial:new vt(e.partial),direction:new yt(e.direction),checkFn:new gt(e.checkFn)}),this.#t=ji(Et({rootMargin:this.rootMargin,threshold:this.threshold,partial:this.partial,direction:this.direction,checkFn:this[En]}))}},wt=class{#e=new Set;#t;#n;constructor(e,n){this.#t=new IntersectionObserver((...i)=>{n.next(...i)},{root:e.root,rootMargin:e.rootMargin,threshold:[...e.threshold]}),this.#n=()=>{this.#t.disconnect(),n.complete()}}addNode(e){this.#e.add(e),this.#t.observe(e)}deleteNode(e){this.#e.delete(e),this.#e.size?this.#t.unobserve(e):this.#n()}},Mt=class t{static#e=Object.create(null);#t=new WeakMap;#n;constructor(e){this.#n=e}addNode(e,n){let i=this.#t.get(n.root??t.#e)??this.create(n),o=n[Ze];i.has(o)||this.insert(i,n),i.get(o).addNode(e)}deleteNode(e,n){let i=this.#t.get(n.root??t.#e),o=n[Ze];i&&i.has(o)&&i.get(o).deleteNode(e),i&&i.size===0&&this.#t.delete(n.root??t.#e)}create(e){let n=new Map;return this.#t.set(e.root??t.#e,n),this.insert(n,e),n}insert(e,n){let i=n[Ze],o=new wt(n,{next:(...r)=>{this.#n(...r)},complete:()=>{e.delete(i)}});e.set(i,o)}},Et=t=>Array.isArray(t)?`[${t.map(Et).join(",")}]`:Hi(t)?Object.entries(t).sort(([e],[n])=>String(e).localeCompare(String(n))).map(([e,n])=>`${e}:${Et(n)}`).join("|"):String(t),ji=t=>{try{let e=globalThis.encodeURI(t);return globalThis.btoa(e)}catch{return t}},Wi=(()=>{var e,n;let i=class i{constructor(){it(this,e,void 0);it(this,n,void 0);ot(this,e,new we),this.trigger$=ve(this,e).asObservable(),this.zone=ce($t),this.zone.runOutsideAngular(()=>{ot(this,n,new Mt(r=>this.onIntersectionEvent(r)))})}register(r,m){this.zone.runOutsideAngular(()=>{ve(this,n).addNode(r,m)})}unregister(r,m){this.zone.runOutsideAngular(()=>{ve(this,n).deleteNode(r,m)})}onIntersectionEvent(r=[]){this.zone.run(()=>r.forEach(m=>ve(this,e).next(m)))}};e=new WeakMap,n=new WeakMap,i.\u0275fac=function(m){return new(m||i)},i.\u0275prov=de({token:i,factory:i.\u0275fac,providedIn:"root"});let t=i;return t})(),Ui=Symbol("InViewportMetadata"),kn=(()=>{let e=class e{constructor(){this.inViewportAction=new D,this.inViewportCustomCheck=new D,this.config=new et({}),this.platformId=ce(Ut),this.changeDetectorRef=ce(V),this.elementRef=ce(Wt),this.destroyable=ce(Mn,{self:!0}),this.inViewportService=ce(Wi)}set options(i){this.config=new et(i)}get nativeElement(){return this.elementRef.nativeElement}ngAfterViewInit(){if(!ct(this.platformId)){this.emit(void 0,!0,!0);return}this.inViewportService.trigger$.pipe(me(i=>i.target===this.nativeElement),Bt(this.destroyable.destroyed$)).subscribe(i=>{this.emit(i,!1),this.changeDetectorRef.markForCheck()}),this.inViewportService.register(this.nativeElement,this.config)}ngOnDestroy(){ct(this.platformId)&&(this.inViewportService.unregister(this.nativeElement,this.config),this.emit(void 0,!0,!1))}isVisible(i){return this.config.partial?i.isIntersecting||i.intersectionRatio>0:i.intersectionRatio>=1}emit(i,o,r){this.inViewportAction.emit({[Ui]:{entry:i},target:this.nativeElement,visible:o?!!r:!i||this.isVisible(i)}),this.config.checkFn&&this.inViewportCustomCheck.emit(this.config.checkFn(i,{force:o,forcedValue:o?!!r:void 0,config:this.config}))}};e.\u0275fac=function(o){return new(o||e)},e.\u0275dir=rt({type:e,selectors:[["","inViewport",""]],inputs:{options:[Nt.None,"inViewportOptions","options"]},outputs:{inViewportAction:"inViewportAction",inViewportCustomCheck:"inViewportCustomCheck"},standalone:!0,features:[zt([Mn])]});let t=e;return t})(),$a=(()=>{let e=class e{};e.\u0275fac=function(o){return new(o||e)},e.\u0275mod=jt({type:e}),e.\u0275inj=Ht({});let t=e;return t})();var zi=["foerch-cost-center-sum-entry",""],Xi=(t,e,n)=>[t,e,"symbol","1.2",n];function Yi(t,e){if(t&1&&(T(0),h(1),I()),t&2){let n=c(2);a(),S(" ",n.costCenterSumValues.name," ")}}function qi(t,e){if(t&1){let n=y();l(0,"td",2),T(1),l(2,"div",3)(3,"input",4),L("ngModelChange",function(o){d(n);let r=c();return O(r.markItem,o)||(r.markItem=o),f(o)}),u("change",function(){d(n);let o=c();return f(o.toggleCheckBox(o.costCenterSumValues.code,o.markItem))}),p(),l(4,"label",5),g(5,Yi,2,1,"ng-container",6),p()(),I(),p()}if(t&2){let n=c();a(3),Y("id","markMeSubCostCenter_",n.costCenterSumValues.code,""),k("ngModel",n.markItem),a(),Y("for","markMeSubCostCenter_",n.costCenterSumValues.code,""),a(),s("ngIf",n.costCenterSumValues.name)}}function Gi(t,e){if(t&1&&(l(0,"td")(1,"strong"),h(2),C(3,"currency"),p(),l(4,"div",7),h(5),p()()),t&2){let n=e.$implicit,i=c();a(2),j(he(3,2,Ce(8,Xi,n.totalPrice,i.currencyCode,i.localeCode))),a(3),j(n.count)}}var tt=(()=>{let e=class e{constructor(){this.icons=H,this.markItem=!1,this.itemToggled=new D}trackByReason(i,o){return o.name}toggleCheckBox(i,o){this.itemToggled.emit({subCode:i,checked:o})}};e.\u0275fac=function(o){return new(o||e)},e.\u0275cmp=M({type:e,selectors:[["","foerch-cost-center-sum-entry",""]],inputs:{costCenterSumValues:"costCenterSumValues",isSubCostCenter:"isSubCostCenter",markItem:"markItem",currencyCode:"currencyCode",localeCode:"localeCode"},outputs:{itemToggled:"itemToggled"},attrs:zi,decls:2,vars:3,consts:[["class","text-nowrap",4,"ngIf"],[4,"ngFor","ngForOf","ngForTrackBy"],[1,"text-nowrap"],[1,"form-check","form-checkbox"],["name","subCostCenter","type","checkbox","role","checkbox",1,"form-check-input",3,"ngModelChange","change","id","ngModel"],[1,"form-check-label",3,"for"],[4,"ngIf"],[1,"tkmList-count"]],template:function(o,r){o&1&&g(0,qi,6,6,"td",0)(1,Gi,6,12,"td",1),o&2&&(s("ngIf",r.isSubCostCenter),a(),s("ngForOf",r.costCenterSumValues.orderReasonWithCountAndPrice)("ngForTrackBy",r.trackByReason))},dependencies:[Z,P,Q,U,$,E],encapsulation:2,changeDetection:0});let t=e;return t})();var Ln=t=>({active:t}),kt=(t,e,n)=>[t,e,"symbol","1.2",n];function Ji(t,e){if(t&1&&(T(0),h(1),I()),t&2){let n=c(2);a(),S(" ",n.costCenterSumValues.name," ")}}function Zi(t,e){if(t&1&&(l(0,"div",14)(1,"div",4)(2,"div",15)(3,"strong"),h(4),C(5,"cxTranslate"),p()(),l(6,"div",15),h(7),C(8,"currency"),p()()()),t&2){let n=c(2);a(4),j(_(5,2,"common.sum")),a(3),S(" ",he(8,4,Ce(10,kt,n.sum.totalPrice,n.currencyCode,n.localeCode))," ")}}function Qi(t,e){if(t&1){let n=y();T(0),l(1,"div",4)(2,"div",5)(3,"div",6)(4,"input",7),L("ngModelChange",function(o){d(n);let r=c();return O(r.markItem,o)||(r.markItem=o),f(o)}),u("change",function(){d(n);let o=c();return f(o.toggleCheckBox(o.costCenterSumValues.code,o.markItem))}),p(),l(5,"label",8),g(6,Ji,2,1,"ng-container",9),p()()(),l(7,"div",10)(8,"button",11),u("click",function(){d(n);let o=c();return f(o.isCollapsedCostCenter=!o.isCollapsedCostCenter)}),v(9,"cx-icon",12),p()()(),g(10,Zi,9,14,"div",13),I()}if(t&2){let n=c();a(4),Y("id","markMeSubCostCenter_",n.costCenterSumValues.code,""),k("ngModel",n.markItem),a(),Y("for","markMeSubCostCenter_",n.costCenterSumValues.code,""),a(),s("ngIf",n.costCenterSumValues.name),a(2),s("ngClass",R(9,Ln,!n.isCollapsedCostCenter)),a(),s("type",n.icons.ARROW_DOWN),a(),s("ngIf",n.sum)}}function eo(t,e){if(t&1){let n=y();l(0,"div",17)(1,"div",4)(2,"div",15)(3,"strong"),h(4),C(5,"cxTranslate"),p()(),l(6,"div",15),h(7),C(8,"currency"),p(),l(9,"div",18)(10,"button",11),u("click",function(){d(n);let o=c(2);return f(o.isCollapsedCostCenter=!o.isCollapsedCostCenter)}),v(11,"cx-icon",12),p()()()()}if(t&2){let n=c(2);a(4),j(_(5,4,"common.sum")),a(3),S(" ",he(8,6,Ce(12,kt,n.sum.totalPrice,n.currencyCode,n.localeCode))," "),a(3),s("ngClass",R(16,Ln,!n.isCollapsedCostCenter)),a(),s("type",n.icons.ARROW_DOWN)}}function to(t,e){if(t&1&&g(0,eo,12,18,"div",16),t&2){let n=c();s("ngIf",n.sum)}}function no(t,e){if(t&1&&(T(0),l(1,"div",4)(2,"div",15)(3,"strong"),h(4),p()(),l(5,"div",15),h(6),C(7,"currency"),p()(),I()),t&2){let n=e.$implicit,i=c();a(4),S(" ",n.shortHand," "),a(2),ke(" ",he(7,3,Ce(9,kt,n.totalPrice,i.currencyCode,i.localeCode))," / ",n.count," ")}}var Vn=(()=>{let e=class e extends tt{constructor(){super(),this.icons=H,this.markItem=!1,this.itemToggled=new D,this.isCollapsedCostCenter=!0,this.purchaseReasons=[]}ngOnChanges(i){i.costCenterSumValues&&i.costCenterSumValues.currentValue&&(this.purchaseReasons=i.costCenterSumValues.currentValue.orderReasonWithCountAndPrice),this.sum=this.purchaseReasons.find(o=>o.shortHand==="sum"),this.purchaseReasons=this.purchaseReasons.filter(o=>o.shortHand!=="sum")}};e.\u0275fac=function(o){return new(o||e)},e.\u0275cmp=M({type:e,selectors:[["foerch-cost-center-sum-entry-mobile"]],inputs:{costCenterSumValues:"costCenterSumValues",isSubCostCenter:"isSubCostCenter",markItem:"markItem"},outputs:{itemToggled:"itemToggled"},features:[ue,Ee],decls:5,vars:5,consts:[["topCostCenter",""],[4,"ngIf","ngIfElse"],[1,"costCenterSumEntryMobile-list",3,"ngbCollapse"],[4,"ngFor","ngForOf","ngForTrackBy"],[1,"row"],[1,"col"],[1,"form-check","form-checkbox"],["name","subCostCenter","type","checkbox","role","checkbox",1,"form-check-input",3,"ngModelChange","change","id","ngModel"],[1,"form-check-label",3,"for"],[4,"ngIf"],[1,"col-auto","text-end"],["type","button",1,"btn-icon","costCenterSumEntryMobile-toggle",3,"click","ngClass"],[3,"type"],["class","costCenterSumEntryMobile-sum_sub",4,"ngIf"],[1,"costCenterSumEntryMobile-sum_sub"],[1,"col-4"],["class","costCenterSumEntryMobile-sum",4,"ngIf"],[1,"costCenterSumEntryMobile-sum"],[1,"col-auto","ms-auto","text-end"]],template:function(o,r){if(o&1&&(g(0,Qi,11,11,"ng-container",1)(1,to,1,1,"ng-template",null,0,w),l(3,"div",2),g(4,no,8,13,"ng-container",3),p()),o&2){let m=F(2);s("ngIf",r.isSubCostCenter)("ngIfElse",m),a(3),s("ngbCollapse",r.isCollapsedCostCenter),a(),s("ngForOf",r.purchaseReasons)("ngForTrackBy",r.trackByReason)}},dependencies:[ge,Z,P,ee,be,Q,U,$,E,W],encapsulation:2,changeDetection:0});let t=e;return t})();var oo=(t,e)=>({currencyCode:t,localeCode:e});function ro(t,e){if(t&1){let n=y();l(0,"foerch-cost-center-sum-entry-mobile",4),u("itemToggled",function(o){d(n);let r=c(3);return f(r.onToggleCheckBox(o))}),p()}if(t&2){let n=e.$implicit,i=c(2).ngIf,o=c();s("costCenterSumValues",n)("currencyCode",i.currencyCode)("isSubCostCenter",o.isSubCostCenter)("localeCode",i.localeCode)("markItem",o.markItem)}}function ao(t,e){if(t&1&&(T(0),g(1,ro,1,5,"foerch-cost-center-sum-entry-mobile",3),I()),t&2){let n=c(2);a(),s("ngForOf",n.costCenterSumValues)("ngForTrackBy",n.trackByIndex)}}function so(t,e){t&1&&(l(0,"th"),h(1),C(2,"cxTranslate"),p()),t&2&&(a(),S(" ",_(2,1,"costCenterManagementList.table.costCenter")," "))}function co(t,e){if(t&1&&(l(0,"th"),h(1),p()),t&2){let n=e.$implicit;a(),S(" ",n," ")}}function lo(t,e){if(t&1&&(l(0,"tr"),g(1,so,3,3,"th",1)(2,co,2,1,"th",7),p()),t&2){let n=c(3);a(),s("ngIf",n.isSubCostCenter),a(),s("ngForOf",n.headerTitles)("ngForTrackBy",n.trackByIndex)}}function po(t,e){if(t&1){let n=y();l(0,"tr",8),u("itemToggled",function(o){d(n);let r=c(3);return f(r.onToggleCheckBox(o))}),p()}if(t&2){let n=e.$implicit,i=c(2).ngIf,o=c();s("costCenterSumValues",n)("currencyCode",i.currencyCode)("isSubCostCenter",o.isSubCostCenter)("localeCode",i.localeCode)("markItem",o.markItem)}}function mo(t,e){if(t&1&&(l(0,"table",5)(1,"thead"),g(2,lo,3,3,"tr",1),p(),l(3,"tbody"),g(4,po,1,5,"tr",6),p()()),t&2){let n=c(2);a(2),s("ngIf",n.costCenterSumList&&n.costCenterSumList.headers),a(2),s("ngForOf",n.costCenterSumValues)("ngForTrackBy",n.trackByIndex)}}function fo(t,e){if(t&1&&(T(0),g(1,ao,2,2,"ng-container",2)(2,mo,5,3,"ng-template",null,0,w),I()),t&2){let n=F(3),i=c();a(),s("ngIf",i.isMobile)("ngIfElse",n)}}var An=(()=>{let e=class e{set costCenterSumList(i){this._costCenterSumList=i,this.headerTitles=this.convertHeaders(i)}get costCenterSumList(){return this._costCenterSumList}constructor(i,o){this._currencyService=i,this._currencyLocaleService=o,this.markItem=!1,this.itemToggled=new D,this.locale$=this._currencyLocaleService.getActiveLocaleForCurrencyPipe(),this.currency$=this._currencyService.getActive(),this.icons=H}ngOnInit(){this.isSubCostCenter=this.costCenterSumList.costCenters&&this.costCenterSumList.costCenters.length>0,this.costCenterSumValues=this.isSubCostCenter?Ne(this.costCenterSumList.costCenters,"name"):[this.costCenterSumList.costCenter],this.totalCountSubCodes=this.costCenterSumValues.length}trackByIndex(i){return i}onToggleCheckBox(i){this.itemToggled.emit({subCode:i.subCode,checked:i.checked})}convertHeaders(i){return i.headers.map(o=>o==="sum"?this.extractSumName(i):o)}extractSumName(i){let o="Summe";if(i.costCenter&&i.costCenter.orderReasonWithCountAndPrice){let m=i.costCenter.orderReasonWithCountAndPrice.find(b=>b.shortHand==="sum").name.toLowerCase();o=m.charAt(0).toUpperCase()+m.slice(1)}return o}};e.\u0275fac=function(o){return new(o||e)(x(A),x(rn))},e.\u0275cmp=M({type:e,selectors:[["foerch-cost-center-sum-list"]],inputs:{costCenterSumList:"costCenterSumList",markItem:"markItem",isMobile:"isMobile"},outputs:{itemToggled:"itemToggled"},decls:3,vars:8,consts:[["isDesktop",""],[4,"ngIf"],[4,"ngIf","ngIfElse"],[3,"costCenterSumValues","currencyCode","isSubCostCenter","localeCode","markItem","itemToggled",4,"ngFor","ngForOf","ngForTrackBy"],[3,"itemToggled","costCenterSumValues","currencyCode","isSubCostCenter","localeCode","markItem"],[1,"cartTable","cartTable_tkmList"],["foerch-cost-center-sum-entry","",3,"costCenterSumValues","currencyCode","isSubCostCenter","localeCode","markItem","itemToggled",4,"ngFor","ngForOf","ngForTrackBy"],[4,"ngFor","ngForOf","ngForTrackBy"],["foerch-cost-center-sum-entry","",3,"itemToggled","costCenterSumValues","currencyCode","isSubCostCenter","localeCode","markItem"]],template:function(o,r){o&1&&(g(0,fo,4,2,"ng-container",1),C(1,"async"),C(2,"async")),o&2&&s("ngIf",qt(5,oo,_(1,1,r.currency$),_(2,3,r.locale$)))},dependencies:[Z,P,tt,Vn,Le,W],encapsulation:2,changeDetection:0});let t=e;return t})();var Co=function(t,e,n,i){var o=arguments.length,r=o<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,n):i,m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(t,e,n,i);else for(var b=t.length-1;b>=0;b--)(m=t[b])&&(r=(o<3?m(r):o>3?m(e,n,r):m(e,n))||r);return o>3&&r&&Object.defineProperty(e,n,r),r},ho=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},go=t=>({"is-indeterminate":t}),_o=()=>[0],xo=t=>({threshold:t});function So(t,e){if(t&1){let n=y();l(0,"button",19),C(1,"cxTranslate"),u("click",function(){d(n);let o=c(2);return f(o.showChartFromTop())}),v(2,"cx-icon",18),h(3),C(4,"cxTranslate"),p(),l(5,"button",19),C(6,"cxTranslate"),u("click",function(){d(n);let o=c(2);return f(o.navigateToPositionList())}),v(7,"cx-icon",18),h(8),C(9,"cxTranslate"),p()}if(t&2){let n=c(2);s("title",_(1,6,"costCenterManagementList.icons.openChart")),a(2),s("type",n.icons.PIE_CHART),a(),S(" ",_(4,8,"common.showChart")," "),a(2),s("title",_(6,10,"costCenterManagementList.icons.openPositionList")),a(2),s("type",n.icons.PURCHASE_ORDER),a(),S(" ",_(9,12,"costCenterManagementList.showPositionList")," ")}}function bo(t,e){if(t&1&&(T(0),l(1,"button",17),v(2,"cx-icon",18),p(),g(3,So,10,14,"ng-template",null,3,w),I()),t&2){let n=F(4),i=c();a(),s("ngbPopover",n)("popoverTitle",""),a(),s("type",i.icons.MENU_VERTICAL)}}function yo(t,e){if(t&1){let n=y();l(0,"button",20),C(1,"cxTranslate"),u("click",function(){d(n);let o=c();return f(o.showChartFromTop())}),v(2,"cx-icon",18),p(),l(3,"button",20),C(4,"cxTranslate"),u("click",function(){d(n);let o=c();return f(o.navigateToPositionList())}),v(5,"cx-icon",18),p()}if(t&2){let n=c();s("title",_(1,4,"costCenterManagementList.icons.openChart")),a(2),s("type",n.icons.PIE_CHART),a(),s("title",_(4,6,"costCenterManagementList.icons.openPositionList")),a(2),s("type",n.icons.PURCHASE_ORDER)}}function vo(t,e){if(t&1&&(l(0,"span"),v(1,"cx-icon",21),C(2,"cxTranslate"),p()),t&2){let n=c();a(),s("title",_(2,2,"costCenterManagementList.icons.hideDetails"))("type",n.icons.ARROW_UP)}}function To(t,e){if(t&1&&(v(0,"cx-icon",21),C(1,"cxTranslate")),t&2){let n=c();s("title",_(1,2,"costCenterManagementList.icons.showDetails"))("type",n.icons.ARROW_DOWN)}}function Io(t,e){if(t&1){let n=y();T(0),l(1,"foerch-cost-center-sum-list",26),u("itemToggled",function(o){d(n);let r=c(4);return f(r.onToggleCheckBoxForSubs(o))}),p(),I()}if(t&2){let n=c(4);a(),s("costCenterSumList",n.costCenterSumList)("isMobile",n.isMobile)("markItem",n.markItem)}}function Fo(t,e){if(t&1){let n=y();T(0),v(1,"foerch-donut-chart",23),g(2,Io,2,3,"ng-container",22),l(3,"div",24)(4,"button",25),u("click",function(){d(n);let o=c(3);return f(o.navigateToPositionList(!1))}),h(5),C(6,"cxTranslate"),p(),l(7,"button",25),u("click",function(){d(n);let o=c(3);return f(o.showChart())}),h(8),C(9,"cxTranslate"),p()(),I()}if(t&2){let n=c(3);a(),s("canvasHeight","287px")("legend",n.pieChartLegend)("pieChartData",n.pieChartData)("seriesOptions",n.seriesOptions)("titleOptions",n.titleOptions),a(),s("ngIf",n.costCenterSumList),a(2),s("disabled",n.isEmptyListOfCodes()),a(),S(" ",_(6,10,"costCenterManagementList.table.toPositionList")," "),a(2),s("disabled",n.isEmptyListOfCodes()),a(),S(" ",_(9,12,"costCenterManagementList.table.toChart")," ")}}function wo(t,e){if(t&1){let n=y();T(0),l(1,"foerch-cost-center-sum-list",26),u("itemToggled",function(o){d(n);let r=c(4);return f(r.onToggleCheckBoxForSubs(o))}),p(),I()}if(t&2){let n=c(4);a(),s("costCenterSumList",n.costCenterSumList)("isMobile",n.isMobile)("markItem",n.markItem)}}function Mo(t,e){if(t&1){let n=y();l(0,"div",31)(1,"button",32),u("click",function(){d(n);let o=c(4);return f(o.navigateToPositionList(!1))}),h(2),C(3,"cxTranslate"),p(),l(4,"button",32),u("click",function(){d(n);let o=c(4);return f(o.showChart())}),h(5),C(6,"cxTranslate"),p()()}if(t&2){let n=c(4);a(),s("disabled",n.isEmptyListOfCodes()),a(),S(" ",_(3,4,"costCenterManagementList.table.toPositionList")," "),a(2),s("disabled",n.isEmptyListOfCodes()),a(),S(" ",_(6,6,"costCenterManagementList.table.toChart")," ")}}function Eo(t,e){if(t&1&&(l(0,"div",27)(1,"div",28),v(2,"foerch-donut-chart",23),p(),l(3,"div",29),g(4,wo,2,3,"ng-container",22)(5,Mo,7,8,"div",30),p()()),t&2){let n=c(3);a(2),s("canvasHeight","260px")("legend",n.pieChartLegend)("pieChartData",n.pieChartData)("seriesOptions",n.seriesOptions)("titleOptions",n.titleOptions),a(2),s("ngIf",n.costCenterSumList),a(),s("ngIf",n.isLoaded)}}function ko(t,e){if(t&1&&(T(0),g(1,Fo,10,14,"ng-container",14)(2,Eo,6,7,"ng-template",null,4,w),I()),t&2){let n=F(3),i=c(2);a(),s("ngIf",i.isMobile)("ngIfElse",n)}}function Oo(t,e){if(t&1&&(T(0),g(1,ko,4,2,"ng-container",22),I()),t&2){let n=c();a(),s("ngIf",n.isExpanded)}}function Lo(t,e){t&1&&v(0,"cx-spinner")}function Vo(t,e){t&1&&(l(0,"div",34),h(1),C(2,"cxTranslate"),p()),t&2&&(a(),S(" ",_(2,1,"common.errorMessage")," "))}function Ao(t,e){if(t&1&&g(0,Lo,1,0,"cx-spinner",22)(1,Vo,3,3,"div",33),t&2){let n=c();s("ngIf",n.isLoading),a(),s("ngIf",n.isError)}}var re,nt=(re=class{set isAllExpanded(e){this.isExpanded=e}get isAllExpanded(){return this.isExpanded}constructor(e,n,i,o,r,m,b){this.costCenterSumService=e,this.modalService=n,this.currencyService=i,this.languageService=o,this.currencyPipe=r,this._router=m,this._cd=b,this.markItem=!1,this.itemToggledForTops=new D,this.itemToggledForSubs=new D,this.icons=H,this.isExpanded=!1,this.isLoaded=!1,this.isLoading=!1,this.isError=!1,this.isSubCostCenter=!1,this.isInViewport=!1,this.selectionHelperForSubs=new Ue,this.selectedCostCenters=[],this.pieChartData=[],this.pieChartLegend={orient:"horizontal",left:0,bottom:0,padding:0,itemGap:8,itemWidth:8,itemHeight:8,inactiveColor:"#999999",textStyle:{backgroundColor:"rgba(255,255,255,0.6)",color:"#1a1a1a",fontFamily:"Helvetica",fontSize:13,padding:[0,0,0,4]}},this.titleOptions={textAlign:"left",textVerticalAlign:"top",left:"center",top:"37%",textStyle:{fontSize:24}},this.currency="",this.localeCode="",this.seriesOptions=[{type:"pie",animation:!1,bottom:35,radius:["68%","83%"],labelLine:{show:!1},label:{show:!1,formatter:se=>`{amount|${this.currencyPipe.transform(se.value[1],this.currency,"symbol","1.0",this.localeCode)}}
{reason|${se.value[0]}}`,position:"center",verticalAlign:"middle"},emphasis:{label:{color:"#161616",show:!0,backgroundColor:"#ffffff",fontFamily:"Helvetica",rich:{amount:{fontSize:24,lineHeight:32,fontWeight:"bold"},reason:{fontSize:12,lineHeight:20}}}}}],this._subs$=new pe,this._pieChartDataConverter=new We,this._inViewportChange=new we,this._lastInterval=null}ngOnInit(){this._subs$.add(this._inViewportChange.pipe(Rt(200)).subscribe(e=>{this.isInViewport=e,this.isExpanded&&!this.isLoaded&&(this.isInViewport?this.loadData():this.isLoaded=!1)})),this._subs$.add(this.costCenterSumService.get(this.costCenter.code).pipe(Pt((e,n)=>JSON.stringify(e)===JSON.stringify(n))).subscribe(e=>{e.costCenterSumList&&e.costCenterSumList.headers&&(this.handleCostCentersResult(e),this._cd.markForCheck())})),this._subs$.add(this.currencyService.getActive().subscribe(e=>this.currency=e)),this._subs$.add(this.languageService.getActive().subscribe(e=>{this.localeCode=e.replace("_","-")}))}ngOnChanges(e){e.isAllExpanded&&e.isAllExpanded.currentValue&&!this.isLoaded||e.interval&&e.interval.currentValue&&(this.isLoaded=!1,this.isExpanded&&this.isInViewport&&this.loadData())}ngOnDestroy(){this._subs$.unsubscribe()}handleCostCentersResult(e){this.isLoaded=e.loaded,this.isLoading=e.loading,this.isError=e.error,e.costCenterSumList&&(this.costCenterSumList=e.costCenterSumList,this.setCodes()),this._pieChartDataConverter.setCostCenterSumData(this.costCenterSumList),this.setPieChartData()}showDetails(){this.isExpanded?this.isExpanded=!1:(this.loadData(),this.isExpanded=!0),this._cd.detectChanges()}showChart(){if(this.selectedCostCenters.length>0){let e=this.modalService.open(ye,{centered:!0,size:"xl"});e&&(e.componentInstance.costCenterCodes=this.selectedCostCenters,e.componentInstance.interval=this.interval)}}showChartFromTop(){this.isExpanded||(this.selectedCostCenters=[this.costCenter.code]),this.showChart()}isEmptyListOfCodes(){return this.selectionHelperForSubs.isNoneSelected()&&this.isSubCostCenter}toggleCheckboxForTops(e,n){this.selectionHelperForSubs.toggleAll(n),this.itemToggledForTops.emit({topCode:e,checked:n})}onToggleCheckBoxForSubs(e){this.itemToggledForSubs.emit({subCode:e.subCode,checked:e.checked,topCode:this.costCenter.code}),this.addOrRemoveCode(e.subCode,e.checked),this.setCheckBoxForTopCode()}onChangeViewport(e){this._inViewportChange.next(e)}isPartiallyMarked(){return!this.selectionHelperForSubs.isNoneSelected()&&!this.selectionHelperForSubs.areAllSelected()}navigateToPositionList(e=!0){let n={intervalStart:this.interval.start?G(new Date(this.interval.start),{representation:"date"}):"",intervalEnd:this.interval.end?G(new Date(this.interval.end),{representation:"date"}):"",costCenters:JSON.stringify(e?[this.costCenter.code]:this.selectedCostCenters)};this._router.navigate(["/","my-account","cost-center-management",this.costCenter.code],{queryParams:n})}setCheckBoxForTopCode(){this.isPartiallyMarked()||this.itemToggledForTops.emit({topCode:this.costCenter.code,checked:!this.selectionHelperForSubs.isNoneSelected()||this.selectionHelperForSubs.areAllSelected()})}addOrRemoveCode(e,n){if(n&&!this.selectionHelperForSubs.areAllSelected())this.selectionHelperForSubs.isNoneSelected()&&(this.selectedCostCenters=[]),this.selectedCostCenters=[...this.selectedCostCenters,e],this.selectionHelperForSubs.toggleItemStatus(e,!0);else{if(this.selectedCostCenters=this.selectedCostCenters.filter(i=>i!==e),this.selectionHelperForSubs.areAllSelected())for(let i of this.selectionHelperForSubs.getSelectedItems())i.id!==e&&this.itemToggledForSubs.emit({subCode:i.id,checked:!0,topCode:this.costCenter.code});if(this.selectionHelperForSubs.toggleItemStatus(e,!1),this.selectionHelperForSubs.isNoneSelected())for(let i of this.selectionHelperForSubs.getAllItems())this.selectedCostCenters.push(i.id)}this.setPieChartData()}setCodes(){this.costCenterSumList.costCenters&&this.costCenterSumList.costCenters.length>0?(this.isSubCostCenter=!0,this.selectedCostCenters=[],this.selectedCostCenters=this.costCenterSumList.costCenters.map(e=>e.code),this.setItemsSelectionHelper(this.costCenterSumList.costCenters)):this.selectedCostCenters=[this.costCenterSumList.costCenter.code]}setItemsSelectionHelper(e){let n=[];for(let i of e)n.push({id:i.code,item:i});this.selectionHelperForSubs.updateItems(n)}loadData(){!this.isLoading&&!this.isLoaded&&this.interval!==this._lastInterval&&(this.costCenterSumService.load(this.costCenter.code,this.interval),this._lastInterval=this.interval)}setPieChartData(){this.pieChartData=this._pieChartDataConverter.getPieChartDataForCostCenterSelection(this.selectedCostCenters)}},re.\u0275fac=function(n){return new(n||re)(x(Ge),x(N),x(A),x(B),x(E),x(Ve),x(V))},re.\u0275cmp=M({type:re,selectors:[["foerch-cost-center-management"]],inputs:{isAllExpanded:"isAllExpanded",costCenter:"costCenter",markItem:"markItem",interval:"interval",isMobile:"isMobile"},outputs:{itemToggledForTops:"itemToggledForTops",itemToggledForSubs:"itemToggledForSubs"},features:[Ee],decls:21,vars:20,consts:[["desktopActions",""],["notExpanded",""],["loadingOrError",""],["popoverContent",""],["desktopView",""],[1,"costCenterManagement","costCenterNode"],[1,"costCenterManagementHead","costCenterNode-head"],[1,"row"],[1,"col-9","col-lg-10"],[1,"form-check","form-checkbox"],["name","costCenter","type","checkbox","role","checkbox",1,"form-check-input",3,"ngModelChange","change","id","ngClass","ngModel"],[1,"form-check-label"],[1,"ellipsis-label",3,"for"],[1,"col-auto","ms-auto"],[4,"ngIf","ngIfElse"],[1,"btn-icon","costCenterNode-quickBtn",3,"click"],["inViewport","",1,"costCenterManagementBody",3,"inViewportAction","inViewportOptions","ngbCollapse"],["container","body","placement","bottom","popoverClass","costCenterManagement-popover","type","button",1,"btn-icon","costCenterNode-quickBtn",3,"ngbPopover","popoverTitle"],[3,"type"],[1,"btn","btn-link","btn-block",3,"click","title"],[1,"btn-icon","costCenterNode-quickBtn",3,"click","title"],[3,"title","type"],[4,"ngIf"],[3,"canvasHeight","legend","pieChartData","seriesOptions","titleOptions"],[1,"costCenterManagement-action","mw-sm-down-400"],["type","button",1,"btn","btn-block","btn-sm","btn-secondary",3,"click","disabled"],[3,"itemToggled","costCenterSumList","isMobile","markItem"],[1,"row","g-0"],[1,"col-lg-3","costCenterManagementBody-left"],[1,"col-lg-9","costCenterManagementBody-border"],["class","costCenterManagement-action",4,"ngIf"],[1,"costCenterManagement-action"],["type","button",1,"btn","btn-sm","btn-secondary",3,"click","disabled"],["class","emptyState-text text-center mb-2",4,"ngIf"],[1,"emptyState-text","text-center","mb-2"]],template:function(n,i){if(n&1){let o=y();l(0,"div",5)(1,"div",6)(2,"div",7)(3,"div",8)(4,"div",9)(5,"input",10),L("ngModelChange",function(m){return d(o),O(i.markItem,m)||(i.markItem=m),f(m)}),u("change",function(){return d(o),f(i.toggleCheckboxForTops(i.costCenter.code,i.markItem))}),p(),v(6,"span",11),l(7,"label",12),h(8),p()()(),l(9,"div",13),g(10,bo,5,3,"ng-container",14)(11,yo,6,8,"ng-template",null,0,w),l(13,"button",15),u("click",function(){return d(o),f(i.showDetails())}),g(14,vo,3,4,"span",14)(15,To,2,4,"ng-template",null,1,w),p()()()(),l(17,"div",16),u("inViewportAction",function(m){return d(o),f(i.onChangeViewport(m))}),g(18,Oo,2,1,"ng-container",14)(19,Ao,2,2,"ng-template",null,2,w),p()()}if(n&2){let o=F(12),r=F(16),m=F(20);a(5),Y("id","markMeCostCenter_",i.costCenter.code,""),s("ngClass",R(15,go,i.isPartiallyMarked())),k("ngModel",i.markItem),a(2),Y("for","markMeCostCenter_",i.costCenter.code,""),a(),S(" ",i.costCenter.name," "),a(2),s("ngIf",i.isMobile)("ngIfElse",o),a(4),s("ngIf",i.isExpanded)("ngIfElse",r),a(3),s("inViewportOptions",R(18,xo,Te(17,_o)))("ngbCollapse",!i.isExpanded),a(),s("ngIf",!i.isLoading&&!i.isError)("ngIfElse",m)}},dependencies:[ge,P,ee,nn,be,Q,U,$,_e,kn,Ye,An,W],encapsulation:2,changeDetection:0}),re);nt=Co([Se(),ho("design:paramtypes",[Ge,N,A,B,E,Ve,V])],nt);var Ro=function(t,e,n,i){var o=arguments.length,r=o<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,n):i,m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(t,e,n,i);else for(var b=t.length-1;b>=0;b--)(m=t[b])&&(r=(o<3?m(r):o>3?m(e,n,r):m(e,n))||r);return o>3&&r&&Object.defineProperty(e,n,r),r},Po=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)},Bo=t=>({active:t}),Ho=()=>({labelForId:"bulkActionDropDownMobile"}),No=()=>({cssClass:"wide-panel",labelForId:"bulkActionDropDown"});function jo(t,e){if(t&1){let n=y();l(0,"div",9)(1,"button",10),u("click",function(){d(n);let o=c();return f(o.showChartComplete())}),v(2,"cx-icon",11),h(3),C(4,"cxTranslate"),p()()}if(t&2){let n=c();a(),s("disabled",n.isEmptyListOfCodes()),a(),s("type",n.icons.PIE_CHART),a(),S(" ",_(4,3,"costCenterManagementList.showChartComplete")," ")}}function Wo(t,e){if(t&1){let n=y();T(0),l(1,"div",15)(2,"button",16),u("click",function(){d(n);let o=c(2);return f(o.openAll())}),h(3),C(4,"cxTranslate"),p()(),I()}if(t&2){let n=c(2);a(3),S(" ",_(4,1,n.getLabel())," ")}}function Uo(t,e){if(t&1){let n=y();l(0,"div",17)(1,"button",16),u("click",function(){d(n);let o=c(2);return f(o.openAll())}),h(2),C(3,"cxTranslate"),p()()}if(t&2){let n=c(2);a(2),S(" ",_(3,1,n.getLabel())," ")}}function $o(t,e){if(t&1){let n=y();T(0),l(1,"div",12)(2,"div",13)(3,"foerch-date-range",14),u("dateRangeChanged",function(o){d(n);let r=c();return f(r.onDateRangeChanged(o))}),p()(),g(4,Wo,5,3,"ng-container",8)(5,Uo,4,3,"ng-template",null,2,w),p(),I()}if(t&2){let n=F(6),i=c();a(3),s("dateRange",i.interval)("isMobile",i.isMobile)("maxDate",i.maxDate)("useDefaultValue",i.useDefaultValue),a(),s("ngIf",i.isMobile)("ngIfElse",n)}}function zo(t,e){if(t&1&&(l(0,"div",21)(1,"div",22)(2,"div",23),h(3),p()()()),t&2){let n=c().$implicit;a(3),ke(" ",n.code," ",n.name," ")}}function Xo(t,e){if(t&1){let n=y();l(0,"foerch-cost-center-management",24),u("itemToggledForSubs",function(o){d(n);let r=c(3);return f(r.onToggleCheckBoxForSubs(o))})("itemToggledForTops",function(o){d(n);let r=c(3);return f(r.onToggleCheckBoxForTops(o))}),p()}if(t&2){let n=e.$implicit,i=c(3);s("costCenter",n)("interval",i.interval)("isAllExpanded",i.expandAll)("isMobile",i.isMobile)("markItem",i.selectionHelperForTops.getItemStatus(n.code))}}function Yo(t,e){if(t&1&&(T(0),g(1,zo,4,2,"div",19)(2,Xo,1,5,"foerch-cost-center-management",20),I()),t&2){let n=e.$implicit,i=c(2);a(),s("ngIf",i.costCenterUnits.length>1),a(),s("ngForOf",n.costCenters)("ngForTrackBy",i.trackByCostCenterCode)}}function qo(t,e){t&1&&st(0)}function Go(t,e){if(t&1){let n=y();T(0),l(1,"div",25)(2,"div",12)(3,"div",22)(4,"div",26)(5,"input",27),L("ngModelChange",function(o){d(n);let r=c(2);return O(r.areAllSelected,o)||(r.areAllSelected=o),f(o)}),u("click",function(){d(n);let o=c(2);return f(o.toggleAll())}),p(),l(6,"label",28),h(7),C(8,"cxTranslate"),p()()(),l(9,"div",15)(10,"button",29),u("click",function(){d(n);let o=c(2);return f(o.isCollapsedBatchProcessing=!o.isCollapsedBatchProcessing)}),h(11),C(12,"cxTranslate"),v(13,"cx-icon",11),p()()(),l(14,"div",30)(15,"div",31),g(16,qo,1,0,"ng-container",32),p(),l(17,"button",33),u("click",function(){d(n);let o=c(2);return f(o.applyBulkAction())}),h(18),C(19,"cxTranslate"),p()()(),I()}if(t&2){let n=c(2),i=F(12);a(5),k("ngModel",n.areAllSelected),a(2),j(_(8,10,"cartDialog.markAll")),a(3),s("ngClass",R(16,Bo,!n.isCollapsedBatchProcessing)),a(),S(" ",_(12,12,"common.batchProcessing")," "),a(2),s("type",n.icons.ARROW_DOWN),a(),s("ngbCollapse",n.isCollapsedBatchProcessing),a(2),s("ngTemplateOutlet",i)("ngTemplateOutletContext",Te(18,Ho)),a(),s("disabled",n.selectedOption&&n.selectedOption.disabled||n.isEmptyListOfCodes()),a(),S(" ",_(19,14,"common.apply")," ")}}function Ko(t,e){t&1&&st(0)}function Jo(t,e){if(t&1){let n=y();l(0,"div",34)(1,"div",35)(2,"div",36)(3,"div",26)(4,"input",37),L("ngModelChange",function(o){d(n);let r=c(2);return O(r.areAllSelected,o)||(r.areAllSelected=o),f(o)}),u("click",function(){d(n);let o=c(2);return f(o.toggleAll())}),p(),l(5,"label",38),h(6),C(7,"cxTranslate"),p()()(),l(8,"div",39),g(9,Ko,1,0,"ng-container",32),p(),l(10,"div",40)(11,"button",41),u("click",function(){d(n);let o=c(2);return f(o.applyBulkAction())}),h(12),C(13,"cxTranslate"),p()(),l(14,"div",42)(15,"button",16),u("click",function(){d(n);let o=c(2);return f(o.openAll())}),h(16),C(17,"cxTranslate"),p()()()()}if(t&2){let n=c(2),i=F(12);a(4),k("ngModel",n.areAllSelected),a(2),j(_(7,7,"cartDialog.markAll")),a(3),s("ngTemplateOutlet",i)("ngTemplateOutletContext",Te(13,No)),a(2),s("disabled",n.selectedOption&&n.selectedOption.disabled||n.isEmptyListOfCodes()),a(),S(" ",_(13,9,"common.apply")," "),a(4),S(" ",_(17,11,n.getLabel())," ")}}function Zo(t,e){if(t&1&&(T(0),g(1,Yo,3,3,"ng-container",18)(2,Go,20,19,"ng-container",8)(3,Jo,18,14,"ng-template",null,2,w),I()),t&2){let n=F(4),i=c();a(),s("ngForOf",i.costCenterUnits)("ngForTrackBy",i.trackByUnit),a(),s("ngIf",i.isMobile)("ngIfElse",n)}}function Qo(t,e){t&1&&v(0,"cx-spinner",47)}function er(t,e){if(t&1&&(l(0,"div",43)(1,"div",44)(2,"div",45),h(3),C(4,"cxTranslate"),p(),g(5,Qo,1,0,"cx-spinner",46),p()()),t&2){let n=c();a(2),s("ngClass",n.isLoading?"small":"emptyState-text"),a(),S(" ",_(4,3,n.isLoading?"costCenterList.table.loading":"costCenterList.table.empty")," "),a(2),s("ngIf",n.isLoading)}}function tr(t,e){if(t&1){let n=y();l(0,"ng-select",49),C(1,"cxTranslate"),L("ngModelChange",function(o){d(n);let r=c(2);return O(r.selectedOption,o)||(r.selectedOption=o),f(o)}),u("change",function(o){d(n);let r=c(2);return f(r.optionChanged(o))}),p()}if(t&2){let n=e.ngIf,i=c(),o=i.cssClass,r=i.labelForId,m=c();Xt("cartBulkEdit-select ",o,""),Yt("labelForId",r),s("clearable",!1)("items",n)("placeholder",_(1,9,"common.markedArticles"))("searchable",!1),k("ngModel",m.selectedOption)}}function nr(t,e){if(t&1&&(g(0,tr,2,11,"ng-select",48),C(1,"async")),t&2){let n=c();s("ngIf",_(1,1,n.bulkActionOptions$))}}var J=function(t){return t[t.EXPORT_SUMMARY_LIST_AS_PDF=1]="EXPORT_SUMMARY_LIST_AS_PDF",t[t.EXPORT_SUMMARY_LIST_AS_EXCEL=2]="EXPORT_SUMMARY_LIST_AS_EXCEL",t[t.EXPORT_POSITION_LIST_AS_EXCEL=3]="EXPORT_POSITION_LIST_AS_EXCEL",t[t.SHOW_COMPLETE_CHART=4]="SHOW_COMPLETE_CHART",t}(J||{}),ae,Dn=(ae=class{constructor(e,n,i,o,r){this.costCentersManagementService=e,this.translationService=n,this.modalService=i,this._breakpointService=o,this._cd=r,this.isEmptyCostCenterUnits=!0,this.icons=H,this.isLoaded=!1,this.isLoading=!1,this.bulkActionOptions$=new Vt([]),this.selectionHelperForTops=new Ue,this.areAllSelected=!1,this.expandAll=!1,this.interval=null,this.isMobile=!1,this.isCollapsedBatchProcessing=!0,this.maxDate=new Date,this.useDefaultValue=!1,this._sub$=new pe,this.codeMap=new Map,this.setActionOptions()}ngOnInit(){this._sub$.add(this.costCentersManagementService.get().subscribe(e=>{e.costCenterUnits&&(this.handleCostCentersResult(e),this.isEmptyCostCenterUnits||this.setItemsSelectionHelper(),this._cd.detectChanges())})),this._sub$.add(this._breakpointService.breakpoint$.subscribe(e=>{this.isMobile=e===Zt.xs,this._cd.detectChanges()})),this._sub$.add(this.costCentersManagementService.getInterval().subscribe(e=>{e.loaded&&(lt(e.start)&&lt(e.end)?this.interval={start:e.start,end:e.end}:this.useDefaultValue=!0),e.error&&(this.useDefaultValue=!0)})),this.costCentersManagementService.load()}ngOnDestroy(){this._sub$.unsubscribe()}trackByUnit(e,n){return n.code}handleCostCentersResult(e){this.costCenterUnits=e.costCenterUnits,this.isLoaded=e.loaded,this.isLoading=e.loading;let n=!1;for(let i=0;i<e.costCenterUnits.length;i++)if(e.costCenterUnits[i].costCenters.length!==0){n=!0;break}this.isEmptyCostCenterUnits=!n}onDateRangeChanged(e){this.costCentersManagementService.setInterval(e)}showChartComplete(){let e=this.modalService.open(ye,{centered:!0,size:"xl"});e&&(e.componentInstance.costCenterCodes=this.getListOfCodes(),e.componentInstance.interval=this.interval)}setItemsSelectionHelper(){let e=[];for(let n of this.costCenterUnits)for(let i of n.costCenters)e.push({id:i.code,item:i});this.selectionHelperForTops.updateItems(e)}trackByCostCenterCode(e,n){return n.code}openAll(){this.expandAll=!this.expandAll}getLabel(){return this.expandAll?"common.closeAll":"common.openAll"}isEmptyListOfCodes(){return this.getListOfCodes().length===0}applyBulkAction(){let e=this.getListOfCodes();if(e.length>0){let n={costCenterCodes:e,chart:xe.NONE,interval:this.interval,isPDF:!1,isTable:!0};switch(this.selectedOption.code){case J.EXPORT_SUMMARY_LIST_AS_PDF:{this.costCentersManagementService.createReport(Lt(Ot({},n),{isPDF:!0}));break}case J.EXPORT_SUMMARY_LIST_AS_EXCEL:{this.costCentersManagementService.createReport(n);break}case J.EXPORT_POSITION_LIST_AS_EXCEL:{this.costCentersManagementService.createPositionListReport({costCenterCodes:e,chart:xe.NONE,interval:this.interval});break}case J.SHOW_COMPLETE_CHART:{this.showChartComplete();break}default:console.error("unimplemented option",this.selectedOption)}}}optionChanged(e){this.selectedOption=e}onToggleCheckBoxForTops(e){e.checked?this.codeMap.set(e.topCode,[]):this.codeMap.has(e.topCode)&&this.codeMap.delete(e.topCode),this.selectionHelperForTops.toggleItemStatus(e.topCode,e.checked),this.areAllSelected=this.selectionHelperForTops.areAllSelected()}onToggleCheckBoxForSubs(e){if(e.checked)if(this.codeMap.has(e.topCode)){if(!this.checkForExistingSubCode(e.topCode,e.subCode)){let n=[...this.codeMap.get(e.topCode),e.subCode];this.codeMap.set(e.topCode,n)}}else this.codeMap.set(e.topCode,[e.subCode]);else if(this.codeMap.has(e.topCode)){let i=this.codeMap.get(e.topCode).filter(o=>o!==e.subCode);this.codeMap.set(e.topCode,i)}}getListOfCodes(){let e=[];return this.codeMap.forEach((n,i)=>{n.length>0?e=[...e,...n]:e.push(i)}),e}checkForExistingSubCode(e,n){return this.codeMap.get(e).includes(n)}toggleAll(){if(this.selectionHelperForTops.toggleAll(),this.areAllSelected=this.selectionHelperForTops.areAllSelected(),!this.areAllSelected)this.codeMap.clear();else{this.codeMap.clear();for(let e of this.selectionHelperForTops.getAllItems())this.codeMap.set(e.id,[])}}setActionOptions(){this._sub$.add(Dt([this.translationService.translate("costCenterManagementList.table.actions.exportSummaryListAsExcel"),this.translationService.translate("costCenterManagementList.table.actions.exportSummaryListAsPdf"),this.translationService.translate("costCenterManagementList.table.actions.exportPositionListAsExcel"),this.translationService.translate("costCenterManagementList.table.actions.showCompleteChart")]).subscribe(([e,n,i,o])=>{let r=[];r.push({name:e,code:J.EXPORT_SUMMARY_LIST_AS_EXCEL}),r.push({name:n,code:J.EXPORT_SUMMARY_LIST_AS_PDF}),r.push({name:i,code:J.EXPORT_POSITION_LIST_AS_EXCEL}),r.push({name:o,code:J.SHOW_COMPLETE_CHART}),this.bulkActionOptions$.next(r),this.selectedOption=r[0]}))}},ae.\u0275fac=function(n){return new(n||ae)(x(te),x(Pe),x(N),x(He),x(V))},ae.\u0275cmp=M({type:ae,selectors:[["foerch-cost-center-management-list"]],decls:13,vars:7,consts:[["emptyList",""],["bulkActions",""],["isDesktop",""],[1,"row","justify-content-between","mb-2","mb-md-4"],[1,"col-md-auto"],[1,"h3","mb-0"],["class","mt-2 mt-md-0 mw-sm-down-400",4,"ngIf"],[4,"ngIf"],[4,"ngIf","ngIfElse"],[1,"mt-2","mt-md-0","mw-sm-down-400"],["type","button",1,"btn","btn-primary","btn-block","btn-icon_left",3,"click","disabled"],[3,"type"],[1,"row"],[1,"col-md-9"],[3,"dateRangeChanged","dateRange","isMobile","maxDate","useDefaultValue"],[1,"col","text-end"],[1,"btn","btn-link_secondary",3,"click"],[1,"col-md-3","text-end"],[4,"ngFor","ngForOf","ngForTrackBy"],["class","row costCenterManagementUnit",4,"ngIf"],[3,"costCenter","interval","isAllExpanded","isMobile","markItem","itemToggledForSubs","itemToggledForTops",4,"ngFor","ngForOf","ngForTrackBy"],[1,"row","costCenterManagementUnit"],[1,"col"],[1,"costCenterManagementUnit-title"],[3,"itemToggledForSubs","itemToggledForTops","costCenter","interval","isAllExpanded","isMobile","markItem"],[1,"bulkEditMobile","bulkEdit_shift"],[1,"form-check","form-checkbox"],["id","markAllMobile","name","markAllMobile","type","checkbox","role","checkbox",1,"form-check-input",3,"ngModelChange","click","ngModel"],["for","markAllMobile",1,"form-check-label"],["type","button",1,"btn","bulkEditMobile-toggle",3,"click","ngClass"],[3,"ngbCollapse"],[1,"form-group","mt-2"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],["type","button",1,"btn","btn-block","btn-secondary",3,"click","disabled"],[1,"costCenterNodesList-bulkEdit"],[1,"row","align-items-center"],[1,"col-auto"],["id","markAll","name","markAll","type","checkbox",1,"form-check-input",3,"ngModelChange","click","ngModel"],["for","markAll",1,"form-check-label"],[1,"col-auto","pe-2"],[1,"col-auto","ps-0"],["type","button",1,"btn","btn-secondary",3,"click","disabled"],[1,"col-md-auto","ms-auto","text-end","d-none","d-md-block"],[1,"row","emptyState"],[1,"col-12"],[3,"ngClass"],["class","mt-2",4,"ngIf"],[1,"mt-2"],["bindLabel","name",3,"class","labelForId","clearable","items","placeholder","searchable","ngModel","ngModelChange","change",4,"ngIf"],["bindLabel","name",3,"ngModelChange","change","labelForId","clearable","items","placeholder","searchable","ngModel"]],template:function(n,i){if(n&1&&(l(0,"div",3)(1,"div",4)(2,"div",5),h(3),C(4,"cxTranslate"),p()(),l(5,"div",4),g(6,jo,5,5,"div",6),p()(),g(7,$o,7,6,"ng-container",7)(8,Zo,5,4,"ng-container",8)(9,er,6,5,"ng-template",null,0,w)(11,nr,2,3,"ng-template",null,1,w)),n&2){let o=F(10);a(3),S(" ",_(4,5,"costCenterManagementList.pageTitle")," "),a(3),s("ngIf",!i.isEmptyCostCenterUnits),a(),s("ngIf",!i.isEmptyCostCenterUnits),a(),s("ngIf",!i.isEmptyCostCenterUnits&&i.isLoaded)("ngIfElse",o)}},dependencies:[ge,Z,P,Gt,ee,be,Be,Q,U,$,on,_e,nt,Le,W],encapsulation:2,changeDetection:0}),ae);Dn=Ro([Se(),Po("design:paramtypes",[te,Pe,N,He,V])],Dn);export{$a as a,Dn as b};