1import{a as qt}from"./chunk-YBLBA6D6.js";import{a as Qt}from"./chunk-WSBIFOSJ.js";import{a as Bt}from"./chunk-63GZHPRM.js";import{a as f,b as H,c as Mt,d as Nt,e as $t,g as Vt,h as kt,i as B,j as Y,k as tt,l as Lt,m as xt,n as Gt,o as _t,p as Ht}from"./chunk-CNBMOLNM.js";import"./chunk-JC5PZU5R.js";import{a as Yt}from"./chunk-VC5NAGEJ.js";import{B as Dt,G as F,I as Ft,T as j,U as X,V,W as jt,g as J,h as Ot,i as Rt,j as z,k as K,l as wt}from"./chunk-SU7S3GV3.js";import{d as Tt}from"./chunk-NOYQY4IF.js";import{d as Ut}from"./chunk-DL3JVWPO.js";import{a as oe}from"./chunk-4Z5MUJO3.js";import"./chunk-LJH5OBMW.js";import{$d as Ct,$e as U,$f as bt,Ad as m,B as at,Bd as x,Bf as S,Ca as ft,D as nt,F as Z,Fd as v,G as W,He as yt,L as p,Nf as I,Oe as gt,Pa as b,Re as N,S as ct,Sf as l,Te as _,Ue as St,Uf as D,V as dt,Ve as A,Ye as T,Z as h,Zg as At,d as ot,da as pt,ga as M,he as Et,ia as ut,ie as G,ka as lt,lf as C,ma as mt,o as st,pb as w,qa as c,qf as $,ra as R,rf as It,sd as ht,ta as u,u as y,ua as a,uf as Pt,v as L,wd as vt,zf as g}from"./chunk-PMSJWPYZ.js";import{a as O,b as it,h as ie}from"./chunk-NIF3MU5U.js";var se=(()=>{class r{constructor(t){this.converter=t}convert(t,e){return e===void 0&&(e=O({},t)),this.removeDuplicatePromotions(t,e),this.handleQuoteCode(t,e),t.entries&&(e.entries=t.entries.map(i=>it(O({},i),{product:this.converter.convert(i.product,At),promotions:this.converter.convert({item:i,promotions:e?.appliedProductPromotions},X)}))),e}handleQuoteCode(t,e){t.sapQuote&&(e.quoteCode=t.sapQuote.code,e.quotePurchaseOrderNumber=t.sapQuote.sapPurchaseOrderNumber)}removeDuplicatePromotions(t,e){t&&t.potentialOrderPromotions&&(e.potentialOrderPromotions=this.removeDuplicateItems(t.potentialOrderPromotions)),t&&t.potentialProductPromotions&&(e.potentialProductPromotions=this.removeDuplicateItems(t.potentialProductPromotions)),t&&t.appliedOrderPromotions&&(e.appliedOrderPromotions=this.removeDuplicateItems(t.appliedOrderPromotions)),t&&t.appliedProductPromotions&&(e.appliedProductPromotions=this.removeDuplicateItems(t.appliedProductPromotions))}removeDuplicateItems(t){return t.filter((e,i,o)=>{let s=o.map(n=>JSON.stringify(n));return i===s.indexOf(JSON.stringify(e))})}static{this.\u0275fac=function(e){return new(e||r)(u(g))}}static{this.\u0275prov=c({token:r,factory:r.\u0275fac,providedIn:"root"})}}return r})(),ae=(()=>{class r{convert(t,e){return e=this.getProductPromotion(t.item,t.promotions),e}getProductPromotion(t,e){let i=[];return e?.forEach(o=>{if(o.description&&o.consumedEntries)for(let s of o.consumedEntries)this.isConsumedByEntry(s,t)&&i.push(o)}),i}isConsumedByEntry(t,e){let i=t.orderEntryNumber;if(e&&e.entries&&e.entries.length>0){for(let o of e.entries)if(o.entryNumber===i)return!0;return!1}else return i===e?.entryNumber}static{this.\u0275fac=function(e){return new(e||r)}}static{this.\u0275prov=c({token:r,factory:r.\u0275fac,providedIn:"root"})}}return r})(),ne=(()=>{class r{constructor(){this.logger=a(U),this.http=a(v),this.occEndpointsService=a(C),this.converterService=a(g)}getCartAccessCode(t,e){return this.http.post(this.getCartAccessCodeEndpoint(t,e),null).pipe(p(i=>{throw l(i,this.logger)}),I({shouldRetry:S,maxTries:2}),this.converterService.pipeable(kt))}getCartAccessCodeEndpoint(t,e){return this.occEndpointsService.buildUrl("cartAccessCode",{urlParams:{userId:t,cartId:e}})}static{this.\u0275fac=function(e){return new(e||r)}}static{this.\u0275prov=c({token:r,factory:r.\u0275fac})}}return r})(),et=(()=>{class r{constructor(t,e,i){this.http=t,this.occEndpointsService=e,this.converterService=i}add(t,e,i,o=1,s){let n=this.occEndpointsService.buildUrl("addEntries",{urlParams:{userId:t,cartId:e,quantity:o}});if(n.includes(`quantity=${o}`)){let k=new m({"Content-Type":"application/x-www-form-urlencoded"});return this.http.post(n,{},{headers:k,params:{code:i}}).pipe(this.converterService.pipeable(V))}let d=O({quantity:o,product:{code:i}},s&&{deliveryPointOfService:{name:s}}),P=new m({"Content-Type":"application/json"});return this.http.post(n,d,{headers:P}).pipe(this.converterService.pipeable(V))}update(t,e,i,o,s,n=!1){let d=new m({"Content-Type":"application/json"}
1),P=this.occEndpointsService.buildUrl("updateEntries",{urlParams:{userId:t,cartId:e,entryNumber:i}});if(s===void 0&&n)return this.http.put(P,{quantity:o},{headers:d}).pipe(this.converterService.pipeable(V));let k={};return s&&(k={deliveryPointOfService:{name:s}}),this.http.patch(P,O({quantity:o},k),{headers:d}).pipe(this.converterService.pipeable(V))}remove(t,e,i){let o=new m({"Content-Type":"application/x-www-form-urlencoded"}),s=this.occEndpointsService.buildUrl("removeEntries",{urlParams:{userId:t,cartId:e,entryNumber:i}});return this.http.delete(s,{headers:o})}static{this.\u0275fac=function(e){return new(e||r)(u(v),u(C),u(g))}}static{this.\u0275prov=c({token:r,factory:r.\u0275fac})}}return r})(),ce={"Content-Type":"application/json"},rt=(()=>{class r{constructor(){this.logger=a(U),this.http=a(v),this.occEndpointsService=a(C),this.converterService=a(g)}getRequestHeaders(){return T.createHeader(A,!0,new m(O({},ce)))}createCartGuestUser(t,e,i){return this.http.post(this.getCartGuestUserEndpoint(t,e),i,{headers:this.getRequestHeaders()}).pipe(p(o=>{throw l(o,this.logger)}),I({shouldRetry:S,maxTries:2}),this.converterService.pipeable(tt))}updateCartGuestUser(t,e,i){return this.http.patch(this.getCartGuestUserEndpoint(t,e),i,{headers:this.getRequestHeaders()}).pipe(p(o=>{throw l(o,this.logger)}),I({shouldRetry:S,maxTries:2}),this.converterService.pipeable(tt))}getCartGuestUserEndpoint(t,e){return this.occEndpointsService.buildUrl("cartGuestUser",{urlParams:{userId:t,cartId:e}})}static{this.\u0275fac=function(e){return new(e||r)}}static{this.\u0275prov=c({token:r,factory:r.\u0275fac})}}return r})(),de=(()=>{class r{constructor(t,e,i){this.http=t,this.occEndpoints=e,this.converter=i,this.logger=a(U)}validate(t,e){let i=this.occEndpoints.buildUrl("validate",{urlParams:{cartId:t,userId:e}});return this.http.post(i,null).pipe(p(o=>{throw l(o,this.logger)}),this.converter.pipeable(Lt))}static{this.\u0275fac=function(e){return new(e||r)(u(v),u(C),u(g))}}static{this.\u0275prov=c({token:r,factory:r.\u0275fac})}}return r})(),pe=(()=>{class r{constructor(t,e,i){this.http=t,this.occEndpoints=e,this.converter=i,this.logger=a(U),this.featureToggles=a(gt)}getCartVoucherEndpoint(t,e){return this.occEndpoints.buildUrl("cartVoucher",{urlParams:{userId:t,cartId:e}})}getRemoveCartVoucherEndpoint(t,e){return this.occEndpoints.buildUrl("cartRemoveVoucher",{urlParams:{userId:t,cartId:e}})}getHeaders(t){let e=new m({"Content-Type":"application/json"});return t===N&&(e=T.createHeader(A,!0,e)),e}add(t,e,i){let o=this.getCartVoucherEndpoint(t,e),s=JSON.stringify({}),n=new x().set("voucherId",i),d=this.getHeaders(t);return this.http.post(o,s,{headers:d,params:n}).pipe(p(P=>{throw l(P,this.logger)}),this.converter.pipeable(jt))}remove(t,e,i){let o=this.getHeaders(t);if(this.featureToggles.enableRemoveVoucherEndpoint){let n=this.getRemoveCartVoucherEndpoint(t,e),d={voucherId:i};return this.http.post(n,d,{headers:o}).pipe(p(P=>{throw l(P,this.logger)}))}let s=this.getCartVoucherEndpoint(t,e)+"/"+encodeURIComponent(i);return this.http.delete(s,{headers:o}).pipe(p(n=>{throw l(n,this.logger)}))}static{this.\u0275fac=function(e){return new(e||r)(u(v),u(C),u(g))}}static{this.\u0275prov=c({token:r,factory:r.\u0275fac})}}return r})(),ue=(()=>{class r{constructor(t,e,i){this.http=t,this.occEndpointsService=e,this.converterService=i}loadAll(t){return this.http.get(this.occEndpointsService.buildUrl("carts",{urlParams:{userId:t}})).pipe(y(e=>e.carts??[]),this.converterService.pipeableMany(j))}load(t,e){return e===_?this.loadAll(t).pipe(y(i=>i.find(o=>o.saveTime===void 0))):this.http.get(this.occEndpointsService.buildUrl("cart",{urlParams:{userId:t,cartId:e}})).pipe(this.converterService.pipeable(j))}create(t,e,i){let o=JSON.stringify({}),s={};return e&&(s.oldCartId=e),i&&(s.toMergeCartGuid=i),this.http.post(this.occEndpointsService.buildUrl("createCart",{urlParams:{userId:t},queryParams:s}),o).pipe(this.converterService.pipeable(j))}delete(t,e){let i=new m;return t===N&&(i=T.createHeader(A,!0,i)),this.http.delete(this.occEndpointsService.buildUrl("deleteCart",{urlParam
1s:{userId:t,cartId:e}}),{headers:i})}save(t,e,i,o){let s=this.occEndpointsService.buildUrl("saveCart",{urlParams:{userId:t,cartId:e,saveCartName:i,saveCartDescription:o}}),n=new x;return n=n.set("saveCartName",i).set("saveCartDescription",o),this.http.patch(s,n).pipe(y(d=>d.savedCartData),this.converterService.pipeable(j))}addEmail(t,e,i){let o=new m({"Content-Type":"application/x-www-form-urlencoded"});o=T.createHeader(A,!0,o);let s=new x().set("email",i),n=this.occEndpointsService.buildUrl("addEmail",{urlParams:{userId:t,cartId:e}});return this.http.put(n,s,{headers:o})}static{this.\u0275fac=function(e){return new(e||r)(u(v),u(C),u(g))}}static{this.\u0275prov=c({token:r,factory:r.\u0275fac})}}return r})();function le(){return{backend:{occ:{endpoints:{carts:"users/${userId}/carts?fields=carts(DEFAULT,potentialProductPromotions,appliedProductPromotions,potentialOrderPromotions,appliedOrderPromotions,entries(totalPrice(formattedValue),product(images(FULL),stock(FULL)),basePrice(formattedValue,value),updateable),totalPrice(formattedValue),totalItems,totalPriceWithTax(formattedValue),totalDiscounts(value,formattedValue),subTotal(formattedValue),totalUnitCount,deliveryItemsQuantity,deliveryCost(formattedValue),totalTax(formattedValue, value),pickupItemsQuantity,net,appliedVouchers,productDiscounts(formattedValue),user,saveTime,name,description)",cart:"users/${userId}/carts/${cartId}?fields=DEFAULT,potentialProductPromotions,appliedProductPromotions,potentialOrderPromotions,appliedOrderPromotions,entries(totalPrice(formattedValue),product(images(FULL),stock(FULL)),basePrice(formattedValue,value),updateable),totalPrice(formattedValue),totalItems,totalPriceWithTax(formattedValue),totalDiscounts(value,formattedValue),subTotal(formattedValue),totalUnitCount,deliveryItemsQuantity,deliveryCost(formattedValue),totalTax(formattedValue, value),pickupItemsQuantity,net,appliedVouchers,productDiscounts(formattedValue),user,saveTime,name,description",createCart:"users/${userId}/carts?fields=DEFAULT,potentialProductPromotions,appliedProductPromotions,potentialOrderPromotions,appliedOrderPromotions,entries(totalPrice(formattedValue),product(images(FULL),stock(FULL)),basePrice(formattedValue,value),updateable),totalPrice(formattedValue),totalItems,totalPriceWithTax(formattedValue),totalDiscounts(value,formattedValue),subTotal(formattedValue),totalUnitCount,deliveryItemsQuantity,deliveryCost(formattedValue),totalTax(formattedValue, value),pickupItemsQuantity,net,appliedVouchers,productDiscounts(formattedValue),user",addEntries:"users/${userId}/carts/${cartId}/entries",updateEntries:"users/${userId}/carts/${cartId}/entries/${entryNumber}",removeEntries:"users/${userId}/carts/${cartId}/entries/${entryNumber}",addEmail:"users/${userId}/carts/${cartId}/email",deleteCart:"users/${userId}/carts/${cartId}",cartVoucher:"users/${userId}/carts/${cartId}/vouchers",cartRemoveVoucher:"users/${userId}/carts/${cartId}/removeVoucher",saveCart:"/users/${userId}/carts/${cartId}/save",validate:"users/${userId}/carts/${cartId}/validate?fields=DEFAULT",cartAccessCode:"users/${userId}/carts/${cartId}/accessCode",cartGuestUser:"users/${userId}/carts/${cartId}/guestuser"}}}}}var Zt=(()=>{class r{static{this.\u0275fac=function(e){return new(e||r)}}static{this.\u0275mod=w({type:r})}static{this.\u0275inj=R({providers:[yt(le),{provide:$t,useClass:ue},{provide:j,useExisting:se,multi:!0},{provide:X,useExisting:ae,multi:!0},{provide:H,useClass:et},{provide:Mt,useClass:pe},{provide:xt,useClass:de},{provide:Vt,useClass:ne},{provide:B,useClass:rt}],imports:[ht]})}}return r})();var Wt=ie(oe());var Jt=(()=>{class r extends rt{assignGuest(t,e){if(!t)throw new Error("UserId is not defined");if(!e)throw new Error("CartId is not defined");let i=new m({"Content-Type":"application/json"});i=T.createHeader(A,!0,i);let o=this.occEndpointsService.buildUrl(`/users/${t}/carts/${e}/guest`);return this.http.put(o,{},{headers:i}).pipe(p(s=>{throw l(s,this.logger)}),I({shouldRetry:S,maxTries:2}))}setGuestInfo(t,e,i){if(!t)throw new Error("UserId is not defined");if(!e)throw new Error("CartId is not defined");if(!i)throw new Error("UserInfo is not defined");let o=this.occEndpointsService.buildUrl(`/users/${t}/carts/${e}/guest-info`,{queryParams:{fields:"DEFAULT"}});return this.http.put(o,(0,Wt.omitBy)(i,s=>s==="")).pipe(p(s=>{throw l(s,this.logger)}),I({shouldRetry:S,maxTries:2}))}static \u0275fac=(()=>{let t;return function(i){return(t||(t=b(r)))(i||r)}})();static \u0275prov=c({token:r,factory:r.\u0275fac})}return r})();var q=(()=>{class r{occEndpoints=a(C);http=a(v);logger=a(U);
1setPickupData(t,e,i){if(!t)throw new Error("UserId is not defined");if(!e)throw new Error("CartId is not defined");if(!i)throw new Error("DeliveryDate is not defined");let o=this.occEndpoints.buildUrl(`/users/${t}/carts/${e}/pickup-data`,{queryParams:{fields:"DEFAULT"}});return this.http.put(o,{deliveryDate:i}).pipe(p(s=>{throw l(s,this.logger)}),I({shouldRetry:S,maxTries:2}))}static \u0275fac=function(e){return new(e||r)};static \u0275prov=c({token:r,factory:r.\u0275fac})}return r})();var zt=(()=>{class r extends et{cartModificationStore=a(qt);update(t,e,i,o,s,n){return super.update(t,e,i,o,s,n).pipe(lt(d=>this.cartModificationStore.setForEntry(i,d)))}static \u0275fac=(()=>{let t;return function(i){return(t||(t=b(r)))(i||r)}})();static \u0275prov=c({token:r,factory:r.\u0275fac})}return r})();var Kt=(()=>{class r{static \u0275fac=function(e){return new(e||r)};static \u0275mod=w({type:r});static \u0275inj=R({providers:[{provide:H,useClass:zt},{provide:B,useClass:Jt},q],imports:[Zt]})}return r})();var Xt=(()=>{class r extends Y{assignGuest(t,e){return this.adapter.assignGuest(t,e)}setGuestInfo(t,e,i){return this.adapter.setGuestInfo(t,e,i)}static \u0275fac=(()=>{let t;return function(i){return(t||(t=b(r)))(i||r)}})();static \u0275prov=c({token:r,factory:r.\u0275fac})}return r})();var Q=(()=>{class r{adapter=a(q);setPickupData(t,e,i){return this.adapter.setPickupData(t,e,i)}static \u0275fac=function(e){return new(e||r)};static \u0275prov=c({token:r,factory:r.\u0275fac})}return r})();var te=(()=>{class r extends Gt{injector=a(ft);viewportScroller=a(vt);eventService=a(Pt);actions$=a(Et);store=a(Ct);_busy$=new ot(!1);busy$=this._busy$.asObservable().pipe(dt());constructor(){super(a(Dt),a(D),a(St)),this.subscription.add(nt(this.actions$.pipe(G(f.CART_ADD_ENTRY,f.CART_REMOVE_ENTRY,f.CART_UPDATE_ENTRY),y(()=>!0)),this.actions$.pipe(G(f.CART_ADD_ENTRY_SUCCESS,f.CART_ADD_ENTRY_FAIL,f.CART_REMOVE_ENTRY_SUCCESS,f.CART_REMOVE_ENTRY_FAIL,f.CART_UPDATE_ENTRY_SUCCESS,f.CART_UPDATE_ENTRY_FAIL),y(()=>!1))).subscribe(t=>this._busy$.next(t)))}isStable(){return at(()=>this.winRef.isBrowser(),super.isStable(),st(!0))}loadOrMerge(t,e,i){if(!(i===N&&t!==_)){super.loadOrMerge(t,e,i);return}this.subscription.add(this.actions$.pipe(G(bt.LOGIN),ct(1),ut(this.userIdService.getUserId().pipe(pt(1)))).subscribe(()=>super.loadOrMerge(t,e,i)))}addEntry(t,e,i,o){this.injector.get(Ut).validStore$.pipe(h()).subscribe(n=>{n?this.dispatchAddEntry(t,e,i,o):this.openModal(t,e,o)})}addEntryWithSource(t,e,i){this.addEntry(t,e,void 0,i)}addEntry$(t,e,i){return this.addEntryWithSource(t,e,i),W(this.getProductEvent$(J,t),this.getProductEvent$(Ot,t)).pipe(y(o=>o instanceof J&&o.statusCode!==Qt.NO_STOCK),h())}updateEntry$(t,e){return this.updateEntry(t,e),W(this.getCartEvent$(K,t),this.getCartEvent$(wt,t),this.getCartEvent$(z,t),this.getCartEvent$(Rt,t)).pipe(y(i=>i instanceof K||i instanceof z),h())}getProductEvent$(t,e){return this.eventService.get(t).pipe(Z(i=>i?.productCode===e))}getCartEvent$(t,e){return this.eventService.get(t).pipe(Z(i=>i?.entry?.entryNumber===e))}replaceEntry(t,e){this.getEntries().pipe(h()).subscribe(i=>{let o=i.find(s=>s.product.code===t);o?this.updateEntry(o.entryNumber,o.quantity+e.quantity):this.addEntry(t,e.quantity),this.removeEntry(e)})}deleteActiveCart(){this.getActive().pipe(h()).subscribe(t=>{let e=t.user?.uid==="anonymous"?t.guid:t.code;this.multiCartFacade.deleteCart(e,t.user?.uid)})}dispatchAddEntry(t,e,i,o){this.requireLoadedCart().pipe(mt(this.userIdService.getUserId())).subscribe(([s,n])=>
1{let d={userId:n,cartId:Nt(s,n),productCode:t,quantity:e,pickupStore:i,source:o};this.store.dispatch(new f.CartAddEntry(d))})}openModal(t,e,i){this.injector.get(Tt).open(Yt,{productCode:t,quantity:e,source:i}),this.viewportScroller.scrollToPosition([0,0])}static \u0275fac=function(e){return new(e||r)};static \u0275prov=c({token:r,factory:r.\u0275fac})}return r})();var ee=(()=>{class r extends _t{userIdService=a(D);activeCartFacade=a(F);assignGuestCommand=this.commandService.create(()=>this.guestPreconditions().pipe(M(({userId:t,cartId:e})=>this.cartGuestUserConnector.assignGuest(t,e))),{strategy:$.CancelPrevious});setGuestInfoCommand=this.commandService.create(t=>this.guestPreconditions().pipe(M(({userId:e,cartId:i})=>this.cartGuestUserConnector.setGuestInfo(e,i,t))),{strategy:$.CancelPrevious});assignGuest(){return this.assignGuestCommand.execute()}setGuestInfo(t){return this.setGuestInfoCommand.execute(t)}guestPreconditions(){return L({userId:this.userIdService.takeUserId(),cartId:this.activeCartFacade.getActiveCartId()}).pipe(h())}static \u0275fac=(()=>{let t;return function(i){return(t||(t=b(r)))(i||r)}})();static \u0275prov=c({token:r,factory:r.\u0275fac})}return r})();var re=(()=>{class r{commandService=a(It);userIdService=a(D);activeCartFacade=a(F);cartPickupConnector=a(Q);setPickupDataCommand=this.commandService.create(t=>this.guestPreconditions().pipe(M(({userId:e,cartId:i})=>this.cartPickupConnector.setPickupData(e,i,t))),{strategy:$.CancelPrevious});setPickupData(t){return this.setPickupDataCommand.execute(t)}guestPreconditions(){return L({userId:this.userIdService.takeUserId(),cartId:this.activeCartFacade.getActiveCartId()}).pipe(h())}static \u0275fac=function(e){return new(e||r)};static \u0275prov=c({token:r,factory:r.\u0275fac})}return r})();var xr=(()=>{class r{static \u0275fac=function(e){return new(e||r)};static \u0275mod=w({type:r});static \u0275inj=R({providers:[Q,{provide:Y,useClass:Xt},{provide:F,useClass:te},{provide:Ft,useClass:ee},{provide:Bt,useClass:re}],imports:[Ht,Kt]})}return r})();export{xr as TrnCartBaseCoreModule};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.