import{a as we}from"./chunk-HBUIWZRH.js";import{a as W}from"./chunk-64JTGTPA.js";import{b as Be}from"./chunk-5RG27LZ2.js";import{c as U}from"./chunk-72JDPJS6.js";import{b as H}from"./chunk-5OZTUYJC.js";import{J as j}from"./chunk-CWWVHRJU.js";import{a as Oe}from"./chunk-7JA7UHZ2.js";import{c as Ee}from"./chunk-QMZQK3O6.js";import{a as Ae}from"./chunk-6IGMG2LM.js";import{a as N}from"./chunk-RU43IR5J.js";import{d as k}from"./chunk-ZSVIZXE3.js";import{a as D}from"./chunk-Y7IP5WLG.js";import{b as Pe}from"./chunk-ISDPQX42.js";import{I as Fe}from"./chunk-SLGBXDUF.js";import{a as Te}from"./chunk-LY6HB4BL.js";import{a as L}from"./chunk-SU6CJJJO.js";import{r as P}from"./chunk-L7CU4UNF.js";import{a as M}from"./chunk-HBJ2IG4O.js";import{K as ye,m as Ie}from"./chunk-FBI7JGZC.js";import{r as Se}from"./chunk-MXUIPT66.js";import{I as be,c as ge,f as fe,l as Ce}from"./chunk-DX7LHTFF.js";import{$b as re,Aa as x,Ab as a,Ba as g,Bb as C,Cb as O,Db as T,Dc as B,E as Z,Eb as ne,Fb as I,Gd as w,Kb as f,Lb as h,N as $,Og as V,Ua as n,Va as v,Wc as pe,Xb as F,Xc as me,Yb as p,_b as m,ad as ue,bd as he,cc as oe,dc as ae,ec as ce,fh as ve,ga as ee,gb as ie,gd as _e,ib as _,jc as E,kc as se,lc as le,o as J,ob as u,rc as s,rg as R,s as X,sc as d,t as Y,ta as te,tc as q,vc as de,wc as A,yh as xe,zb as o}from"./chunk-N6B2OJOY.js";var De=function(i,t,e,c){var l=arguments.length,r=l<3?t:c===null?c=Object.getOwnPropertyDescriptor(t,e):c,S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,c);else for(var y=i.length-1;y>=0;y--)(S=i[y])&&(r=(l<3?S(r):l>3?S(t,e,r):S(t,e))||r);return l>3&&r&&Object.defineProperty(t,e,r),r},Me=function(i,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,t)},Re=i=>({max:i}),je=i=>({items:i}),He=(i,t)=>({currencyCode:i,localeCode:t}),Ue=(i,t,e)=>[i,t,"symbol","1.2",e];function We(i,t){i&1&&(p(0),s(1,"cxTranslate")),i&2&&m(" ",d(1,1,"approval.info")," ")}function $e(i,t){if(i&1){let e=I();o(0,"button",15),f("click",function(){x(e);let l=h();return g(l.approveOrder(!1))}),C(1,"cx-icon",8),p(2),s(3,"cxTranslate"),a()}if(i&2){let e=h();u("disabled",e.isLoading),n(),u("type",e.icons.CLOSE),n(),m(" ",d(3,3,"approval.rejectOrder")," ")}}function qe(i,t){if(i&1){let e=I();o(0,"button",16),f("click",function(){x(e);let l=h();return g(l.approveOrder(!0))}),C(1,"cx-icon",8),p(2),s(3,"cxTranslate"),a()}if(i&2){let e=h();u("disabled",e.shouldDisableApproveButton),n(),u("type",e.icons.SUCCESS),n(),m(" ",d(3,3,"approval.approveOrder")," ")}}function Ge(i,t){if(i&1&&C(0,"foerch-checkout-info",42),i&2){let e=h(2);u("checkoutInfo",e.order.checkoutInfo)}}function Ke(i,t){i&1&&ne(0)}function Qe(i,t){i&1&&(o(0,"div",43)(1,"div",23),p(2),s(3,"cxTranslate"),a(),o(4,"div",26),p(5),s(6,"cxTranslate"),a()()),i&2&&(n(2),m(" ",d(3,2,"common.info")," "),n(3),m(" ",d(6,4,"approval.deliveryAddressInfo")," "))}function ze(i,t){if(i&1&&(o(0,"div",43)(1,"div",23),p(2),s(3,"cxTranslate"),C(4,"br"),a(),o(5,"div",26),C(6,"foerch-address",44),a()()),i&2){let e=h(2);n(2),m(" ",d(3,3,"orderDetails.shippedOn"),""),n(4),u("address",e.order.deliveryAddress)("showAddressName",!1)}}function Je(i,t){if(i&1){let e=I();o(0,"div",32)(1,"ng-select",51),s(2,"cxTranslate"),ce("ngModelChange",function(l){x(e);let r=h(4);return ae(r.selectedPurchaseReasonValue,l)||(r.selectedPurchaseReasonValue=l),g(l)}),f("change",function(l){x(e);let r=h(4);return g(r.purchaseReasonChanged(l))}),a()()}if(i&2){let e=t.ngIf,c=h(4);n(),u("clearable",!1)("disabled",!e.items||(e.items==null?null:e.items.length)===0)("items",e.items)("placeholder",d(2,5,"cartDetails.selectPurchaseReasonPlaceHolder")),oe("ngModel",c.selectedPurchaseReasonValue)}}function Xe(i,t){if(i&1){let e=I();o(0,"div",46)(1,"div",38)(2,"div",39),p(3),s(4,"cxTranslate"),a(),o(5,"div",40)(6,"div",32)(7,"ng-select",47),s(8,"cxTranslate"),f("change",function(l){x(e);let r=h(3);return g(r.costCenterChanged(l))}),a()(),_(9,Je,3,7,"div",48),s(10,"async"),o(11,"button",49),f("click",function(){x(e);let l=h(3);return g(l.applyCostCenterToOrder(!0))}),p(12),s(13,"cxTranslate"),a(),o(14,"button",50),f("click",function(){x(e);let l=h(3);return g(l.applyCostCenterToOrder(!1))}),p(15),s(16,"cxTranslate"),a()()()()}if(i&2){let e=h().ngIf,c=h(2);n(3),m(" ",d(4,9,"cartDetails.editCostCenter")," "),n(4),u("clearable",!1)("items",e)("placeholder",d(8,11,"cartDetails.selectCostCenterPlaceHolder")),n(2),u("ngIf",E(19,je,d(10,13,c.purchaseReasons$))),n(2),u("disabled",!c.selectedCostCenter),n(),m(" ",d(13,15,"cartHeader.applyCostCenter")," "),n(2),u("disabled",!c.selectedCostCenter),n(),m(" ",d(16,17,"cartHeader.applyForSelected")," ")}}function Ye(i,t){if(i&1&&(O(0),_(1,Xe,17,21,"div",45),T()),i&2){let e=t.ngIf,c=h(2);n(),u("ngIf",c.cartConfig.showCCM&&e.length)}}function Ze(i,t){if(i&1){let e=I();O(0),o(1,"button",52),f("click",function(){x(e);let l=h(2);return g(l.openWatchlistDialogToAddInOrder())}),C(2,"cx-icon",8),p(3),s(4,"cxTranslate"),a(),T()}if(i&2){let e=h(2);n(2),u("type",e.icons.WATCHLIST),n(),m(" ",d(4,2,"cartHeader.searchWatchlist")," ")}}function et(i,t){if(i&1&&(o(0,"div",43)(1,"div",23),p(2),s(3,"cxTranslate"),a(),o(4,"div",26),p(5),a()()),i&2){let e=h(3);n(2),m(" ",d(3,2,"orderDetails.value")," "),n(3),m(" ",e.order.subTotal.formattedValue||"-"," ")}}function tt(i,t){if(i&1&&(o(0,"div",43)(1,"div",23),p(2),a(),o(3,"div",26),p(4),s(5,"currency"),a()()),i&2){let e=t.$implicit,c=h().ngIf;n(2),m(" ",e.type.name," "),n(2),m(" ",(e.value==null?null:e.value.formattedValue)||de(5,2,le(8,Ue,e.value==null?null:e.value.value,c.currencyCode,c.localeCode))," ")}}function it(i,t){if(i&1&&(O(0),_(1,tt,6,12,"div",54),T()),i&2){let e=h(4);n(),u("ngForOf",e.order.fees)("ngForTrackBy",e.trackByIndex)}}function nt(i,t){if(i&1&&(O(0),_(1,it,2,2,"ng-container",14),s(2,"async"),s(3,"async"),T()),i&2){let e=h(3);n(),u("ngIf",se(5,He,d(2,1,e.currencyCode$),d(3,3,e.localeCode$)))}}function rt(i,t){if(i&1&&(o(0,"div",22)(1,"div",10),_(2,et,6,4,"div",53)(3,nt,4,8,"ng-container",14),o(4,"div",43)(5,"div",23),p(6),s(7,"cxTranslate"),a(),o(8,"div",26),p(9),a()()()()),i&2){let e=h(2);n(2),u("ngIf",e.order.subTotal),n(),u("ngIf",e.order.fees&&e.order.fees.length>0),n(3),m(" ",d(7,4,"orderDetails.totalValue")," "),n(3),m(" ",(e.order.totalPrice==null?null:e.order.totalPrice.formattedValue)||"-"," ")}}function ot(i,t){if(i&1&&(o(0,"div",22)(1,"div",23),p(2),s(3,"cxTranslate"),a(),o(4,"div",26),p(5),a()()),i&2){let e=h(2);n(2),m(" ",d(3,2,"orderDetails.value")," "),n(3),m(" ",(e.order.totalPrice==null?null:e.order.totalPrice.formattedValue)||"-"," ")}}function at(i,t){if(i&1){let e=I();O(0),_(1,Ge,1,1,"foerch-checkout-info",17),s(2,"foerchCheckoutDisplayHint"),o(3,"div",18),p(4),s(5,"cxTranslate"),a(),o(6,"div",19)(7,"div",20)(8,"div",21)(9,"div",10)(10,"div",22)(11,"div",23),p(12),s(13,"cxTranslate"),a(),o(14,"div",24)(15,"span",25),p(16),a()()(),o(17,"div",22)(18,"div",23),p(19),s(20,"cxTranslate"),a(),o(21,"div",26),p(22),s(23,"cxDate"),a()(),o(24,"div",22)(25,"div",23),p(26),s(27,"cxTranslate"),a(),o(28,"div",26),p(29),a()(),o(30,"div",22)(31,"div",23),p(32),s(33,"cxTranslate"),a(),o(34,"div",26),p(35),a()(),o(36,"div",22)(37,"div",23),p(38),s(39,"cxTranslate"),a(),o(40,"div",26),p(41),a()(),o(42,"div",22)(43,"div",23),p(44),s(45,"cxTranslate"),a(),o(46,"div",26),p(47),s(48,"cxTranslate"),a()()(),o(49,"div",10),_(50,Ke,1,0,"ng-container",27),a(),o(51,"foerch-input",28),s(52,"cxTranslate"),s(53,"cxTranslate"),f("valueChanged",function(l){x(e);let r=h();return g(r.setPurchaseNumber(l))}),a(),o(54,"foerch-input",29),s(55,"cxTranslate"),s(56,"cxTranslate"),f("valueChanged",function(l){x(e);let r=h();return g(r.setComment(l))}),a()(),o(57,"div",21)(58,"div",10),_(59,Qe,7,6,"div",30)(60,ze,7,5,"ng-template",null,1,A),a(),o(62,"div",10)(63,"div",31)(64,"div",32)(65,"div",33)(66,"textarea",34),s(67,"cxTranslate"),f("ngModelChange",function(l){x(e);let r=h();return g(r.setCommentApprover(l))}),a(),o(68,"label",35),p(69),s(70,"cxTranslate"),a()()()()()()()(),o(71,"div",36)(72,"div",20),_(73,Ye,2,1,"ng-container",14),s(74,"async"),o(75,"div",37)(76,"div",38)(77,"div",39),p(78),s(79,"cxTranslate"),a(),o(80,"div",40)(81,"foerch-quick-add-entry",41),f("addToCart",function(l){x(e);let r=h();return g(r.quickAddEntriesToOrder(l))}),a(),_(82,Ze,5,4,"ng-container",14),a()()()()(),_(83,rt,10,6,"ng-template",null,2,A)(85,ot,6,4,"ng-template",null,3,A),T()}if(i&2){let e=F(61),c=F(84),l=F(86),r=h();n(),u("ngIf",d(2,33,r.order.checkoutInfo)),n(3),re(" ",d(5,35,"approval.orderNumber")," ",r.order.code," "),n(8),m(" ",d(13,37,"ordersList.table.status")," "),n(4),m(" ",r.order.statusDisplay||"-"," "),n(3),m(" ",d(20,39,"common.orderedAt")," "),n(3),m(" ",d(23,41,r.order.created)||"-"," "),n(4),m(" ",d(27,43,"ordersList.table.channel")," "),n(3),m(" ",r.order.salesApplication||"-"," "),n(3),m(" ",d(33,45,"ordersList.table.user")," "),n(3),m(" ",(r.order.user==null?null:r.order.user.name)||"-"," "),n(3),m(" ",d(39,47,"ordersList.table.customerId")," "),n(3),m(" ",(r.order.unit==null?null:r.order.unit.displayUid)||(r.order.unit==null?null:r.order.unit.uid)||"-"," "),n(3),m(" ",d(45,49,"ordersList.table.paymentMethod")," "),n(3),m(" ",r.order.paymentInfo||d(48,51,"orderDetails.paymentInvoice")," "),n(3),u("ngTemplateOutlet",(r.order.fees==null?null:r.order.fees.length)>0?c:l),n(),u("dynamicHelpText",r.maxPurchaseOrderNumberLength<r.standardStringLength?q(52,53,"checkoutReview.internalOrderNumberHelpText",E(71,Re,r.maxPurchaseOrderNumberLength)):"")("labelAndPlaceholder",d(53,56,"approval.yourOrderNumber"))("maxLength",r.maxPurchaseOrderNumberLength)("value",r.order.purchaseOrderNumber),n(3),u("dynamicHelpText",r.maxOrderCommentLength<r.standardStringLength?q(55,58,"checkoutReview.orderCommentLengthHelpText",E(73,Re,r.maxOrderCommentLength)):"")("labelAndPlaceholder",d(56,61,"approval.comment"))("maxLength",r.maxOrderCommentLength)("value",r.order.b2BComment==null?null:r.order.b2BComment.comment),n(5),u("ngIf",(r.order.consignments==null?null:r.order.consignments.length)>1)("ngIfElse",e),n(7),u("ngModel",r.approvalNotes)("placeholder",d(67,63,"approval.notes")),n(3),m(" ",d(70,65,"approval.notes")," "),n(4),u("ngIf",d(74,67,r.costCenters$)),n(5),m(" ",d(79,69,"cartHeader.addArticle")," "),n(3),u("cartMode",r.cartMode),n(),u("ngIf",r.watchlistItems.length>0)}}var b,Ve=(b=class extends we{constructor(t,e,c,l,r,S,y,G,K,Q,ke,Le,Ne,z){super(t,c,r,S,e,y,G,K,Q,z),this.activatedRoute=t,this.modalService=e,this.orderService=c,this.watchlistService=l,this.activeCartService=r,this.permissionService=S,this.cd=y,this.unitsService=G,this.currencyService=K,this.currencyLocaleService=Q,this.routingService=ke,this.baseSiteService=Le,this.translationService=Ne,this.checkoutInfoPipe=z,this.watchlistItems=[],this.comment="",this.approvalNotes="",this.selectedCostCenter=null,this.selectedPurchaseReason=null,this.selectedPurchaseReasonValue=null,this.standardStringLength="255",this.maxPurchaseOrderNumberLength=this.standardStringLength,this.maxOrderCommentLength=this.standardStringLength,this.cartMode=Ie.ORDER_TEMPLATE_DETAILS}ngOnInit(){super.ngOnInit(),this.subs$.add(this.baseSiteService.getActiveBaseSite().pipe(X(t=>t?.stores??[])).subscribe(t=>{Array.isArray(t)&&t.length>0&&(this.maxOrderCommentLength=t[0].orderCommentLength,this.maxPurchaseOrderNumberLength=t[0].purchaseOrderNumberLength,this.cd.detectChanges())})),this.subs$.add(this.watchlistService.getEntries().subscribe(t=>{this.watchlistItems=t,this.cd.detectChanges()})),this.costCenters$=this.activeCartService.getAllCostCentersAndOrderReasons()}ngOnDestroy(){super.ngOnDestroy(),this.orderService.reset()}handleResults(t){super.handleResults(t),t.order&&(this.purchaseNumber=this.order.purchaseOrderNumber,this.order.b2BComment&&(this.comment=this.order.b2BComment.comment),this.order.status!==ye.PENDING_APPROVAL&&this.routingService.go({cxRoute:"foerchOrder",params:{code:this.order.code}})),this.isLoading=t.loading,this.isLoaded=t.loaded}setPurchaseNumber(t){this.purchaseNumber=t,this.orderService.updateOrder(this.currentOrderCode,this.purchaseNumber,this.comment)}setComment(t){this.comment=t,this.orderService.updateOrder(this.currentOrderCode,this.purchaseNumber,this.comment)}setCommentApprover(t){this.approvalNotes=t,this.orderService.addCommentApproverToOrderState(t)}costCenterChanged(t){this.selectedPurchaseReason=null,this.selectedPurchaseReasonValue=null,this.selectedCostCenter=null,this.purchaseReasons$=J([]),t&&t.code&&(this.selectedCostCenter=t,this.purchaseReasons$=this.activeCartService.getOrderReasonsByCostCenter({id:t.code}).pipe(ee(e=>{e&&e.length>0&&(this.selectedPurchaseReason=e[0],this.selectedPurchaseReasonValue=e[0].code)})))}purchaseReasonChanged(t){t&&t.code?this.selectedPurchaseReason=t:this.selectedPurchaseReason=null}quickAddEntriesToOrder(t){this.orderService.addEntries({code:this.currentOrderCode,entries:t,targetType:this.targetType})}applyCostCenterToOrder(t){this.orderService.applyCostCenter({code:this.currentOrderCode,costCenter:this.selectedCostCenter?this.selectedCostCenter.code:null,costReason:this.selectedPurchaseReason?this.selectedPurchaseReason.code:null,entries:this.order.entries,targetType:this.targetType,toAll:t})}openWatchlistDialogToAddInOrder(){let t={scrollable:!0},e=this.modalService.open(Be,t);if(e){let c=e.componentInstance;c.isWatchList=!0,c.addToOrder=!0,c.orderCode=this.currentOrderCode,c.watchlistItems=this.watchlistItems}}loadOrder(){super.loadOrder();let t=this.getB2BUnitIdFromRoute();t?this.unitsService.canSwitchB2BUnit(t).pipe($(1)).subscribe(e=>{e?(this.unitsService.switchB2BUnit(t,!1),Y([this.unitsService.isSwitching(),this.unitsService.isSwitched()]).pipe(Z(([c,l])=>!c&&l),$(1)).subscribe(c=>{this.orderService.load(this.currentOrderCode)})):this.orderService.load(this.currentOrderCode)}):this.orderService.load(this.currentOrderCode)}onChangedOrderCode(){super.onChangedOrderCode(),this.approvalNotes=""}getB2BUnitIdFromRoute(){return this.activatedRoute.snapshot.paramMap.get("unitId")}},b.\u0275fac=function(e){return new(e||b)(v(w),v(D),v(U),v(L),v(j),v(N),v(B),v(W),v(R),v(H),v(M),v(k),v(V),v(P))},b.\u0275cmp=te({type:b,selectors:[["foerch-order-approval-process"]],features:[ie],decls:16,vars:8,consts:[["popoverContent",""],["oneDeliveryAddress",""],["withFees",""],["withoutFees",""],[1,"row","align-items-center","mb-md-3"],[1,"col-auto"],[1,"h3"],["container","body","placement","bottom","popoverClass","costCenterManagement-popover","triggers","mouseenter:mouseleave:click","type","button",1,"btn-icon","orderApprovalProcessInfo-btn","ms-2",3,"ngbPopover"],[3,"type"],[1,"col-auto","ms-lg-auto"],[1,"row"],[1,"col-md-auto"],["class","btn btn-danger btn-block btn-icon_left","type","button",3,"disabled","click",4,"ngIf"],["class","btn btn-success btn-block btn-icon_left","type","button",3,"disabled","click",4,"ngIf"],[4,"ngIf"],["type","button",1,"btn","btn-danger","btn-block","btn-icon_left",3,"click","disabled"],["type","button",1,"btn","btn-success","btn-block","btn-icon_left",3,"click","disabled"],["class","mb-2",3,"checkoutInfo",4,"ngIf"],[1,"orderApprovalProcessNr"],[1,"orderApprovalProcess"],[1,"row","g-0"],[1,"col-md-6","px-2"],[1,"col-6"],[1,"orderApprovalProcess-key"],[1,"orderApprovalProcess-value","orderApprovalProcess-value_status","mb-2"],[1,"text-warning"],[1,"orderApprovalProcess-value","mb-2"],[4,"ngTemplateOutlet"],["inputId","customOrderNumber",3,"valueChanged","dynamicHelpText","labelAndPlaceholder","maxLength","value"],["inputId","commentOrderer",3,"valueChanged","dynamicHelpText","labelAndPlaceholder","maxLength","value"],["class","col-12",4,"ngIf","ngIfElse"],[1,"col-md-12"],[1,"form-group"],[1,"form-floating"],["id","comment","name","comment","rows","1",1,"form-control",3,"ngModelChange","ngModel","placeholder"],["for","comment",1,"form-label"],[1,"orderTemplateDetailHead"],[1,"col-sm-6"],[1,"cartBox"],[1,"cartBox-head"],[1,"cartBox-body"],[3,"addToCart","cartMode"],[1,"mb-2",3,"checkoutInfo"],[1,"col-12"],[3,"address","showAddressName"],["class","col-sm-6 pe-2",4,"ngIf"],[1,"col-sm-6","pe-2"],["bindLabel","name","bindValue","PK","labelForId","costCenters",3,"change","clearable","items","placeholder"],["class","form-group",4,"ngIf"],["type","button",1,"btn","btn-secondary","btn-block",3,"click","disabled"],[1,"btn","btn-secondary","btn-block","mt-2",3,"click","disabled"],["bindLabel","name","bindValue","code","labelForId","purchaseReasons",3,"ngModelChange","change","clearable","disabled","items","placeholder","ngModel"],["type","button",1,"btn","btn-link","cartBox-link",3,"click"],["class","col-12",4,"ngIf"],["class","col-12",4,"ngFor","ngForOf","ngForTrackBy"]],template:function(e,c){if(e&1&&(o(0,"div",4)(1,"div",5)(2,"div",6),p(3),s(4,"cxTranslate"),o(5,"button",7),C(6,"cx-icon",8),a(),_(7,We,2,3,"ng-template",null,0,A),a()(),o(9,"div",9)(10,"div",10)(11,"div",11),_(12,$e,4,5,"button",12),a(),o(13,"div",11),_(14,qe,4,5,"button",13),a()()()(),_(15,at,87,75,"ng-container",14)),e&2){let l=F(8);n(3),m(" ",d(4,6,"approval.headline")," "),n(2),u("ngbPopover",l),n(),u("type",c.icons.INFO),n(6),u("ngIf",c.areApprovalButtonsVisible),n(2),u("ngIf",c.areApprovalButtonsVisible),n(),u("ngIf",!c.isLoading&&c.order)}},dependencies:[pe,me,ue,Se,Fe,ge,fe,Ce,be,Pe,Ae,Oe,Ee,he,_e,xe,ve,P],encapsulation:2}),b);Ve=De([Te(),Me("design:paramtypes",[w,D,U,L,j,N,B,W,R,H,M,k,V,P])],Ve);export{Ve as a};