import{b as ct}from"./chunk-X6XKYEEJ.js";import{c as rt}from"./chunk-PY36RJBP.js";import{c as st}from"./chunk-7M3X7FU6.js";import{b as ee}from"./chunk-5OZTUYJC.js";import{J as ge}from"./chunk-CWWVHRJU.js";import{c as $e}from"./chunk-TFQ3RBKD.js";import{a as it}from"./chunk-TRE4H2YK.js";import{a as nt,b as ot}from"./chunk-NLWV7OZT.js";import{a as tt}from"./chunk-N2WXLUZD.js";import{a as Ze}from"./chunk-RU43IR5J.js";import{a as et}from"./chunk-SLGBXDUF.js";import{a as Xe}from"./chunk-LY6HB4BL.js";import{Qo as Ge,Re as Ke,Ue as qe,Vk as ye,_d as We,hl as Te,ll as Ye,ml as Je,nl as ze,rl as Ee}from"./chunk-RQDYBYBM.js";import{T as Qe,U as D,ba as ae}from"./chunk-FBI7JGZC.js";import{a as Z}from"./chunk-ILYMG6ZI.js";import{r as X}from"./chunk-MXUIPT66.js";import{I as ue,f as Ce,l as he}from"./chunk-DX7LHTFF.js";import{$d as Ne,Aa as h,Ab as l,Ba as u,Bb as L,Cb as S,Ce as Ue,Db as P,Dc as Y,E as Fe,Eb as Pe,Fb as E,Gd as Oe,Ge as He,Ka as U,Kb as f,Kd as De,Lb as c,N as Me,Ob as Ae,Og as je,Pb as B,Ua as s,Va as y,Vc as de,Wc as J,Xb as k,Xc as R,Yb as m,Zb as I,_b as b,a as Ie,ad as Be,ae as me,bd as Q,be as ce,cc as oe,dc as re,ec as se,fh as _e,gb as we,gd as z,ib as g,ic as Ve,jc as O,kc as H,la as Re,lc as j,o as ke,oa as Se,ob as a,rc as d,rg as G,sc as C,t as Le,ta as M,tc as q,vc as $,wc as F,yh as w,zb as p}from"./chunk-N6B2OJOY.js";import{a as V,b as ne}from"./chunk-GHL4OFBQ.js";var ft=ce(Ge,t=>t.costCentersManagementState.costCenterPositions),fe=ce(ft,t=>({entities:t.entities,loading:t.loading,loaded:t.loaded,error:t.error})),at=ce(fe,t=>t.loading),lt=ce(fe,t=>t.loaded);var te=(()=>{let r=class r{constructor(i,n){this.foerchStore=i,this.userIdService=n}get(){return this.foerchStore.pipe(me(fe))}load(i,n){this.withUserId(o=>{let{intervalStart:_,intervalEnd:v}=this.intervalToDateStrings(n);this.foerchStore.dispatch(new Ke({userId:o,costCenterCodes:i,intervalStart:_,intervalEnd:v}))})}isLoading(){return this.foerchStore.pipe(me(at))}isLoaded(){return this.foerchStore.pipe(me(lt))}rebook(i,n,o,_,v,x){this.withUserId(T=>{let{intervalStart:N,intervalEnd:A}=this.intervalToDateStrings(x);this.foerchStore.dispatch(new qe({userId:T,sourceCostCenterCode:i,targetCostCenterCode:n,orderReason:o,pks:_,costCenterCodes:v,intervalStart:N,intervalEnd:A}))})}intervalToDateStrings(i){return{intervalStart:Te(i.start,{representation:"date"}),intervalEnd:Te(i.end,{representation:"date"})}}withUserId(i){this.userIdService.getUserId().pipe(Fe(n=>n!==Ue),Me(1)).subscribe(n=>i(n))}};r.\u0275fac=function(n){return new(n||r)(Se(Ne),Se(He))},r.\u0275prov=Re({token:r,factory:r.\u0275fac,providedIn:"root"});let t=r;return t})();var xt=(t,r)=>({currencyCode:t,localeCode:r}),mt=(t,r,e)=>[t,r,"symbol","1.2",e],vt=t=>({query:t});function St(t,r){if(t&1){let e=E();p(0,"th")(1,"foerch-table-sort",6),d(2,"cxTranslate"),f("changeSorting",function(n){h(e);let o=c(3);return u(o.onSortingChange(n))}),l()()}if(t&2){let e=c(3);s(),a("sortBy",e.sortBy.CUSTOMER)("sortModel",e.sortModel)("title",C(2,3,"costCenterPositionList.table.customerHeader"))}}function Pt(t,r){if(t&1){let e=E();p(0,"div",12)(1,"input",13),f("click",function(){h(e);let n=c().$implicit,o=c(3);return u(o.onChangeSelection(n.orderEntryPK))}),l(),L(2,"label",14),l()}if(t&2){let e=c().$implicit,i=c(3);s(),B("id","markCostCenterPositionItem_",e.orderEntryPK,""),a("checked",i.mapping[i.costCenterPositionCode].positions[e.orderEntryPK].selected),s(),B("for","markCostCenterPositionItem_",e.orderEntryPK,"")}}function yt(t,r){if(t&1&&(S(0),m(1),P()),t&2){let e=c().$implicit;s(),b(" ",e.supplierAlternativeAID?e.supplierAlternativeAID:e.productCode," ")}}function Tt(t,r){if(t&1&&(S(0),m(1),P()),t&2){let e=c().$implicit;s(),b(" ",e.customArticleCode," ")}}function Et(t,r){if(t&1&&(p(0,"div"),m(1),l()),t&2){let e=c().$implicit;s(),b(" ",e.customArticleCode," ")}}function It(t,r){if(t&1&&(p(0,"td"),m(1),l()),t&2){let e=c().$implicit;s(),I(e.b2BUnit||"-")}}function kt(t,r){if(t&1&&(p(0,"tr")(1,"td"),g(2,Pt,3,5,"div",9),p(3,"div",10)(4,"div",11),g(5,yt,2,1,"ng-container",1)(6,Tt,2,1,"ng-container",1),l(),g(7,Et,2,1,"div",1),l()(),p(8,"td"),m(9),l(),p(10,"td"),m(11),d(12,"cxDate"),l(),p(13,"td"),m(14),l(),g(15,It,2,1,"td",1),p(16,"td"),m(17),l(),p(18,"td")(19,"strong"),m(20),d(21,"currency"),l()()()),t&2){let e=r.$implicit,i=c(2).ngIf,n=c();s(2),a("ngIf",n.isSelectionEnabled),s(3),a("ngIf",n.articleNumberMode!==n.articleNumberModes.CUSTOMER||!e.customArticleCode),s(),a("ngIf",n.articleNumberMode===n.articleNumberModes.CUSTOMER&&e.customArticleCode),s(),a("ngIf",n.articleNumberMode===n.articleNumberModes.BOTH&&e.customArticleCode),s(2),I(e.productDescription||"-"),s(2),I(C(12,10,e.purchaseDate)),s(3),I(e.orderReasonName||"-"),s(),a("ngIf",n.showCustomerColumn),s(2),I(e.count),s(3),I($(21,12,j(18,mt,e.totalPrice,i.currencyCode,i.localeCode)))}}function Lt(t,r){if(t&1&&(S(0),m(1),d(2,"cxTranslate"),p(3,"strong"),m(4),d(5,"currency"),l(),P()),t&2){let e=c(3).ngIf,i=c();s(),b(" ",C(2,2,"costCenterPositionList.table.sumHeader")," "),s(3),I($(5,4,j(10,mt,i.totalPrice,e.currencyCode,e.localeCode)))}}function Ft(t,r){if(t&1&&(p(0,"div",15),g(1,Lt,6,14,"ng-container",1),l()),t&2){let e=c(3);s(),a("ngIf",e.areAllArticlesShown)}}function Mt(t,r){if(t&1){let e=E();p(0,"div",3)(1,"foerch-table-reset",4),f("resetSorting",function(){h(e);let n=c(2);return u(n.onSortingReset())}),l(),p(2,"table",5)(3,"thead")(4,"tr")(5,"th")(6,"foerch-table-sort",6),d(7,"cxTranslate"),f("changeSorting",function(n){h(e);let o=c(2);return u(o.onSortingChange(n))}),l()(),p(8,"th")(9,"foerch-table-sort",6),d(10,"cxTranslate"),f("changeSorting",function(n){h(e);let o=c(2);return u(o.onSortingChange(n))}),l()(),p(11,"th")(12,"foerch-table-sort",6),d(13,"cxTranslate"),f("changeSorting",function(n){h(e);let o=c(2);return u(o.onSortingChange(n))}),l()(),p(14,"th")(15,"foerch-table-sort",6),d(16,"cxTranslate"),f("changeSorting",function(n){h(e);let o=c(2);return u(o.onSortingChange(n))}),l()(),g(17,St,3,5,"th",1),p(18,"th")(19,"foerch-table-sort",6),d(20,"cxTranslate"),f("changeSorting",function(n){h(e);let o=c(2);return u(o.onSortingChange(n))}),l()(),p(21,"th")(22,"foerch-table-sort",6),d(23,"cxTranslate"),f("changeSorting",function(n){h(e);let o=c(2);return u(o.onSortingChange(n))}),l()()()(),p(24,"tbody"),g(25,kt,22,22,"tr",7),l()(),g(26,Ft,2,1,"div",8),l()}if(t&2){let e=c(2);s(),a("enabled",e.hasActiveSorting),s(5),a("sortBy",e.sortBy.CODE)("sortModel",e.sortModel)("title",C(7,23,"costCenterPositionList.table.articleNumberHeader")),s(3),a("sortBy",e.sortBy.DESCRIPTION)("sortModel",e.sortModel)("title",C(10,25,"costCenterPositionList.table.articleHeader")),s(3),a("sortBy",e.sortBy.PURCHASE_DATE)("sortModel",e.sortModel)("title",C(13,27,"costCenterPositionList.table.purchaseDateHeader")),s(3),a("sortBy",e.sortBy.REASON)("sortModel",e.sortModel)("title",C(16,29,"costCenterPositionList.table.orderReasonHeader")),s(2),a("ngIf",e.showCustomerColumn),s(2),a("sortBy",e.sortBy.AMOUNT)("sortModel",e.sortModel)("title",C(20,31,"costCenterPositionList.table.amountHeader")),s(3),a("sortBy",e.sortBy.SUM)("sortModel",e.sortModel)("title",C(23,33,"costCenterPositionList.table.sumHeader")),s(3),a("ngForOf",e.visiblePositions)("ngForTrackBy",e.trackByPK),s(),a("ngIf",e.showTotalPrice&&e.visiblePositions.length>0)}}function Rt(t,r){if(t&1&&(p(0,"div",16)(1,"div",17),m(2),d(3,"cxTranslate"),l()()),t&2){let e=c(2);s(2),b(" ",q(3,1,e.searchQuery!==""?"costCenterPositionList.table.noSearchResults":"costCenterPositionList.table.noPositions",O(4,vt,e.searchQuery))," ")}}function wt(t,r){if(t&1&&(S(0),g(1,Mt,27,35,"div",2)(2,Rt,4,6,"ng-template",null,0,F),P()),t&2){let e=k(3),i=c();s(),a("ngIf",i.visiblePositions.length>0)("ngIfElse",e)}}var W=function(t){return t.CODE="productCode",t.DESCRIPTION="productDescription",t.REASON="orderReasonName",t.CUSTOMER="b2BUnit",t.AMOUNT="count",t.SUM="totalPrice",t.PURCHASE_DATE="purchaseDate",t}(W||{}),ie=(()=>{let r=class r{set positions(i){this._positions=i,this.showCustomerColumn=this.hasPositionWithDifferentCustomerB2BUnit(),this.sortArticles()}get positions(){return this._positions}set totalPrice(i){this._totalPriceOfPositions=i,this.showTotalPrice=!0}get totalPrice(){return this._totalPriceOfPositions}set mapping(i){this._mapping=i,this.updateVisiblePositions()}get mapping(){return this._mapping}set b2bUnit(i){this._b2bUnit=i,this.showCustomerColumn=this.hasPositionWithDifferentCustomerB2BUnit()}get b2bUnit(){return this._b2bUnit}set sortModel(i){this.onSortingChange(i)}get sortModel(){return this._sortModel}constructor(i,n,o){this.currencyService=i,this.currencyLocaleService=n,this.cd=o,this.searchQuery="",this.isSelectionEnabled=!1,this.articleNumberMode=D.FOERCH,this.selectionChanged=new U,this.locale$=this.currencyLocaleService.getActiveLocaleForCurrencyPipe(),this.currency$=this.currencyService.getActive(),this.sortBy=W,this.visiblePositions=[],this.showTotalPrice=!1,this.areAllArticlesShown=!0,this.showCustomerColumn=!1,this.articleNumberModes=D,this.defaultSortModel={sortBy:W.CODE,sortDirection:ae.ASC},this.hasActiveSorting=!1,this._sortModel=this.defaultSortModel,this._positions=[]}ngOnInit(){this.updateVisiblePositions()}onSortingChange(i,n=!0){n&&(this.hasActiveSorting=!0),this._sortModel=i,this.sortArticles()}onSortingReset(){this.hasActiveSorting=!1,this.onSortingChange(this.defaultSortModel,!1)}trackByPK(i,n){return n.orderEntryPK}isSelected(i){return this.mapping[this.costCenterPositionCode].positions[i].selected===!0}onChangeSelection(i){this.selectionChanged.emit({costCenterPosition:this.costCenterPositionCode,position:i})}sortArticles(){let i=this.sortModel.sortBy,n=this.sortModel.sortDirection===ae.ASC,o=i===W.AMOUNT||i===W.SUM?0:"";this._positions=[...this._positions||[]].sort((_,v)=>{let x=typeof _[i]<"u"?_[i]:o,T=typeof v[i]<"u"?v[i]:o;if(x>T)return n?1:-1;if(_[i]<v[i])return n?-1:1;if(i!==W.CODE){if(_.productCode>v.productCode)return 1;if(_.productCode<v.productCode)return-1}return 0}),this.updateVisiblePositions()}updateVisiblePositions(){this.costCenterPositionCode&&(this.visiblePositions=this.positions.filter(i=>{let n=this.mapping[this.costCenterPositionCode].positions[i.orderEntryPK];return n&&n.visible}),this.areAllArticlesShown=this.visiblePositions.length===Object.keys(this.mapping[this.costCenterPositionCode].positions).length)}hasPositionWithDifferentCustomerB2BUnit(){return this.positions&&this.positions.length>0&&this.b2bUnit?this.positions.some(i=>i.b2BUnit!==this.b2bUnit):!1}};r.\u0275fac=function(n){return new(n||r)(y(G),y(ee),y(Y))},r.\u0275cmp=M({type:r,selectors:[["foerch-cost-center-position-list-table"]],inputs:{positions:"positions",totalPrice:"totalPrice",mapping:"mapping",b2bUnit:"b2bUnit",sortModel:"sortModel",searchQuery:"searchQuery",costCenterPositionCode:"costCenterPositionCode",isSelectionEnabled:"isSelectionEnabled",articleNumberMode:"articleNumberMode"},outputs:{selectionChanged:"selectionChanged"},decls:3,vars:8,consts:[["noPositions",""],[4,"ngIf"],["class","costCenterPositionListTable",4,"ngIf","ngIfElse"],[1,"costCenterPositionListTable"],[3,"resetSorting","enabled"],[1,"cartTable","costCenterPositionListTable-table"],[3,"changeSorting","sortBy","sortModel","title"],[4,"ngFor","ngForOf","ngForTrackBy"],["class","costCenterPositionListTable-sum",4,"ngIf"],["class","form-check form-checkbox costCenterPositionListTable-checkbox",4,"ngIf"],[1,"costCenterPositionListTable-table-codedate"],[1,"costCenterPositionListTable-table-code"],[1,"form-check","form-checkbox","costCenterPositionListTable-checkbox"],["name","costCenterPositionItem","type","checkbox","role","checkbox",1,"form-check-input",3,"click","id","checked"],[1,"form-check-label",3,"for"],[1,"costCenterPositionListTable-sum"],[1,"emptyState"],[1,"emptyState-text"]],template:function(n,o){n&1&&(g(0,wt,4,2,"ng-container",1),d(1,"async"),d(2,"async")),n&2&&a("ngIf",H(5,xt,C(1,1,o.currency$),C(2,3,o.locale$)))},dependencies:[J,R,ot,nt,Q,z,w,_e],encapsulation:2,changeDetection:0});let t=r;return t})();var At=(t,r)=>({currencyCode:t,localeCode:r}),Ct=(t,r,e)=>[t,r,"symbol","1.2",e],Vt=t=>({query:t});function Bt(t,r){if(t&1){let e=E();S(0),p(1,"div",12)(2,"input",13),f("click",function(){h(e);let n=c().$implicit,o=c(3);return u(o.onChangeSelection(n.orderEntryPK))}),l(),L(3,"label",14),l(),P()}if(t&2){let e=c().$implicit,i=c(3);s(2),B("id","markCostCenterPositionItem_",e.orderEntryPK,""),a("checked",i.mapping[i.costCenterPositionCode].positions[e.orderEntryPK].selected),s(),B("for","markCostCenterPositionItem_",e.orderEntryPK,"")}}function Ot(t,r){if(t&1&&(S(0),m(1),P()),t&2){let e=c().$implicit;s(),b(" ",e.supplierAlternativeAID?e.supplierAlternativeAID:e.productCode," ")}}function Dt(t,r){if(t&1&&(S(0),m(1),P()),t&2){let e=c().$implicit;s(),b(" ",e.customArticleCode," ")}}function Nt(t,r){if(t&1&&(p(0,"div",10),m(1),l()),t&2){let e=c().$implicit;s(),b(" ",e.customArticleCode," ")}}function Ut(t,r){if(t&1&&(p(0,"tr")(1,"td"),m(2),d(3,"cxTranslate"),l(),p(4,"td"),m(5),l()()),t&2){let e=c().$implicit;s(2),b(" ",C(3,2,"costCenterPositionList.table.customerHeader")," "),s(3),I(e.b2BUnit||"-")}}function Ht(t,r){if(t&1&&(p(0,"div",6),g(1,Bt,4,5,"ng-container",3),p(2,"div",7),m(3),d(4,"cxDate"),l(),p(5,"div",8),g(6,Ot,2,1,"ng-container",3)(7,Dt,2,1,"ng-container",3),l(),g(8,Nt,2,1,"div",9),p(9,"div",10),m(10),l(),p(11,"table",11)(12,"tbody")(13,"tr")(14,"td"),m(15),d(16,"cxTranslate"),l(),p(17,"td"),m(18),l()(),g(19,Ut,6,4,"tr",3),p(20,"tr")(21,"td"),m(22),d(23,"cxTranslate"),l(),p(24,"td"),m(25),l()(),p(26,"tr")(27,"td"),m(28),d(29,"cxTranslate"),l(),p(30,"td"),m(31),d(32,"currency"),l()()()()()),t&2){let e=r.$implicit,i=c().ngIf,n=c(2);s(),a("ngIf",n.isSelectionEnabled),s(2),b(" ",C(4,13,e.purchaseDate)," "),s(3),a("ngIf",n.articleNumberMode!==n.articleNumberModes.CUSTOMER||!e.customArticleCode),s(),a("ngIf",n.articleNumberMode===n.articleNumberModes.CUSTOMER&&e.customArticleCode),s(),a("ngIf",n.articleNumberMode===n.articleNumberModes.BOTH&&e.customArticleCode),s(2),b(" ",e.productDescription||"-"," "),s(5),b(" ",C(16,15,"costCenterPositionList.table.orderReasonHeader")," "),s(3),I(e.orderReasonName||"-"),s(),a("ngIf",n.showCustomerColumn),s(3),b(" ",C(23,17,"costCenterPositionList.table.amountHeader")," "),s(3),I(e.count),s(3),b(" ",C(29,19,"costCenterPositionList.table.sumHeader")," "),s(3),b(" ",$(32,21,j(27,Ct,e.totalPrice,i.currencyCode,i.localeCode))," ")}}function jt(t,r){if(t&1&&(S(0),p(1,"strong"),m(2),d(3,"cxTranslate"),l(),m(4),d(5,"currency"),P()),t&2){let e=c(2).ngIf,i=c(2);s(2),I(C(3,2,"costCenterPositionList.table.sumHeader")),s(2),b("\xA0 ",$(5,4,j(10,Ct,i.totalPrice,e.currencyCode,e.localeCode))," ")}}function $t(t,r){t&1&&(S(0),m(1," -"),P())}function Qt(t,r){if(t&1&&(p(0,"div",15),g(1,jt,6,14,"ng-container",3)(2,$t,2,0,"ng-container",3),l()),t&2){let e=c(3);s(),a("ngIf",e.areAllArticlesShown),s(),a("ngIf",!e.areAllArticlesShown)}}function Wt(t,r){if(t&1&&(S(0),g(1,Ht,33,31,"div",4)(2,Qt,3,2,"div",5),P()),t&2){let e=c(2);s(),a("ngForOf",e.visiblePositions)("ngForTrackBy",e.trackByPK),s(),a("ngIf",e.showTotalPrice&&e.visiblePositions.length>0)}}function Kt(t,r){if(t&1&&(p(0,"div",2),g(1,Wt,3,3,"ng-container",3),d(2,"async"),d(3,"async"),l()),t&2){let e=c();s(),a("ngIf",H(5,At,C(2,1,e.currency$),C(3,3,e.locale$)))}}function qt(t,r){if(t&1&&(p(0,"div",16)(1,"div",17),m(2),d(3,"cxTranslate"),l()()),t&2){let e=c();s(2),b(" ",q(3,1,e.searchQuery!==""?"costCenterPositionList.table.noSearchResults":"costCenterPositionList.table.noPositions",O(4,Vt,e.searchQuery))," ")}}var ht=(()=>{let r=class r extends ie{constructor(i,n,o){super(i,n,o),this.currencyService=i,this.currencyLocaleService=n,this.cd=o}};r.\u0275fac=function(n){return new(n||r)(y(G),y(ee),y(Y))},r.\u0275cmp=M({type:r,selectors:[["foerch-cost-center-mobile-position-list-table"]],features:[we],decls:3,vars:2,consts:[["noPositions",""],["class","costCenterMobilePositionListTable",4,"ngIf","ngIfElse"],[1,"costCenterMobilePositionListTable"],[4,"ngIf"],["class","costCenterMobilePositionListTable-item",4,"ngFor","ngForOf","ngForTrackBy"],["class","costCenterMobilePositionListTable-sum",4,"ngIf"],[1,"costCenterMobilePositionListTable-item"],[1,"costCenterMobilePositionListTable-date"],[1,"costCenterMobilePositionListTable-code"],["class","costCenterMobilePositionListTable-desc",4,"ngIf"],[1,"costCenterMobilePositionListTable-desc"],[1,"costCenterMobilePositionListTable-table"],[1,"form-check","form-checkbox","costCenterMobilePositionListTable-checkbox"],["name","costCenterPositionItem","type","checkbox","role","checkbox",1,"form-check-input",3,"click","id","checked"],[1,"form-check-label",3,"for"],[1,"costCenterMobilePositionListTable-sum"],[1,"emptyState"],[1,"emptyState-text"]],template:function(n,o){if(n&1&&g(0,Kt,4,8,"div",1)(1,qt,4,6,"ng-template",null,0,F),n&2){let _=k(2);a("ngIf",o.visiblePositions.length>0)("ngIfElse",_)}},dependencies:[J,R,Q,z,w,_e],encapsulation:2,changeDetection:0});let t=r;return t})();var Jt=(t,r)=>({currencyCode:t,localeCode:r}),zt=t=>({"is-indeterminate":t}),Gt=t=>({count:t}),Xt=(t,r,e)=>[t,r,"symbol","1.2",e];function Zt(t,r){if(t&1){let e=E();p(0,"div",8)(1,"div",16)(2,"input",17),f("click",function(){h(e);let n=c(2);return u(n.onChangedSelection())}),l(),L(3,"label",18),l()()}if(t&2){let e=c(2);s(2),B("id","markCostCenterPosition_",e.costCenterPosition.code,""),a("checked",e.mapping[e.costCenterPosition.code].selected)("disabled",e.isDisabled())("ngClass",O(7,zt,e.isPartiallyMarked())),s(),B("for","markCostCenterPosition_",e.costCenterPosition.code,"")}}function ei(t,r){if(t&1&&(p(0,"div",19),m(1),d(2,"cxTranslate"),l()),t&2){let e=c(2);s(),b(" ",q(2,1,"costCenterPositionList.table.articleOrderedLabel",O(4,Gt,e.costCenterPosition==null?null:e.costCenterPosition.countPositions))," ")}}function ti(t,r){if(t&1&&(p(0,"div",20),m(1),d(2,"currency"),l()),t&2){let e=c().ngIf,i=c();s(),b(" ",$(2,1,j(7,Xt,i.costCenterPosition==null?null:i.costCenterPosition.totalPricePositions,e.currencyCode,e.localeCode))," ")}}function ii(t,r){if(t&1&&(S(0),L(1,"cx-icon",21),P()),t&2){let e=c(2);s(),a("type",e.icons.ARROW_UP)}}function ni(t,r){if(t&1&&(S(0),L(1,"cx-icon",21),P()),t&2){let e=c(2);s(),a("type",e.icons.ARROW_DOWN)}}function oi(t,r){if(t&1){let e=E();p(0,"div",5)(1,"div",6),g(2,Zt,4,9,"div",7),p(3,"div",8)(4,"div",9),m(5),l(),g(6,ei,3,6,"div",10),l()(),p(7,"div",11)(8,"div",12),m(9),d(10,"cxTranslate"),g(11,ti,3,11,"div",13),l(),p(12,"button",14),f("click",function(){h(e);let n=c();return u(n.toggleExpansionState())}),g(13,ii,2,1,"ng-container",15)(14,ni,2,1,"ng-container",15),l()()()}if(t&2){let e=c(),i=k(7),n=k(9);s(2),a("ngIf",e.isSelectionEnabled),s(3),b(" ",e.costCenterPosition==null?null:e.costCenterPosition.name," "),s(),a("ngIf",e.areAllArticlesShown)("ngIfElse",i),s(3),b(" ",C(10,9,"costCenterPositionList.table.sumHeader")," "),s(2),a("ngIf",e.areAllArticlesShown)("ngIfElse",n),s(2),a("ngIf",e.mapping[e.costCenterPosition.code].expanded),s(),a("ngIf",!e.mapping[e.costCenterPosition.code].expanded)}}function ri(t,r){if(t&1){let e=E();S(0),p(1,"foerch-cost-center-position-list-table",22),f("selectionChanged",function(n){h(e);let o=c();return u(o.onTableSelectionChanged(n))}),l(),P()}if(t&2){let e=c();s(),a("articleNumberMode",e.articleNumberMode)("costCenterPositionCode",e.costCenterPosition.code)("hidden",!e.mapping[e.costCenterPosition.code].expanded)("isSelectionEnabled",e.isSelectionEnabled)("mapping",e.mapping)("positions",e.costCenterPosition==null?null:e.costCenterPosition.positions)("searchQuery",e.searchQuery)}}function si(t,r){if(t&1){let e=E();p(0,"foerch-cost-center-mobile-position-list-table",23),f("selectionChanged",function(n){h(e);let o=c();return u(o.onTableSelectionChanged(n))}),l()}if(t&2){let e=c();a("articleNumberMode",e.articleNumberMode)("costCenterPositionCode",e.costCenterPosition.code)("hidden",!e.mapping[e.costCenterPosition.code].expanded)("isSelectionEnabled",e.isSelectionEnabled)("mapping",e.mapping)("positions",e.costCenterPosition==null?null:e.costCenterPosition.positions)("searchQuery",e.searchQuery)("sortModel",e.sortModel)}}function ci(t,r){t&1&&(p(0,"div",19),m(1,"-"),l())}function ai(t,r){t&1&&(p(0,"div",20),m(1,"-"),l())}var gt=(()=>{let r=class r{set mapping(i){this._mapping=i,this.updateSummaryVisibility()}get mapping(){return this._mapping}constructor(i,n){this._currencyService=i,this._currencyLocaleService=n,this.isSelectionEnabled=!1,this.isMobileView=!1,this.articleNumberMode=D.FOERCH,this.sortModel={sortBy:W.CODE,sortDirection:ae.ASC},this.expansionStateChanged=new U,this.selectionChanged=new U,this.icons=Z,this.currency$=this._currencyService.getActive(),this.locale$=this._currencyLocaleService.getActiveLocaleForCurrencyPipe(),this.areAllArticlesShown=!0}toggleExpansionState(){this.expansionStateChanged.emit(this.costCenterPosition.code)}onTableSelectionChanged(i){this.selectionChanged.emit(i)}isPartiallyMarked(){let i=this.mapping[this.costCenterPosition.code].positions,n=Object.keys(i).some(o=>i[o].visible&&i[o].selected);return!this.mapping[this.costCenterPosition.code].selected&&n}isDisabled(){return!Object.values(this.mapping[this.costCenterPosition.code].positions).some(i=>i.visible)}onChangedSelection(){this.selectionChanged.emit({costCenterPosition:this.costCenterPosition.code,position:null})}updateSummaryVisibility(){let i=this.mapping[this.costCenterPosition.code].positions;this.areAllArticlesShown=Object.keys(i).length!==0&&!Object.values(i).some(n=>n.visible===!1)}};r.\u0275fac=function(n){return new(n||r)(y(G),y(ee))},r.\u0275cmp=M({type:r,selectors:[["foerch-cost-center-position-list-header"]],inputs:{costCenterPosition:"costCenterPosition",searchQuery:"searchQuery",isSelectionEnabled:"isSelectionEnabled",isMobileView:"isMobileView",articleNumberMode:"articleNumberMode",sortModel:"sortModel",mapping:"mapping"},outputs:{expansionStateChanged:"expansionStateChanged",selectionChanged:"selectionChanged"},decls:10,vars:10,consts:[["mobileTable",""],["notAllArticlesCount",""],["notAllArticles",""],["class","costCenterPositionListHeader",4,"ngIf"],[4,"ngIf","ngIfElse"],[1,"costCenterPositionListHeader"],[1,"row","flex-nowrap"],["class","col-auto",4,"ngIf"],[1,"col-auto"],[1,"costCenterPositionListHeader-name"],["class","costCenterPositionListHeader-count",4,"ngIf","ngIfElse"],[1,"costCenterPositionListHeader-action"],[1,"costCenterPositionListHeader-sum"],["class","costCenterPositionListHeader-sum-price",4,"ngIf","ngIfElse"],["type","button",1,"btn","costCenterPositionListHeader-toggle",3,"click"],[4,"ngIf"],[1,"form-check","form-checkbox","costCenterPositionListHeader-checkbox"],["name","costCenterPosition","type","checkbox","role","checkbox",1,"form-check-input",3,"click","id","checked","disabled","ngClass"],[1,"form-check-label",3,"for"],[1,"costCenterPositionListHeader-count"],[1,"costCenterPositionListHeader-sum-price"],[3,"type"],[3,"selectionChanged","articleNumberMode","costCenterPositionCode","hidden","isSelectionEnabled","mapping","positions","searchQuery"],[3,"selectionChanged","articleNumberMode","costCenterPositionCode","hidden","isSelectionEnabled","mapping","positions","searchQuery","sortModel"]],template:function(n,o){if(n&1&&(g(0,oi,15,11,"div",3),d(1,"async"),d(2,"async"),g(3,ri,2,7,"ng-container",4)(4,si,1,8,"ng-template",null,0,F)(6,ci,2,0,"ng-template",null,1,F)(8,ai,2,0,"ng-template",null,2,F)),n&2){let _=k(5);a("ngIf",H(7,Jt,C(1,3,o.currency$),C(2,5,o.locale$))),s(3),a("ngIf",!o.isMobileView)("ngIfElse",_)}},dependencies:[de,R,X,ie,ht,Q,z,w],encapsulation:2,changeDetection:0});let t=r;return t})();var mi=function(t,r,e,i){var n=arguments.length,o=n<3?r:i===null?i=Object.getOwnPropertyDescriptor(r,e):i,_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(t,r,e,i);else for(var v=t.length-1;v>=0;v--)(_=t[v])&&(o=(n<3?_(o):n>3?_(r,e,o):_(r,e))||o);return n>3&&o&&Object.defineProperty(r,e,o),o},_i=function(t,r){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,r)},Ci=(t,r)=>({costCenters:t,purchaseReasons:r}),hi=t=>({active:t});function ui(t,r){if(t&1){let e=E();S(0),p(1,"div",3)(2,"div",4)(3,"div",5)(4,"div",6)(5,"input",7),f("click",function(){h(e);let n=c(2);return u(n.toggleAll())}),l(),p(6,"label",8),m(7),d(8,"cxTranslate"),l()()(),p(9,"div",9)(10,"button",10),f("click",function(){h(e);let n=c(2);return u(n.isCollapsedBatchProcessing=!n.isCollapsedBatchProcessing)}),m(11),d(12,"cxTranslate"),L(13,"cx-icon",11),l()()(),p(14,"div",12)(15,"div",13)(16,"ng-select",14),d(17,"cxTranslate"),f("change",function(n){h(e);let o=c(2);return u(o.costCenterChanged(n))}),l()(),p(18,"div",13)(19,"ng-select",15),d(20,"cxTranslate"),se("ngModelChange",function(n){h(e);let o=c(2);return re(o.selectedPurchaseReasonValue,n)||(o.selectedPurchaseReasonValue=n),u(n)}),f("change",function(n){h(e);let o=c(2);return u(o.purchaseReasonChanged(n))}),l()(),p(21,"button",16),f("click",function(){h(e);let n=c(2);return u(n.rebook())}),m(22),d(23,"cxTranslate"),l()()(),P()}if(t&2){let e=c().ngIf,i=c();s(5),a("checked",i.areAllSelected)("disabled",!i.isSelectionPossible),s(2),I(C(8,17,"cartDialog.markAll")),s(3),a("ngClass",O(27,hi,!i.isCollapsedBatchProcessing)),s(),b(" ",C(12,19,"common.batchProcessing")," "),s(2),a("type",i.iconTypes.ARROW_DOWN),s(),a("ngbCollapse",i.isCollapsedBatchProcessing),s(2),a("clearable",!1)("items",e.costCenters)("placeholder",C(17,21,"cartDetails.selectCostCenterPlaceHolder")),s(3),a("clearable",!1)("disabled",!i.selectedCostCenter||(e.purchaseReasons==null?null:e.purchaseReasons.length)===0)("items",e.purchaseReasons)("placeholder",C(20,23,"cartDetails.selectPurchaseReasonPlaceHolder")),oe("ngModel",i.selectedPurchaseReasonValue),s(2),a("disabled",!i.canApply()),s(),b(" ",C(23,25,"common.apply")," ")}}function gi(t,r){if(t&1){let e=E();p(0,"div",17)(1,"div",18)(2,"div",6)(3,"input",19),f("click",function(){h(e);let n=c(2);return u(n.toggleAll())}),l(),p(4,"label",20),m(5),d(6,"cxTranslate"),l()()(),p(7,"div",21)(8,"ng-select",22),d(9,"cxTranslate"),f("change",function(n){h(e);let o=c(2);return u(o.costCenterChanged(n))}),l()(),p(10,"div",23)(11,"ng-select",24),d(12,"cxTranslate"),se("ngModelChange",function(n){h(e);let o=c(2);return re(o.selectedPurchaseReasonValue,n)||(o.selectedPurchaseReasonValue=n),u(n)}),f("change",function(n){h(e);let o=c(2);return u(o.purchaseReasonChanged(n))}),l()(),p(13,"div",25)(14,"button",26),f("click",function(){h(e);let n=c(2);return u(n.rebook())}),m(15),d(16,"cxTranslate"),l()()()}if(t&2){let e=c().ngIf,i=c();s(3),a("checked",i.areAllSelected)("disabled",!i.isSelectionPossible),s(2),I(C(6,13,"cartDialog.markAll")),s(3),a("clearable",!1)("items",e.costCenters)("placeholder",C(9,15,"cartDetails.selectCostCenterPlaceHolder")),s(3),a("clearable",!1)("disabled",!i.selectedCostCenter||(e.purchaseReasons==null?null:e.purchaseReasons.length)===0)("items",e.purchaseReasons)("placeholder",C(12,17,"cartDetails.selectPurchaseReasonPlaceHolder")),oe("ngModel",i.selectedPurchaseReasonValue),s(3),a("disabled",!i.canApply()),s(),b(" ",C(16,19,"common.apply")," ")}}function fi(t,r){if(t&1&&(S(0),g(1,ui,24,29,"ng-container",2)(2,gi,17,21,"ng-template",null,0,F),P()),t&2){let e=k(3),i=c();s(),a("ngIf",i.isMobile)("ngIfElse",e)}}var K,xe=(K=class{set allSelected(r){this.areAllSelected=r}constructor(r,e){this._foerchCostCenterPositionsService=r,this._activeCartService=e,this.selectedPositions=[],this.isMobile=!1,this.bulkSelectionChanged=new U,this.rebookSuccess=new U,this.costCenters$=this._activeCartService.getAllCostCentersAndOrderReasons(),this.iconTypes=Z,this.areAllSelected=!1,this.isCollapsedBatchProcessing=!0,this.selectedCostCenter=null,this.selectedPurchaseReason=null,this.selectedPurchaseReasonValue=null}ngOnDestroy(){}toggleAll(){this.bulkSelectionChanged.emit(!this.areAllSelected)}costCenterChanged(r){this.selectedPurchaseReason=null,this.selectedPurchaseReasonValue=null,this.selectedCostCenter=null,this.purchaseReasons$=ke([]);let e=r;e&&e.code&&(this.selectedCostCenter=e,this.purchaseReasons$=this._activeCartService.getOrderReasonsByCostCenter({id:e.code}),this.selectedPurchaseReasonValue=e.orderReasons&&e.orderReasons.length>0?e.orderReasons[0].code:null)}purchaseReasonChanged(r){let e=r;e&&e.code?this.selectedPurchaseReason=e:this.selectedPurchaseReason=null}canApply(){return this.selectedCostCenter!==null&&this.selectedPurchaseReasonValue!==null&&this.selectedPositions.length>0}rebook(){this._foerchCostCenterPositionsService.rebook(this.topCostCenterCode,this.selectedCostCenter.code,this.selectedPurchaseReasonValue,this.selectedPositions,this.costCenterCodes,this.interval)}},K.\u0275fac=function(e){return new(e||K)(y(te),y(ge))},K.\u0275cmp=M({type:K,selectors:[["foerch-bulk-rebooking"]],inputs:{allSelected:"allSelected",selectedPositions:"selectedPositions",isMobile:"isMobile",interval:"interval",costCenterCodes:"costCenterCodes",topCostCenterCode:"topCostCenterCode",isSelectionPossible:"isSelectionPossible"},outputs:{bulkSelectionChanged:"bulkSelectionChanged",rebookSuccess:"rebookSuccess"},decls:3,vars:8,consts:[["desktopVersion",""],[4,"ngIf"],[4,"ngIf","ngIfElse"],[1,"bulkEditMobile"],[1,"row"],[1,"col"],[1,"form-check","form-checkbox"],["id","markAllMobile","name","markAll","type","checkbox","role","checkbox",1,"form-check-input",3,"click","checked","disabled"],["for","markAllMobile",1,"form-check-label"],[1,"col","text-end"],["type","button",1,"btn","bulkEditMobile-toggle",3,"click","ngClass"],[3,"type"],[3,"ngbCollapse"],[1,"form-group","mt-2"],["bindLabel","name","bindValue","code","labelForId","costCenters",3,"change","clearable","items","placeholder"],["bindLabel","name","bindValue","code","labelForId","purchaseReasons",3,"ngModelChange","change","clearable","disabled","items","placeholder","ngModel"],["type","button",1,"btn","btn-secondary","btn-block",3,"click","disabled"],[1,"row","align-items-center"],[1,"col-auto"],["id","markAll","name","markAll","type","checkbox",1,"form-check-input",3,"click","checked","disabled"],["for","markAll",1,"form-check-label"],[1,"col-auto","pe-2"],["bindLabel","name","bindValue","code","labelForId","costCenters",1,"bulkEdit-select",3,"change","clearable","items","placeholder"],[1,"col-auto","pe-2","ps-0"],["bindLabel","name","bindValue","code","labelForId","purchaseReasons",1,"bulkEdit-select",3,"ngModelChange","change","clearable","disabled","items","placeholder","ngModel"],[1,"col-auto","ps-0"],["type","button",1,"btn","btn-secondary",3,"click","disabled"]],template:function(e,i){e&1&&(g(0,fi,4,2,"ng-container",1),d(1,"async"),d(2,"async")),e&2&&a("ngIf",H(5,Ci,C(1,1,i.costCenters$),C(2,3,i.purchaseReasons$)))},dependencies:[de,R,X,et,ue,Ce,he,Q,w],encapsulation:2,changeDetection:0}),K);xe=mi([Xe(),_i("design:paramtypes",[te,ge])],xe);var xi=()=>["/","my-account","cost-center-management"];function vi(t,r){t&1&&Pe(0)}function Si(t,r){if(t&1&&(S(0),g(1,vi,1,0,"ng-container",15),P()),t&2){c(2);let e=k(4);s(),a("ngTemplateOutlet",e)}}function Pi(t,r){if(t&1){let e=E();S(0),p(1,"foerch-cost-center-position-list-table",16),f("selectionChanged",function(n){h(e);let o=c(2);return u(o.onSelectionChanged(n))}),l(),P()}if(t&2){let e=c(2);s(),a("articleNumberMode",e.articleNumberMode)("b2bUnit",e.user==null||e.user.unit==null?null:e.user.unit.uid)("costCenterPositionCode",e.costCenterPositions[0]==null?null:e.costCenterPositions[0].code)("isSelectionEnabled",e.selectedFilter===e.positionListFilters.TKM)("mapping",e.mapping)("positions",e.costCenterPositions[0]==null?null:e.costCenterPositions[0].positions)("searchQuery",e.searchQuery)("totalPrice",e.costCenterPositions[0]==null?null:e.costCenterPositions[0].totalPricePositions)}}function yi(t,r){if(t&1){let e=E();p(0,"foerch-cost-center-position-list-header",18),f("expansionStateChanged",function(n){h(e);let o=c(3);return u(o.onExpansionStateChanged(n))})("selectionChanged",function(n){h(e);let o=c(3);return u(o.onSelectionChanged(n))}),l()}if(t&2){let e=r.$implicit,i=c(3);a("costCenterPosition",e)("isSelectionEnabled",i.selectedFilter===i.positionListFilters.TKM)("mapping",i.mapping)("searchQuery",i.searchQuery)}}function Ti(t,r){if(t&1&&(S(0),g(1,yi,1,4,"foerch-cost-center-position-list-header",17),P()),t&2){let e=c(2);s(),a("ngForOf",e.costCenterPositions)("ngForTrackBy",e.trackByPosition)}}function Ei(t,r){if(t&1){let e=E();p(0,"foerch-bulk-rebooking",19),f("bulkSelectionChanged",function(n){h(e);let o=c(2);return u(o.onBulkSelectionChanged(n))})("rebookSuccess",function(){h(e);let n=c(2);return u(n.onRebookSuccess())}),l()}if(t&2){let e=c(2);a("allSelected",e.allSelected)("costCenterCodes",e.costCenterCodes)("interval",e.interval)("isSelectionPossible",e.hasSelectablePositions)("selectedPositions",e.selectedPositions)("topCostCenterCode",e.topCostCenterCode)}}function Ii(t,r){t&1&&Pe(0)}function ki(t,r){if(t&1&&(S(0),g(1,Ii,1,0,"ng-container",15),P()),t&2){c(2);let e=k(4);s(),a("ngTemplateOutlet",e)}}function Li(t,r){if(t&1){let e=E();S(0),p(1,"div",3)(2,"div",4)(3,"button",5),L(4,"cx-icon",6),m(5),d(6,"cxTranslate"),l(),p(7,"div",7),m(8),l()(),p(9,"div",8)(10,"foerch-search-input",9),f("searchString",function(n){h(e);let o=c();return u(o.onSearchQueryChanged(n))}),l()()(),p(11,"div",10),L(12,"cx-icon",6),m(13),d(14,"cxTranslate"),l(),g(15,Si,2,1,"ng-container",11),p(16,"div",3)(17,"div",8)(18,"ng-select",12),d(19,"cxTranslate"),se("ngModelChange",function(n){h(e);let o=c();return re(o.selectedFilter,n)||(o.selectedFilter=n),u(n)}),l()(),p(20,"div",4)(21,"foerch-date-range",13),f("dateRangeChanged",function(n){h(e);let o=c();return u(o.onDateRangeChanged(n))}),l()()(),g(22,Pi,2,8,"ng-container",11)(23,Ti,2,2,"ng-container",11)(24,Ei,1,6,"foerch-bulk-rebooking",14)(25,ki,2,1,"ng-container",11),P()}if(t&2){let e=c();s(3),a("routerLink",Ve(24,xi)),s(),a("type",e.icons.ARROW_LEFT),s(),b(" ",C(6,18,"common.back")," "),s(3),b(" ",e.topCostCenter==null?null:e.topCostCenter.name," "),s(2),a("placeholder","costCenterPositionList.searchArticlePlaceholder"),s(2),a("type",e.icons.INFO),s(),b(" ",C(14,20,"costCenterPositionList.rebookingNote")," "),s(2),a("ngIf",!e.isCostCenterWithoutSubs),s(3),Ae("placeholder",C(19,22,"costCenterPositionList.filter.filter")),a("clearable",!1)("items",e.filterOptions),oe("ngModel",e.selectedFilter),s(3),a("dateRange",e.interval)("maxDate",e.maxDate),s(),a("ngIf",e.isCostCenterWithoutSubs),s(),a("ngIf",!e.isCostCenterWithoutSubs),s(),a("ngIf",e.selectedFilter===e.positionListFilters.TKM),s(),a("ngIf",!e.isCostCenterWithoutSubs)}}function Fi(t,r){t&1&&(m(0),d(1,"cxTranslate")),t&2&&b(" ",C(1,1,"costCenterPositionList.invalidURL"),` `)}function Mi(t,r){if(t&1){let e=E();p(0,"div",20)(1,"button",21),f("click",function(){h(e);let n=c();return u(n.toggleAll())}),m(2),d(3,"cxTranslate"),l()()}if(t&2){let e=c();s(2),b(" ",C(3,1,e.allExpanded?"common.closeAll":"common.openAll")," ")}}var ve=function(t){return t[t.TKM=0]="TKM",t[t.VMM=1]="VMM",t[t.ALL=2]="ALL",t}(ve||{}),Yn=(()=>{let r=class r{constructor(i,n,o,_,v,x,T,N,A){this.activatedRoute=i,this.userAccountService=n,this.costCenterService=o,this.costCentersManagementService=_,this.costCenterPositionsService=v,this.translationService=x,this.permissionsService=T,this.loggingService=N,this.cd=A,this.icons=Z,this.isInvalidUrl=!1,this.interval=null,this.costCenterPositions=[],this.maxDate=new Date,this.isCostCenterWithoutSubs=!0,this.searchQuery="",this.allExpanded=!1,this.allSelected=!1,this.filterOptions=[],this.selectedFilter=ve.TKM,this.positionListFilters=ve,this.mapping={},this.selectedPositions=[],this.hasSelectablePositions=!0,this.articleNumberMode=D.FOERCH,this._DELIMITER="#|<>|#",this._subs$=new Ie}ngOnInit(){this.extractDataFromUrl(),this.isInvalidUrl||(this.prepareFilter(),this.isLoading$=this.costCenterPositionsService.isLoading(),this._subs$.add(this.permissionsService.getPermissionValue(Qe.ACTIVATE_WEBSHOP_ARTICLE_NUMBER).subscribe(i=>{i&&(this.articleNumberMode=i,this.cd.detectChanges())})),this._subs$.add(this.userAccountService.get().subscribe(i=>this.user=i)),this._subs$.add(this.costCenterService.get().subscribe(i=>{this.topCostCenter=i})),this._subs$.add(this.costCenterPositionsService.get().subscribe(i=>{this.costCenterPositions=We(i.entities,"name");let n={};this.costCenterPositions.forEach(o=>{n[o.code]={selected:!1,expanded:this.mapping[o.code]&&!!this.mapping[o.code].expanded,positions:{}},o.positions.forEach(_=>{n[o.code].positions[_.orderEntryPK]={selected:!1,visible:!0}})}),this.mapping=n,this.isCostCenterWithoutSubs=this.costCenterPositions.length===1&&this.costCenterPositions[0].code===this.topCostCenterCode,this.searchQuery!==""&&this.onSearchQueryChanged(this.searchQuery),this.updateBulkSelectionStatus()})),this.costCenterService.load(this.topCostCenterCode),this.costCenterPositionsService.load(this.costCenterCodes,this.interval))}ngOnDestroy(){this._subs$.unsubscribe()}trackByPosition(i,n){return n.code}onDateRangeChanged(i){this.interval=i,this.costCentersManagementService.setInterval(i),this.costCenterPositionsService.load(this.costCenterCodes,this.interval)}onSearchQueryChanged(i){this.searchQuery=i;let n=V({},this.mapping);this.costCenterPositions.forEach(o=>{o.positions.forEach(x=>{let T=[x.productCode.replace(/\s/g,"")];switch(this.articleNumberMode){case D.FOERCH:{T.push(x.supplierAlternativeAID||null);break}case D.CUSTOMER:{T.push(x.customArticleCode||null);break}default:T.push(x.supplierAlternativeAID||null,x.customArticleCode||null)}let N=T.filter(A=>A!==null).join(this._DELIMITER);n[o.code].positions[x.orderEntryPK].visible=this.searchQuery===""?!0:`${N}${this._DELIMITER}${(x.productDescription||"").toLowerCase()}${this._DELIMITER}${(x.orderReasonName||"").toLowerCase()}${this._DELIMITER}${x.b2BUnit}`.indexOf(this.searchQuery)!==-1});let _=!1,v=Object.keys(n[o.code].positions).some(x=>{let T=n[o.code].positions[x];return T.visible&&(_=!0),T.visible&&!T.selected});n[o.code].selected=_&&!v}),this.mapping=n,this.updateBulkSelectionStatus(),this.updateSelectedPositions(),this.allExpanded||this.toggleAll()}onSelectionChanged(i){let{costCenterPosition:n,position:o}=i,_=V({},this.mapping[n].positions);if(o){_[o].selected=!_[o].selected;let v=Object.values(_).some(x=>x.visible&&!x.selected);this.mapping=ne(V({},this.mapping),{[n]:{positions:_,expanded:this.mapping[n].expanded,selected:!v}})}else{let v=!this.mapping[n].selected;Object.keys(_).forEach(x=>{_[x].visible&&(_[x].selected=v)}),this.mapping=ne(V({},this.mapping),{[n]:{positions:_,expanded:this.mapping[n].expanded,selected:v}})}this.updateBulkSelectionStatus(),this.updateSelectedPositions()}onExpansionStateChanged(i){this.mapping=ne(V({},this.mapping),{[i]:ne(V({},this.mapping[i]),{expanded:!this.mapping[i].expanded})}),this.mapping[i].expanded?this.allExpanded=Object.values(this.mapping).filter(n=>n.expanded===!1).length===0:this.allExpanded=!1}toggleAll(){this.allExpanded=!this.allExpanded;let i=V({},this.mapping);Object.values(i).forEach(n=>{n.expanded=this.allExpanded}),this.mapping=i}onBulkSelectionChanged(i){this.allSelected=i;let n=V({},this.mapping);Object.keys(n).forEach(o=>{let _=!1;Object.values(n[o].positions).forEach(v=>{v.visible&&(_=!0,v.selected=i)}),n[o].selected=_?i:!1}),this.mapping=n,this.updateSelectedPositions(),this.cd.detectChanges()}onRebookSuccess(){this.costCenterPositionsService.load(this.costCenterCodes,this.interval)}updateBulkSelectionStatus(){let i=!1;for(let n of Object.keys(this.mapping))if(Object.values(this.mapping[n].positions).some(o=>o.visible)){i=!0;break}this.hasSelectablePositions=i,this.allSelected=i&&!Object.values(this.mapping).some(n=>Object.values(n.positions).some(o=>o.visible===!0&&o.selected===!1)),this.cd.detectChanges()}updateSelectedPositions(){let i=[];Object.values(this.mapping).forEach(n=>{Object.keys(n.positions).forEach(o=>{let _=n.positions[o];_.visible&&_.selected&&i.push(o)})}),this.selectedPositions=i}extractDataFromUrl(){let i=this.activatedRoute.snapshot.paramMap.get("uid"),n=this.activatedRoute.snapshot.queryParamMap,o=null,_=null,v=null,x;if(n.has("intervalStart")&&(x=Ee(n.get("intervalStart")),ye(x)&&(o=x)),n.has("intervalEnd")&&(x=Ee(n.get("intervalEnd")),ye(x)&&(_=x)),n.has("costCenters"))try{let T=JSON.parse(n.get("costCenters"));if(Array.isArray(T)){let N=!0;for(let A=0;A<T.length;A++)if(typeof T[A]!="string"){N=!1;break}N&&(v=T)}}catch(T){this.loggingService.handleError(T)}this.isInvalidUrl=!i||!o||!_||!v||Ye(o,_)||Je(o,_)||ze(_),this.isInvalidUrl||(this.topCostCenterCode=i,this.interval={start:o,end:_},this.costCenterCodes=v,this.costCentersManagementService.setInterval(this.interval))}prepareFilter(){Le([this.translationService.translate("costCenterPositionList.filter.tkm"),this.translationService.translate("costCenterPositionList.filter.vmm"),this.translationService.translate("costCenterPositionList.filter.allSections")]).subscribe(([i,n,o])=>{this.filterOptions=[{value:ve.TKM,label:i}]})}};r.\u0275fac=function(n){return new(n||r)(y(Oe),y($e),y(st),y(rt),y(te),y(je),y(Ze),y(ct),y(Y))},r.\u0275cmp=M({type:r,selectors:[["foerch-cost-center-position-list"]],decls:5,vars:2,consts:[["invalidURL",""],["expandCollapse",""],[4,"ngIf","ngIfElse"],[1,"row"],[1,"col-8"],["type","button",1,"btn","btn-tertiary","btn-back",3,"routerLink"],[3,"type"],[1,"h3","mb-3"],[1,"col-4"],[3,"searchString","placeholder"],[1,"costCenterPositionList-info"],[4,"ngIf"],["bindLabel","label","bindValue","value",3,"ngModelChange","placeholder","clearable","items","ngModel"],[3,"dateRangeChanged","dateRange","maxDate"],[3,"allSelected","costCenterCodes","interval","isSelectionPossible","selectedPositions","topCostCenterCode","bulkSelectionChanged","rebookSuccess",4,"ngIf"],[4,"ngTemplateOutlet"],[3,"selectionChanged","articleNumberMode","b2bUnit","costCenterPositionCode","isSelectionEnabled","mapping","positions","searchQuery","totalPrice"],[3,"costCenterPosition","isSelectionEnabled","mapping","searchQuery","expansionStateChanged","selectionChanged",4,"ngFor","ngForOf","ngForTrackBy"],[3,"expansionStateChanged","selectionChanged","costCenterPosition","isSelectionEnabled","mapping","searchQuery"],[3,"bulkSelectionChanged","rebookSuccess","allSelected","costCenterCodes","interval","isSelectionPossible","selectedPositions","topCostCenterCode"],[1,"text-end","mb-1"],["type","button",1,"btn","btn-link_secondary","pt-0",3,"click"]],template:function(n,o){if(n&1&&g(0,Li,26,25,"ng-container",2)(1,Fi,2,3,"ng-template",null,0,F)(3,Mi,4,3,"ng-template",null,1,F),n&2){let _=k(2);a("ngIf",!o.isInvalidUrl)("ngIfElse",_)}},dependencies:[J,R,Be,X,De,ue,Ce,he,it,tt,ie,gt,xe,w],encapsulation:2,changeDetection:0});let t=r;return t})();export{te as a,xe as b,W as c,ht as d,gt as e,ve as f,Yn as g};