import{a as ie}from"./chunk-EG5GZRMN.js";import{a as Me}from"./chunk-ZLKCSYK5.js";import{a as ke,b as De}from"./chunk-3P6GZXAL.js";import{b as Re}from"./chunk-SSXIUBOK.js";import{f as Y,g as we}from"./chunk-4ENQACUL.js";import{a as Fe}from"./chunk-LTUVDLS3.js";import{a as z}from"./chunk-4SQV5SMO.js";import{a as J}from"./chunk-ANRCCD2N.js";import{a as A}from"./chunk-B4H3G55F.js";import{H as W,J as Q}from"./chunk-CWWVHRJU.js";import{a as j}from"./chunk-RU43IR5J.js";import{a as q}from"./chunk-Y7IP5WLG.js";import{I as Ie}from"./chunk-SLGBXDUF.js";import{a as Pe}from"./chunk-LY6HB4BL.js";import{a as U}from"./chunk-SU6CJJJO.js";import{a as G}from"./chunk-HBJ2IG4O.js";import{L as v,N as $,T,U as Se,ba as xe,c as te,m as H}from"./chunk-FBI7JGZC.js";import{a as Ae}from"./chunk-ILYMG6ZI.js";import{r as be,t as Te}from"./chunk-MXUIPT66.js";import{Aa as m,Ab as C,Ba as h,Bb as S,Cb as w,Cd as ge,Cf as D,Db as R,Dc as M,Df as N,E as X,Fb as k,Gd as B,Jd as V,Kb as x,Kd as ye,Lb as s,N as se,Ua as a,Va as _,Vc as Ce,Wg as ve,Xc as fe,Yb as g,_b as y,a as re,bd as O,da as ce,db as pe,ga as Z,gc as de,gf as L,ib as f,ic as ee,jc as _e,o as K,ob as c,pa as le,qb as me,qc as ue,rc as l,s as oe,sc as p,t as ne,ta as F,ub as he,yh as Ee,z as ae,zb as u}from"./chunk-N6B2OJOY.js";import{a as P,b as I}from"./chunk-GHL4OFBQ.js";function We(o,t){o&1&&(u(0,"div",0),g(1),C()),o&2&&(a(),y(" ",t," "))}var Oe=(()=>{let t=class t{constructor(){this._promotionsService=le(A),this.promotionDescription$=this._promotionsService.getNextValidPotentialOrderPromotion().pipe(oe(e=>e&&e.description||null))}};t.\u0275fac=function(r){return new(r||t)},t.\u0275cmp=F({type:t,selectors:[["foerch-promotion-banner"]],standalone:!0,features:[de],decls:2,vars:3,consts:[[1,"container","alert","alert-promotion"]],template:function(r,n){if(r&1&&(f(0,We,2,1,"div",0),l(1,"async")),r&2){let d;he(0,(d=p(1,1,n.promotionDescription$))?0:-1,d)}},dependencies:[O],encapsulation:2,changeDetection:0});let o=t;return o})();var Ye=function(o,t,i,e){var r=arguments.length,n=r<3?t:e===null?e=Object.getOwnPropertyDescriptor(t,i):e,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(o,t,i,e);else for(var E=o.length-1;E>=0;E--)(d=o[E])&&(n=(r<3?d(n):r>3?d(t,i,n):d(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n},ze=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Je=(o,t,i,e,r,n,d,E)=>({subTotalPrice:o,isEProcurementCart:t,onlyEProcurementOrders:i,checkoutInfo:e,shouldShowPromotionHintBox:r,unqualifiedEntriesForPromotion:n,bulkActionOptions:d,isCartLoading:E}),Ke=o=>({"mb-7":o}),Xe=()=>({cxRoute:"checkout"}),Ze=()=>({cxRoute:"login"});function et(o,t){o&1&&S(0,"foerch-promotion-banner")}function tt(o,t){if(o&1&&(u(0,"button",17,0),l(2,"cxTranslate"),S(3,"cx-icon",7),C()),o&2){let i=s(3);c("ngbPopover",p(2,2,"cartDetails.cartContainsNonPurchasableProducts")),a(3),c("type",i.iconTypes.INFO)}}function it(o,t){o&1&&S(0,"cx-spinner",18)}function rt(o,t){if(o&1&&(u(0,"div",11)(1,"div",12),S(2,"foerch-cart-print-button",13),f(3,tt,4,4,"button",14),u(4,"button",15),l(5,"cxUrl"),f(6,it,1,0,"cx-spinner",16),g(7),l(8,"cxTranslate"),C()()()),o&2){let i=s().ngIf,e=s();a(2),c("sortModel",e.sortModel),a(),c("ngIf",e.hasAnyDeletedArticle),a(),me("btn-loading",i.isCartLoading||e.isNavigatingToCheckout()),c("disabled",i.isCartLoading||e.isNavigatingToCheckout()||e.footerConfig.disableAll||e.hasAnyDeletedArticle||!e.footerConfig.showCheckout||(i.checkoutInfo==null?null:i.checkoutInfo.allowed)===!1)("routerLink",p(5,8,ee(12,Xe))),a(2),c("ngIf",i.isCartLoading||e.isNavigatingToCheckout()),a(),y(" ",p(8,10,"cartDetails.proceedToCheckout")," ")}}function ot(o,t){o&1&&(u(0,"button",25),l(1,"cxUrl"),g(2),l(3,"cxTranslate"),C()),o&2&&(c("routerLink",p(1,2,ee(6,Ze))),a(2),y(" ",p(3,4,"cartDetails.login")," "))}function nt(o,t){if(o&1){let i=k();w(0),u(1,"div",19)(2,"div",20)(3,"div",21),g(4),l(5,"cxTranslate"),C()()(),u(6,"div",22)(7,"div",20),f(8,ot,4,7,"button",23),u(9,"button",24),x("click",function(){m(i);let r=s(2);return h(r.navigateToCatalog())}),g(10),l(11,"cxTranslate"),C()()(),R()}if(o&2){let i=s(2);a(4),y(" ",p(5,3,"cartDetails.emptyCart")," "),a(4),c("ngIf",!i.isLoggedIn),a(2),y(" ",p(11,5,"cartDetails.shopNow")," ")}}function at(o,t){if(o&1){let i=k();u(0,"foerch-cart-footer",28),x("applyBulkAction",function(r){m(i);let n=s(3);return h(n.applyBulkAction(r))})("markToggle",function(){m(i);let r=s(3);return h(r.toggleAll())})("transferEProcurementCart",function(){m(i);let r=s(3);return h(r.placeDirectEProcurementOrder())}),C()}if(o&2){let i=s(2).ngIf,e=s();c("bulkOptions",i.bulkActionOptions)("footerConfig",e.footerConfig)("hasAnyDeletedArticle",e.hasAnyDeletedArticle)("isEProcurementCart",i.isEProcurementCart)("isNavigatingToCheckout",e.isNavigatingToCheckout())("selectAll",e.selectionHelper.areAllSelected())("shouldDisableElements",(i.checkoutInfo==null?null:i.checkoutInfo.allowed)===!1)("sortModel",e.sortModel)("totalPrice",i.subTotalPrice)}}function st(o,t){if(o&1){let i=k();w(0),u(1,"foerch-cart-body",26),x("applyCostCenterToEntry",function(r){m(i);let n=s(2);return h(n.applyCcmToEntry(r))})("markEntry",function(r){m(i);let n=s(2);return h(n.markCartEntry(r))})("removeEntry",function(r){m(i);let n=s(2);return h(n.removeCartEntry(r))})("replaceArticle",function(r){m(i);let n=s(2);return h(n.replaceArticle(r))})("sortingChange",function(r){m(i);let n=s(2);return h(n.sortingChange(r))})("sortingReset",function(){m(i);let r=s(2);return h(r.sortingReset())})("updateComment",function(r){m(i);let n=s(2);return h(n.updateEntryComment(r))})("vpeChange",function(r){m(i);let n=s(2);return h(n.onVpeChange(r))}),C(),f(2,at,1,9,"foerch-cart-footer",27),R()}if(o&2){let i=s().ngIf,e=s();a(),c("cartConfig",e.cartConfig)("checkoutInfo",i.checkoutInfo)("isLoading$",e.isCartLoading$)("items",e.cartEntries)("selectionHelper",e.selectionHelper)("shouldShowPromotionHintBox",i.shouldShowPromotionHintBox)("sortableColumns",e.sortableColumns)("sortModel",e.sortModel)("totalPrice",i.subTotalPrice)("unqualifiedEntriesForPromotion",i.unqualifiedEntriesForPromotion),a(),c("ngIf",!e.isEProcurementOrderInProcess)}}function ct(o,t){if(o&1){let i=k();w(0),u(1,"div",2)(2,"div",3)(3,"div",4)(4,"div",5)(5,"button",6),x("click",function(){m(i);let r=s();return h(r.navigateToCatalog())}),S(6,"cx-icon",7),g(7),l(8,"cxTranslate"),C()(),u(9,"div",5)(10,"div",8),g(11),l(12,"cxTranslate"),C()(),f(13,rt,9,13,"div",9),C(),f(14,nt,12,7,"ng-container",1),C()(),u(15,"foerch-cart-head",10),l(16,"async"),x("addToCart",function(r){m(i);let n=s();return h(n.quickAddEntriesToCart(r))})("applyCCM",function(r){m(i);let n=s();return h(n.applyCostCenterAndObject(r))}),C(),f(17,st,3,11,"ng-container",1),R()}if(o&2){let i=t.ngIf,e=s();a(4),c("ngClass",e.isEmptyCart?"col-sm-4":"col-sm-auto"),a(2),c("type",e.iconTypes.ARROW_LEFT),a(),y(" ",p(8,12,"cartDetails.proceedToShopping")," "),a(2),c("ngClass",e.isEmptyCart?"col-sm-4":"col-sm"),a(2),y(" ",p(12,14,"cartDetails.cartName")," "),a(2),c("ngIf",!(e.isEmptyCart||i.isEProcurementCart||i.onlyEProcurementOrders)),a(),c("ngIf",e.isEmptyCart),a(),c("headerConfig",e.headerConfig)("isCartRefreshed",p(16,16,e.isCartRefreshed$))("isEmptyCart",e.isEmptyCart)("ngClass",_e(18,Ke,e.isEmptyCart)),a(2),c("ngIf",!e.isEmptyCart)}}var b,Be=(b=class{constructor(t,i,e,r,n,d,E,Ve,Le,Ne,He,$e,Ue,je){this.activeCartService=t,this.watchlistService=i,this.authService=e,this.modalService=r,this.categoriesService=n,this.routingService=d,this.eProcurementService=E,this.permissionService=Ve,this.enhancedECommerceService=Le,this.globalMessageService=Ne,this.router=He,this.activatedRoute=$e,this.cd=Ue,this.promotionsService=je,this.iconTypes=Ae,this.cartModes=H,this.targetType=te.CARTS,this.cartEntries=[],this.isEmptyCart=!1,this.isCartRefreshed$=this.activeCartService.isCartRefreshed(),this.isLoggedIn=!1,this.onlyEProcurementOrders$=this.permissionService.getPermissionValueAsBoolean(T.EPROCUREMENT_ORDERS),this.isEProcurementOrderInProcess=!1,this.selectionHelper=new Fe,this.headerConfig={showCCM:!0,showDialogLinks:!0,showQuickAddInBox:!0,cartMode:H.CART},this.cartConfig={cartMode:H.CART,highlightDeletedArticles:!0,highlightReplaceableArticles:!0,isAnonymousUser:!0,isEditable:!0,showAddToCart:!1,showCCM:!1,showPrice:!0,showPromotions:!0,showRememberedAt:!1,showVolumePrices:!0,showVPE:!0},this.footerConfig={addCoupon:!1,showCheckout:!0,showPromotions:!0,showTotal:!0,disableAll:!1},this.hasAnyDeletedArticle=!1,this.sortableColumns=[Y.ARTICLE_NUMBER,Y.ARTICLE_NAME,Y.TOTAL],this.defaultSortModel={sortBy:"code",sortDirection:xe.ASC},this.sortModel=this.defaultSortModel,this.articleNumberMode=Se.FOERCH,this.isCartLoading$=this.activeCartService.isLoading().pipe(Z(qe=>this._isCartLoading=qe)),this.isNavigatingToCheckout=pe(!1),this.checkoutInfo$=this.activeCartService.getCheckoutInfo(),this.shouldShowPromotionHintBox$=this.promotionsService.hasNextUnqualifiedEntries(),this.unqualifiedEntriesForPromotion$=this.promotionsService.getNextUnqualifiedEntries(),this._rootCategoryId="",this._subs$=new re,this._isCartLoading=!1}ngOnInit(){this.bulkActionOptions$=this.permissionService.getPermissionValueAsBoolean(T.VISITING_CUSTOMER).pipe(ce(t=>ae(()=>t,K([v.ADD_TO_WATCH_LIST,v.DELETE]),K([v.ADD_TO_ORDER_TEMPLATE,v.ADD_TO_WATCH_LIST,v.DELETE])))),this.subTotalPrice$=this.activeCartService.getSubTotalPrice(),this.isEProcurementCart$=this.eProcurementService.isEProcurementCart().pipe(Z(t=>{t&&(this.sortableColumns=[],this.sortModel={})})),this._subs$.add(ne([this.authService.isUserLoggedIn(),this.permissionService.getPermissionValueAsBoolean(T.COST_CENTER_MANAGEMENT_TOOL),this.permissionService.getPermissionValueAsBoolean(T.ACTIVATE_WEBSHOP_ORDER_FUNCTION),this.permissionService.getPermissionValueAsBoolean(T.VISITING_CUSTOMER)]).subscribe(([t,i,e])=>{this.isLoggedIn=t,this.cartConfig=I(P({},this.cartConfig),{isAnonymousUser:!t,showPrice:t,showCCM:t&&i}),this.footerConfig=I(P({},this.footerConfig),{showTotal:t,showCheckout:!t||e}),this.headerConfig=I(P({},this.headerConfig),{showCCM:t&&i})})),this._subs$.add(this.activeCartService.getEntries().subscribe(t=>{this.cartEntries=t?ie(t,this.sortModel,this.articleNumberMode):[];let i=[$.DELETED,$.UNAVAILABLE,$.ONLY_AVAILABLE_WITHIN_ASSORTMENT];this.hasAnyDeletedArticle=this.cartEntries.some(e=>i.includes(e.product?.saleability?.status)),this.isEmptyCart=t.length===0,this.selectionHelper.updateItems(this.isEmptyCart?[]:this.cartEntries.filter(e=>!e.giveAway&&!e.freightToll).map(e=>({id:e.pk,item:e}))),this.disableFooterLinks(),this.cd.markForCheck()})),this._subs$.add(this.categoriesService.getRootCategoryId().subscribe(t=>this._rootCategoryId=t)),this._subs$.add(this.router.events.subscribe(t=>{t instanceof ge&&t.url==="/checkout"&&(this.isNavigatingToCheckout.set(!0),this.enhancedECommerceService.trackCheckout(1,this.cartEntries))})),this._subs$.add(this.activatedRoute.queryParamMap.pipe(X(t=>t.has("add"))).subscribe(t=>{this.handleRouteChangeForAddQueryParam(t)})),this._subs$.add(this.permissionService.getPermissionValue(T.ACTIVATE_WEBSHOP_ARTICLE_NUMBER).subscribe(t=>{t&&(this.articleNumberMode=t,this.cd.detectChanges())}))}ngOnDestroy(){this._subs$.unsubscribe()}applyCostCenterAndObject(t){let i=t.toAll?this.cartEntries.filter(e=>!e.freightToll):this.selectionHelper.getSelectedItems().map(e=>e.item);this.activeCartService.applyCostCenterForEntries({costCenter:t.costCenter.code,costReason:t.purchaseReason?t.purchaseReason.code:null,entries:i,targetType:this.targetType})}quickAddEntriesToCart(t){this.activeCartService.addEntries({entries:t,targetType:this.targetType})}applyCcmToEntry(t){this.activeCartService.applyCostCenterForEntries({costCenter:t.costCenter,costReason:t.orderReason,entries:[t.item],targetType:this.targetType})}updateEntryComment(t){this.activeCartService.updateEntryComment({comment:t.comment,pk:t.item.pk})}removeCartEntry(t){this.activeCartService.removeEntries([t.item],this.targetType)}markCartEntry(t){this.selectionHelper.toggleItemStatus(t.item.pk)}applyBulkAction(t){let i=this.selectionHelper.getSelectedItems().map(r=>r.item);if(i.length===0)return;let e=i.filter(r=>r.product.saleability&&r.product.saleability.purchasable===!0);switch(t){case v.DELETE:{this._isCartLoading===!1&&this.activeCartService.removeEntries(i,this.targetType);break}case v.ADD_TO_ORDER_TEMPLATE:{if(e.length===0){this.globalMessageService.add({key:"cartDetails.selectOnlyPurchasableArticles"},D.MSG_TYPE_INFO);break}else e.length<i.length&&this.globalMessageService.add({key:"cartDetails.notAllArticlesPurchasable"},D.MSG_TYPE_INFO);let r;this.modalRef=this.modalService.open(Me),r=this.modalRef.componentInstance,r.entries=e;break}case v.ADD_TO_WATCH_LIST:{if(e.length===0){this.globalMessageService.add({key:"cartDetails.selectOnlyPurchasableArticles"},D.MSG_TYPE_INFO);break}let r=e.map(n=>({code:n.product.code,comment:n.comment,qty:1}));r.length<i.length&&this.globalMessageService.add({key:"cartDetails.notAllArticlesPurchasable"},D.MSG_TYPE_INFO),this.watchlistService.addEntries(r);break}default:console.error("unimplemented option",t)}}onVpeChange(t){let i=t.packagingUnits.find(e=>e.numberContentUnit===t.selectedVPE);i&&i.materialCode&&this.activeCartService.updateQuantity({pk:t.code,qty:t.quantity,material:i.materialCode})}replaceArticle(t){if(t){let i=t.replacement?.preferredMaterialAndQuantity;t.item?.pk&&i&&this.activeCartService.updateQuantity({pk:t.item.pk,qty:i.quantity||1,material:i.materialCode})}}sortingReset(){this.sortingChange(this.defaultSortModel)}sortingChange(t){this.sortModel=t,this.cartEntries=ie(this.cartEntries,this.sortModel,this.articleNumberMode)}navigateToCatalog(){this._rootCategoryId&&this.routingService.go({cxRoute:"category",params:{code:this._rootCategoryId}})}placeDirectEProcurementOrder(){this.isEProcurementOrderInProcess=!0,this.eProcurementService.placeOrder()}toggleAll(){this.selectionHelper.toggleAll(),this.selectionHelper=this.selectionHelper.clone()}handleRouteChangeForAddQueryParam(t){let i=t.get("add");if(i==null||i.length===0)return;let e=i.split(",");if(e.length===0)return;let n={entries:e.map(d=>({code:d.trim(),qty:1})),targetType:te.CARTS,showConfirmDialog:!1};this.activeCartService.getActive().pipe(X(d=>!!d),se(1)).subscribe(()=>{this.activeCartService.addEntries(n),this.router.navigate(["."],{relativeTo:this.activatedRoute}).then(()=>{})})}disableFooterLinks(){this.footerConfig=I(P({},this.footerConfig),{disableAll:this.isEmptyCart})}},b.\u0275fac=function(i){return new(i||b)(_(Q),_(U),_(L),_(q),_(J),_(G),_(W),_(j),_(z),_(N),_(V),_(B),_(M),_(A))},b.\u0275cmp=F({type:b,selectors:[["foerch-cart-details"]],decls:10,vars:27,consts:[["p","ngbPopover"],[4,"ngIf"],[1,"container"],[1,"cartHead"],[1,"row","align-items-center"],[1,"col-12",3,"ngClass"],["type","button",1,"btn","btn-tertiary","btn-back",3,"click"],[3,"type"],[1,"h2","cartHead-title","text-sm-center"],["class","col-12 col-sm-auto",4,"ngIf"],[3,"addToCart","applyCCM","headerConfig","isCartRefreshed","isEmptyCart","ngClass"],[1,"col-12","col-sm-auto"],[1,"text-end","d-none","d-sm-block"],[1,"me-2",3,"sortModel"],["class","btn-icon me-2","container","body","placement","left","triggers","mouseenter:mouseleave:click","type","button",3,"ngbPopover",4,"ngIf"],["type","button",1,"btn","btn-commerce",3,"disabled","routerLink"],["class","spinner_small",4,"ngIf"],["container","body","placement","left","triggers","mouseenter:mouseleave:click","type","button",1,"btn-icon","me-2",3,"ngbPopover"],[1,"spinner_small"],[1,"row","mt-3","mb-4"],[1,"col-12","text-sm-center"],[1,"emptyState-text"],[1,"row","pb-6"],["class","btn btn-secondary btn-wider me-2","type","button",3,"routerLink",4,"ngIf"],["type","button",1,"btn","btn-primary","btn-wider",3,"click"],["type","button",1,"btn","btn-secondary","btn-wider","me-2",3,"routerLink"],[3,"applyCostCenterToEntry","markEntry","removeEntry","replaceArticle","sortingChange","sortingReset","updateComment","vpeChange","cartConfig","checkoutInfo","isLoading$","items","selectionHelper","shouldShowPromotionHintBox","sortableColumns","sortModel","totalPrice","unqualifiedEntriesForPromotion"],[3,"bulkOptions","footerConfig","hasAnyDeletedArticle","isEProcurementCart","isNavigatingToCheckout","selectAll","shouldDisableElements","sortModel","totalPrice","applyBulkAction","markToggle","transferEProcurementCart",4,"ngIf"],[3,"applyBulkAction","markToggle","transferEProcurementCart","bulkOptions","footerConfig","hasAnyDeletedArticle","isEProcurementCart","isNavigatingToCheckout","selectAll","shouldDisableElements","sortModel","totalPrice"]],template:function(i,e){i&1&&(f(0,et,1,0,"foerch-promotion-banner",1)(1,ct,18,20,"ng-container",1),l(2,"async"),l(3,"async"),l(4,"async"),l(5,"async"),l(6,"async"),l(7,"async"),l(8,"async"),l(9,"async")),i&2&&(c("ngIf",e.cartConfig.showPromotions),a(),c("ngIf",ue(18,Je,p(2,2,e.subTotalPrice$),p(3,4,e.isEProcurementCart$),p(4,6,e.onlyEProcurementOrders$),p(5,8,e.checkoutInfo$),p(6,10,e.shouldShowPromotionHintBox$),p(7,12,e.unqualifiedEntriesForPromotion$),p(8,14,e.bulkActionOptions$),p(9,16,e.isCartLoading$))))},dependencies:[Ce,fe,ye,Re,we,De,ke,Oe,Ie,be,Te,Ee,O,ve],encapsulation:2,changeDetection:0}),b);Be=Ye([Pe(),ze("design:paramtypes",[Q,U,L,q,J,G,W,j,z,N,V,B,M,A])],Be);export{Oe as a,Be as b};