1import{B as ut,G as mt,k as dt}from"./chunk-CDH54WDO.js";import{K as Z,Ma as st,Na as pt,X as tt,Z as et,_ as it,aa as nt,ba as ot,j as Y,ja as rt,l as z,lb as ct,o as H,q as J,u as X,wa as at}from"./chunk-ROAQJP46.js";import{Ca as w,Da as A,H as b,Hb as p,Ib as f,Ja as x,Jb as g,Ka as v,Kb as q,Kc as L,Lb as R,Nb as T,Qb as F,R as y,Re as U,Sb as s,Wc as M,Yc as Q,cc as h,cd as V,dc as I,eb as r,ec as S,fb as l,ic as P,jb as E,jc as N,jd as j,kc as B,me as G,oh as $,ph as K,ta as O,tb as C,ub as D,v as k,vb as a,yc as c,yf as W,zc as d}from"./chunk-ADQO3XXX.js";function ft(e,o){if(e&1&&g(0,"cx-item-counter",9),e&2){let n=s(3);a("max",n.maxQuantity)("control",n.addToCartForm.get("quantity"))}}function ht(e,o){if(e&1&&(p(0,"span"),h(1),f()),e&2){let n=s(3);r(),I(n.getInventory())}}function _t(e,o){if(e&1&&(p(0,"div",5)(1,"label"),h(2),c(3,"cxTranslate"),f(),p(4,"div",6),C(5,ft,1,2,"cx-item-counter",7),p(6,"span",8),C(7,ht,2,1,"span",3),c(8,"async"),h(9),c(10,"cxTranslate"),c(11,"cxTranslate"),f()()()),e&2){let n=s(2);r(2),I(d(3,4,"addToCart.quantity")),r(3),a("ngIf",n.hasStock),r(2),a("ngIf",d(8,6,n.showInventory$)),r(2),S(" ",n.hasStock?d(10,8,"addToCart.inStock"):d(11,10,"addToCart.outOfStock"),"")}}function yt(e,o){}function xt(e,o){if(e&1){let n=T();q(0),C(1,yt,0,0,"ng-template",10),B("cxComponentRefChange",function(t){x(n);let u=s(2);return N(u.pickupOptionCompRef,t)||(u.pickupOptionCompRef=t),v(t)}),R()}if(e&2){let n=s(2);r(),a("cxOutlet",n.CartOutlets.ADD_TO_CART_PICKUP_OPTION),P("cxComponentRef",n.pickupOptionCompRef)}}function vt(e,o){if(e&1&&(p(0,"span",14),g(1,"cx-icon",15),f()),e&2){let n=s(3);r(),a("type",n.iconTypes.REPEAT)}}function gt(e,o){if(e&1&&(p(0,"button",11),C(1,vt,2,1,"span",12),c(2,"cxTranslate"),p(3,"span",13),c(4,"cxTranslate"),c(5,"cxTranslate"),h(6),c(7,"cxTranslate"),f()()),e&2){let n,i,t=s(2);a("ngClass",t.options!=null&&t.options.displayAddToCart?"btn btn-tertiary":"btn btn-primary btn-block")("disabled",t.quantity<=0||t.quantity>t.maxQuantity),r(),a("ngIf",(t.options==null?null:t.options.addToCartString)===d(2,6,"addToCart.buyItAgain")),r(2),a("ngClass",(t.options==null?null:t.options.addToCartString)===d(4,8,"addToCart.buyItAgain")?"buyItAgainLink":""),D("aria-label",(n=t.options==null?null:t.options.addToCartString)!==null&&n!==void 0?n:d(5,10,"addToCart.addToCart")),r(3),S(" ",(i=t.options==null?null:t.options.addToCartString)!==null&&i!==void 0?i:d(7,12,"addToCart.addToCart")," ")}}function Tt(e,o){if(e&1){let n=T();p(0,"form",1),F("submit",function(){x(n);let t=s();return v(t.addToCart())}),C(1,_t,12,12,"div",2)(2,xt,2,2,"ng-container",3)(3,gt,8,14,"button",4),f()}if(e&2){let n=s();a("formGroup",n.addToCartForm),r(),a("ngIf",n.showQuantity),r(),a("ngIf",n.hasStock),r(),a("ngIf",n.hasStock)}}var It=(()=>{let o=class o{constructor(i,t,u,_,m,lt){this.currentProductService=i,this.cd=t,this.activeCartService=u,this.component=_,this.eventService=m,this.productListItemContext=lt,this.showQuantity=!0,this.hasStock=!1,this.inventoryThreshold=!1,this.showInventory$=this.component?.data$.pipe(k(Ct=>Ct.inventoryDisplay)),this.quantity=1,this.addToCartForm=new z({quantity:new H(1,{updateOn:"blur"})}),this.CartOutlets=mt,this.iconTypes=it}ngOnInit(){this.product?(this.productCode=this.product.code??"",this.setStockInfo(this.product),this.cd.markForCheck()):this.productCode?(this.quantity=1,this.hasStock=!0,this.cd.markForCheck()):this.subscription=(this.productListItemContext?this.productListItemContext.product$:this.currentProductService.getProduct()).pipe(b(U)).subscribe(i=>{this.productCode=i.code??"",this.setStockInfo(i),this.cd.markForCheck()})}setStockInfo(i){this.quantity=1,this.addToCartForm.controls.quantity.setValue(1),this.hasStock=i.stock?.stockLevelStatus!=="outOfStock",this.inventoryThreshold=i.stock?.isValueRounded??!1,this.hasStock&&i.stock?.stockLevel&&(this.maxQuantity=i.stock.stockLevel),this.productListItemContext&&(this.showQuantity=!1)}getInventory(){if(this.hasStock){let i=this.maxQuantity?this.maxQuantity.toString():"";return this.inventoryThreshold?i+"+":i}else return""}updateCount(i){this.quantity=i}addToCart(){let i=this.addToCartForm.get("quantity")?.value;
1!this.productCode||i<=0||(this.pickupOptionCompRef instanceof E&&this.pickupOptionCompRef.instance.intendedPickupLocation$.pipe(y(1)).subscribe(t=>{this.pickupStore=t?.pickupOption==="pickup"?t.name:void 0}),this.activeCartService.getEntries().pipe(y(1)).subscribe(t=>{this.activeCartService.addEntry(this.productCode,i,this.pickupStore),this.eventService.dispatch(this.createCartUiEventAddToCart(this.productCode,i,t.length,this.pickupStore))}))}createCartUiEventAddToCart(i,t,u,_){let m=new dt;return m.productCode=i,m.quantity=t,m.numberOfEntriesBeforeAdd=u,m.pickupStoreName=_,m}ngOnDestroy(){this.subscription&&this.subscription.unsubscribe()}};o.\u0275fac=function(t){return new(t||o)(l(at),l(L),l(ut),l(rt),l(W),l(ct,8))},o.\u0275cmp=w({type:o,selectors:[["cx-add-to-cart"]],inputs:{productCode:"productCode",showQuantity:"showQuantity",options:"options",pickupStore:"pickupStore",product:"product"},decls:1,vars:1,consts:[[3,"formGroup","submit",4,"ngIf"],[3,"submit","formGroup"],["class","quantity",4,"ngIf"],[4,"ngIf"],["type","submit",3,"ngClass","disabled",4,"ngIf"],[1,"quantity"],[1,"cx-counter-stock"],[3,"max","control",4,"ngIf"],[1,"info"],[3,"max","control"],[3,"cxComponentRefChange","cxOutlet","cxComponentRef"],["type","submit",3,"ngClass","disabled"],["class","repeat-icon",4,"ngIf"],[3,"ngClass"],[1,"repeat-icon"],[3,"type"]],template:function(t,u){t&1&&C(0,Tt,4,4,"form",0),t&2&&a("ngIf",u.productCode)},dependencies:[M,Q,J,Y,X,nt,st,tt,V,$],encapsulation:2,changeDetection:0});let e=o;return e})(),jt=(()=>{let o=class o{};o.\u0275fac=function(t){return new(t||o)}
1,o.\u0275mod=A({type:o}),o.\u0275inj=O({providers:[G({cmsComponents:{ProductAddToCartComponent:{component:It,data:{inventoryDisplay:!1}}}})],imports:[j,Z,K,ot,pt,et]});let e=o;return e})();export{It as a,jt as b};
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.