1import{a as Z,b as tt}from"./chunk-SOEL42P7.js";import{a as X,b as Y}from"./chunk-2ELNDHLL.js";import{a as et}from"./chunk-RXCXR7O6.js";import"./chunk-3J6GJA2Y.js";import"./chunk-UETD4DIZ.js";import{Cb as j,Cd as J,Lc as U,Nc as H,Oc as W,Tb as Q,Tc as K,Vb as B,c as N,ea as V,ed as G,fa as A,lb as F,pa as R,tb as L,u as z,uc as $}from"./chunk-QFV2VXXO.js";import"./chunk-MNOAC44J.js";import{G as q}from"./chunk-SD7HBRTT.js";import"./chunk-ZSKOB7NA.js";import{$ as m,Ab as x,Bb as f,Eb as O,Fb as E,Gb as C,Hb as a,Ib as o,Ic as c,Jb as b,Lc as M,Mc as w,Qb as h,Ub as g,Va as u,W as l,Wb as s,aa as _,ba as k,ib as P,ic as p,jc as y,lc as T,ma as D,yb as I}from"./chunk-LFZB7MMP.js";import{a as S}from"./chunk-IMPBB4AK.js";function ot(n,t){if(n&1&&b(0,"img",2),n&2){let e=s();C("appLazyLoad",e.thumbnail())("alt",e.product().name)}}function ct(n,t){n&1&&b(0,"div",3)}function dt(n,t){if(n&1){let e=h();a(0,"div",9),g("click",function(i){return m(e),_(i.stopPropagation())}),a(1,"app-counter",10),g("valueChange",function(i){m(e);let d=s();return _(d.onQuantityChange(i))}),o()()}if(n&2){let e=s();u(),C("min",0)("max",e.counterMax())("value",e.quantity())("size",e.CounterSize.Small)}}function lt(n,t){if(n&1){let e=h();a(0,"button",11),g("click",function(i){m(e);let d=s();return _(d.onAddClick(i))}),k(),a(1,"svg",12),b(2,"line",13)(3,"line",14),o()()}}var v=class n{storeDateTime=l(F);product=w.required();quantity=w(0);addProduct=M();quantityChange=M();CounterSize=Z;thumbnail=c(()=>{let t=this.product().images;return t?.length?t[0].thumbnail||t[0].src:""});priceDisplay=c(()=>R(this.product()?.price||0,this.storeDateTime.roundDigits()));isInCart=c(()=>this.quantity()>0);counterMax=c(()=>V(this.product()));onCardClick(){this.isInCart()||this.addProduct.emit(this.product())}onAddClick(t){t.stopPropagation(),this.addProduct.emit(this.product())}onQuantityChange(t){this.quantityChange.emit(t)}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=P({type:n,selectors:[["app-popular-product-card"]],inputs:{product:[1,"product"],quantity:[1,"quantity"]},outputs:{addProduct:"addProduct",quantityChange:"quantityChange"},decls:11,vars:5,consts:[[1,"popular-card",3,"click"],[1,"popular-card__image"],[3,"appLazyLoad","alt"],[1,"popular-card__image-placeholder"],[1,"popular-card__info"],[1,"popular-card__name"],[1,"popular-card__price"],[1,"popular-card__counter"],["type","button","aria-label","Add product",1,"popular-card__add"],[1,"popular-card__counter",3,"click"],[3,"valueChange","min","max","value","size"],["type","button","aria-label","Add product",1,"popular-card__add",3,"click"],["xmlns","http://www.w3.org/2000/svg","width","22","height","22","viewBox","0 0 24 24","fill","none","stroke","currentColor","stroke-width","2.5","stroke-linecap","round","stroke-linejoin","round"],["x1","12","y1","5","x2","12","y2","19"],["x1","5","y1","12","x2","19","y2","12"]],template:function(e,r){e&1&&(a(0,"div",0),g("click",function(){return r.onCardClick()}),a(1,"div",1),x(2,ot,1,2,"img",2)(3,ct,1,0,"div",3),o(),a(4,"div",4)(5,"span",5),p(6),o(),a(7,"span",6),p(8),o()(),x(9,dt,2,4,"div",7)(10,lt,4,0,"button",8),o()),e&2&&(I("data-in-cart",r.isInCart()||null),u(2),f(r.thumbnail()?2:3),u(4),y(r.product().name),u(2),y(r.priceDisplay()),u(),f(r.isInCart()?9:10))},dependencies:[et,tt],styles:["[_nghost-%COMP%]{display:block}.popular-card[_ngcontent-%COMP%]{display:flex;align-items:center;gap:16px;padding:12px 16px;border:1px solid var(--gray-300);border-radius:12px;cursor:pointer;transition:border-color .2s,box-shadow .2s;background-color:var(--white)}.popular-card[_ngcontent-%COMP%]:hover{border-color:var(--gray-400);box-shadow:0 2px 8px #0000000f}.popular-card[data-in-cart=true][_ngcontent-%COMP%]{cursor:default}.popular-card__image[_ngcontent-%COMP%]{flex-shrink:0;width:80px;height:80px;border-radius:8px;overflow:hidden;background-color:var(--gray-100)}.popular-card__image[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{width:100%;height:100%;object-fit:cover;display:block}.popular-card__image-placeholder[_ngcontent-%COMP%]{width:100%;height:100%;background-color:var(--gray-200)}.popular-card__info[_ngcontent-%COMP%]{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}.popular-card__name[_ngcontent-%COMP%]{font-family:var(--font-title);font-size:16px;font-weight:600;line-height:1.3;color:var(--gray-900);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.popular-card__price[_ngcontent-%COMP%]{font-family:var(--font-body);font-size:15px;font-weight:400;color:var(--gray-600);line-height:1.3}.popular-card__add[_ngcontent-%COMP%]{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:36px;height:36px;border:none;background:none;color:var(--primary);cursor:pointer;border-radius:50%;transition:background-color .2s,color .2s;padding:0}.popular-card__add[_ngcontent-%COMP%]:hover{background-color:var(--gray-200)}.popular-card__counter[_ngcontent-%COMP%]{flex-shrink:0}@media(max-width:640px){.popular-card[_ngcontent-%COMP%]{gap:12px;padding:10px 12px}.popular-card__image[_ngcontent-%COMP%]{width:64px;
1height:64px}.popular-card__name[_ngcontent-%COMP%]{font-size:14px}.popular-card__price[_ngcontent-%COMP%]{font-size:13px}}"],changeDetection:0})};var st=(n,t)=>t.id;function ut(n,t){if(n&1){let e=h();a(0,"app-popular-product-card",12),g("addProduct",function(i){m(e);let d=s();return _(d.onProductClick(i))})("quantityChange",function(i){let d=m(e).$implicit,nt=s();return _(nt.onQuantityChange(d,i))}),o()}if(n&2){let e=t.$implicit,r=s();C("product",e)("quantity",r.quantitiesByProductId().get(e.id)??0)}}function pt(n,t){n&1&&(a(0,"p",5),p(1,"No extras available right now."),o())}function mt(n,t){if(n&1){let e=h();a(0,"app-button",13),g("click",function(){m(e);let i=s();return _(i.onContinueToCheckout())}),p(1," CONTINUE TO CHECKOUT "),o()}if(n&2){let e=s();C("disabled",e.isSyncing())("loading",e.isSyncing())}}function _t(n,t){if(n&1&&(a(0,"app-button",11),p(1),o()),n&2){let e=s();C("disabled",!0),u(),T(" ADD ",e.mealsNeeded()," MORE MEAL",e.mealsNeeded()===1?"":"S"," TO CHECKOUT ")}}var rt=class n{cartService=l(G);productsService=l(j);mealPlansService=l(L);authService=l(J);dialog=l(H);dialogRef=l(U);router=l(q);additionsPrompt=l(N);notificationService=l(z);isSyncing=D(!1);products=c(()=>this.productsService.extraProducts());quantitiesByProductId=c(()=>{let t=this.getCurrentMealPlanId(),e=t!==null?this.cartService.orderPageVisibleItems(t):this.cartService.items();return X(e)});mealPlanPosts=this.mealPlansService.posts;currentMealPlanCard=c(()=>{let t=this.getCurrentMealPlanId();return t===null?null:this.mealPlansService.mealPlanCards().find(e=>e.id===t)??null});currentPlanMealCount=c(()=>{let t=this.getCurrentMealPlanId(),e=t!==null?this.cartService.orderPageVisibleItems(t):this.cartService.items(),r=t!==null?this.cartService.itemsByPlan().find(i=>i.mpid===t):void 0;return r?.backendRegularItemCount!=null?r.backendRegularItemCount:e.reduce((i,d)=>Q(d)||B(d)?i:i+d.quantity,0)});minimumMealsRequired=c(()=>{let t=this.currentMealPlanCard();if(t&&t.minMeals>0)return t.minMeals;let e=this.productsService.productsMin();return e>0?e:0});hasMetMealMinimum=c(()=>{let t=this.minimumMealsRequired();return t<=0?!0:this.currentPlanMealCount()>=t});mealsNeeded=c(()=>{let t=this.minimumMealsRequired();return Math.max(0,t-this.currentPlanMealCount())});constructor(){document.documentElement.classList.add("app-dialog-open")}ngOnDestroy(){document.documentElement.classList.remove("app-dialog-open")}async onProductClick(t){if(!this.hasProductAddons(t)){this.addProductToCart(t);return}let{MealSelectionDialogComponent:e}=await import("./chunk-IW5TIU5N.js");this.dialog.open(e,{data:{product:t,isAddition:!0},panelClass:"meal-selection-dialog-panel",maxWidth:"855px",width:"100%"})}onQuantityChange(t,e){let r=Y(this.getMatchingCartItems(t.id),e);for(let i of r)switch(i.type){case"update":this.cartService.updateItem(i.key,i.quantity);break;case"remove":this.cartService.removeItem(i.key);break;default:return i}}onContinueToCheckout(){if(!this.hasMetMealMinimum()||this.isSyncing())return;this.additionsPrompt.markHandled();let t=this.getCurrentMealPlanId();if(t!==null&&this.cartService.commitPlanItems(t),!this.authService.authenticated()&&this.cartService.hasAnySubscription()){this.dialogRef.close(),this.router.navigate(["/checkout"]);return}this.isSyncing.set(!0),this.cartService.waitForCheckoutReady().subscribe({next:()=>{this.isSyncing.set(!1),this.dialogRef.close(),this.router.navigate(["/checkout"])},error:()=>{this.isSyncing.set(!1),this.notificationService.error("Failed to prepare cart for checkout. Please try again.")}})}getMatchingCartItems(t){let e=this.getCurrentMealPlanId();return(e!==null?this.cartService.orderPageVisibleItems(e):this.cartService.items()).filter(i=>i.id===t)}hasProductAddons(t){return $(t).length>0}addProductToCart(t){let e=this.buildCartItemDataPayload(),r=S({id:t.id,quantity:1},e?{cart_item_data:e}:{});this.cartService.addItem(r,this.buildDisplayData(t))}buildDisplayData(t){let e=this.getPriceCents(t.price),r=this.getPriceCents(t.regular_price||t.price),i=this.buildItemData();return{name:t.name,prices:{price:e.toString(),regular_price:r.toString(),sale_price:e.toString(),price_range:null,raw_prices:{precision:2,price:e.toString(),regular_price:r.toString(),sale_price:e.toString()},currency_code:"USD",currency_symbol:"$",currency_minor_unit:2,currency_decimal_separator:".",currency_thousand_separator:",",currency_prefix:"$",currency_suffix:""},images:this.buildCartImages(t),item_data:i,quantity_limits:A(t),variation:[],extensions:this.buildCartItemExtensions()}}buildItemData(){let t=this.getCurrentMealPlanMetadata();return t?[{name:"mpid",display:t.mpid.toString(),value:t.mpid.toString(),price:""},{name:"Meal Plan",display:t.mealPlanTitle,value:t.mealPlanTitle,price:""}]:[]}buildCartImages(t){return t.images?.map(e=>({id:e.id,src:e.src,thumbnail:e.thumbnail||e.src,srcset:e.srcset||"",sizes:"",name:e.name,alt:e.alt||t.name}))}buildCartItemDataPayload(){let t=this.getCurrentMealPlanId();if(t!==null)return{mpid:t,mpextra:1}}buildCartItemExtensions(){let t=this.getCurrentMealPlanId();return t===null?{}:{mpid:t,mpextra:1}}getCurrentMealPlanMetadata(){let t=this.getCurrentMealPlanId();if(t===null)return null;let e=this.mealPlanPosts().find(r=>r.id===t)?.title||`Meal Plan #${t}`;return{mpid:t,mealPlanTitle:e}}getCurrentMealPlanId(){let t=Number(this.router.parseUrl(this.router.url).queryParams.mpid);return Number.isFinite(t)&&t>0?Math.trunc(t):this.productsService.currentMpid()}getPriceCents(t){return Math.round((t||0)*100)}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=P({type:n,selectors:[["app-extra-products-dialog"]],decls:17,vars:2,consts:[[1,"extra-products"],[1,"extra-products__title"],[1,"extra-products__subtitle"],[1,"extra-products__list"],[3,"product","quantity"],[1,"extra-products__empty"],["footer","",1,"extra-products__footer"],[1,"extra-products__divider"],[1,"extra-products__divider-text"],[1,"extra-products__action"],[1,"full-width",3,"disabled","loading"],[1,"full-width",3,"disabled"],[3,"addProduct","quantityChange","product","quantity"],[1,"full-width",3,"click","disabled","loading"]],template:function(e,r){e&1&&(a(0,"app-dialog-wrapper")(1,"div",0)(2,"h2",1),p(3,"Wait, don't forget these extras!"),o(),a(4,"p",2),p(5,"Make your week even better with a few healthy treats"),o(),a(6,"div",3),O(7,ut,1,2,"app-popular-product-card",4,st,!1,pt,2,0,"p",5),o()(),a(10,"div",6)(11,"div",7)(12,"span",8),p(13,"-OR-"),o()(),a(14,"div",9),x(15,mt,2,2,"app-button",10)(16,_t,2,3,"app-button",11),o()()()),e&2&&(u(7),E(r.products()),u(8),f(r.hasMetMealMinimum()?15:16))},dependencies:[W,v,K],styles:[".extra-products[_ngcontent-%COMP%]{display:flex;flex-direction:column;font-family:var(--font-body)}.extra-products__title[_ngcontent-%COMP%]{font-family:var(--font-title);font-size:24px;font-weight:700;
1color:#1a1a1a;margin:0 0 8px;text-align:center;line-height:1.3}.extra-products__subtitle[_ngcontent-%COMP%]{font-family:var(--font-body);font-size:14px;font-weight:400;color:#888;margin:0 0 24px;text-align:center;line-height:1.4}.extra-products__list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:16px;max-height:50vh;overflow-y:auto;padding:2px;scrollbar-width:thin;scrollbar-color:var(--scrollbar-thumb) var(--scrollbar-track)}.extra-products__list[_ngcontent-%COMP%]::-webkit-scrollbar{width:5px;height:5px;-webkit-appearance:none;appearance:none}.extra-products__list[_ngcontent-%COMP%]::-webkit-scrollbar-button, .extra-products__list[_ngcontent-%COMP%]::-webkit-scrollbar-button:single-button, .extra-products__list[_ngcontent-%COMP%]::-webkit-scrollbar-button:single-button:vertical:decrement, .extra-products__list[_ngcontent-%COMP%]::-webkit-scrollbar-button:single-button:vertical:increment, .extra-products__list[_ngcontent-%COMP%]::-webkit-scrollbar-button:vertical:start:decrement, .extra-products__list[_ngcontent-%COMP%]::-webkit-scrollbar-button:vertical:end:increment, .extra-products__list[_ngcontent-%COMP%]::-webkit-scrollbar-button:horizontal:start:decrement, .extra-products__list[_ngcontent-%COMP%]::-webkit-scrollbar-button:horizontal:end:increment{display:none;width:0;height:0;-webkit-appearance:none;appearance:none;background:transparent}.extra-products__list[_ngcontent-%COMP%]::-webkit-scrollbar-corner, .extra-products__list[_ngcontent-%COMP%]::-webkit-scrollbar-track-piece:start, .extra-products__list[_ngcontent-%COMP%]::-webkit-scrollbar-track-piece:end{background:transparent}.extra-products__list[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:var(--scrollbar-track);border-radius:var(--scrollbar-radius)}.extra-products__list[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:var(--scrollbar-thumb);border-radius:var(--scrollbar-radius)}.extra-products__list[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:var(--scrollbar-thumb-hover)}.extra-products__empty[_ngcontent-%COMP%]{font-family:var(--font-body);font-size:14px;color:#888;text-align:center;padding:24px 0;margin:0}.extra-products__divider[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center;padding:0 0 20px}.extra-products__divider-text[_ngcontent-%COMP%]{font-family:var(--font-body);font-size:16px;font-weight:700;color:#1a1a1a;letter-spacing:.5px}.extra-products__action[_ngcontent-%COMP%], .extra-products__footer[_ngcontent-%COMP%]{width:100%}@media(max-width:640px){.extra-products__title[_ngcontent-%COMP%]{font-size:20px}.extra-products__subtitle[_ngcontent-%COMP%]{font-size:13px;margin-bottom:20px}.extra-products__list[_ngcontent-%COMP%]{gap:12px;max-height:none}.extra-products__divider[_ngcontent-%COMP%]{padding-bottom:16px}}"],changeDetection:0})};export{rt as ExtraProductsDialogComponent};
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.