mealz-components 2.5.1 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/dist/assets/{OperatorSubscriber-BaYaQC1O.js → OperatorSubscriber-DfCnFunn.js} +1 -1
  2. package/dist/assets/{accordion-DJLqKUJq.js → accordion-sjJSL32r.js} +1 -1
  3. package/dist/assets/{args-BozZ6oU-.js → args-DAL2bHut.js} +1 -1
  4. package/dist/assets/{async-CFBGA-Dz.js → async-C5Kj_SqM.js} +1 -1
  5. package/dist/assets/{combineLatest-BmqPE0OB.js → combineLatest-Capvy1jI.js} +1 -1
  6. package/dist/assets/{debounceTime-B4DpnstH.js → debounceTime-Cf_7YmIn.js} +1 -1
  7. package/dist/assets/delay-DHNms76g.js +1 -0
  8. package/dist/assets/{distinctUntilChanged-91AVuO2B.js → distinctUntilChanged-kXqVrZ5h.js} +1 -1
  9. package/dist/assets/empty-qrpgDBbc.js +1 -0
  10. package/dist/assets/{filter-BZ75lS5D.js → filter-q99GWcpD.js} +1 -1
  11. package/dist/assets/firstValueFrom-Bcbk1SUg.js +1 -0
  12. package/dist/assets/{from-CAidt5N1.js → from-D8c5akO7.js} +1 -1
  13. package/dist/assets/guestObserver-C5qvv1Ll.js +1 -0
  14. package/dist/assets/{innerFrom-BgPDnAsH.js → innerFrom-DePszgj9.js} +1 -1
  15. package/dist/assets/isDate-BwHtzZM4.js +1 -0
  16. package/dist/assets/isScheduler-CqHuyMwD.js +1 -0
  17. package/dist/assets/{map-BVOhpQm0.js → map-DT-7dkaR.js} +1 -1
  18. package/dist/assets/mapOneOrManyArgs-CHGhEDCk.js +1 -0
  19. package/dist/assets/merge-DzIA6T0M.js +1 -0
  20. package/dist/assets/mergeAll-DpEYIxY3.js +1 -0
  21. package/dist/assets/{mergeMap-Dw_YYHwH.js → mergeMap-D2yctTHQ.js} +1 -1
  22. package/dist/assets/no-shadow-element-D62BBu0I.js +21 -0
  23. package/dist/assets/of-DtJFltSl.js +1 -0
  24. package/dist/assets/price-D6RVRYHJ.js +1 -0
  25. package/dist/assets/product-card-TLfT6URx.js +189 -0
  26. package/dist/assets/{promotion-badge-8Arhhb-p.js → promotion-badge-B-er7bV2.js} +1 -1
  27. package/dist/assets/{property-_7ObQ3dl.js → property-CoRN-Ln2.js} +1 -1
  28. package/dist/assets/singleton-COF3iBbF.js +1 -0
  29. package/dist/assets/skip-Bup0JB81.js +1 -0
  30. package/dist/assets/{skipWhile-BZVFq1Cg.js → skipWhile-Beza3ws3.js} +1 -1
  31. package/dist/assets/{state-W5mtSPAs.js → state-DDIoBQp5.js} +1 -1
  32. package/dist/assets/{switchMap-Dk_0Nhlo.js → switchMap-BAdE9Uzw.js} +1 -1
  33. package/dist/assets/{take-CozE9iSG.js → take-CpvJwza7.js} +1 -1
  34. package/dist/assets/{tap-C8CJ3R2H.js → tap-BN_fPb40.js} +1 -1
  35. package/dist/assets/timer-3Kpx74mt.js +1 -0
  36. package/dist/assets/{unsafe-html-CY0Np4--.js → unsafe-html-DWUMaK1p.js} +1 -1
  37. package/dist/assets/{viewport-listener-CDsKFDz1.js → viewport-listener-DsRHfwo4.js} +1 -1
  38. package/dist/basket-transfer-modal/basket-transfer-modal.min.js +1 -1
  39. package/dist/catalog/basket-preview/basket-preview.min.js +3 -3
  40. package/dist/catalog/catalog-category/catalog-category.min.js +1 -1
  41. package/dist/catalog/catalog-favorites/catalog-favorites.min.js +1 -1
  42. package/dist/catalog/catalog-history/catalog-history.min.js +1 -1
  43. package/dist/catalog/catalog-home/catalog-home.min.js +1 -1
  44. package/dist/catalog/catalog-home-header/catalog-home-header.min.js +1 -0
  45. package/dist/catalog/catalog-list/catalog-list.min.js +1 -1
  46. package/dist/catalog/catalog-load-more.min.js +1 -1
  47. package/dist/catalog/catalog-tabs/catalog-tabs.min.js +1 -1
  48. package/dist/catalog/catalog-toolbar/catalog-toolbar.min.js +1 -1
  49. package/dist/catalog/my-meals-button/my-meals-button.min.js +1 -1
  50. package/dist/counter/counter.min.js +3 -3
  51. package/dist/drawer/drawer.css +1 -1
  52. package/dist/drawer/drawer.min.js +4 -4
  53. package/dist/drawer-view-swapper/drawer-view-swapper.min.js +7 -7
  54. package/dist/history-drawer/history-drawer.min.js +1 -1
  55. package/dist/history-order/history-order.min.js +1 -1
  56. package/dist/history-order-expanded/history-order-expanded.min.js +1 -1
  57. package/dist/last-order-badge/last-order-badge.min.js +2 -2
  58. package/dist/last-order-modal/last-order-modal.min.js +1 -1
  59. package/dist/like-button/like-button.min.js +1 -1
  60. package/dist/modal/modal.min.js +1 -1
  61. package/dist/no-supplier-add-to-cart-cta/no-supplier-add-to-cart-cta.min.js +1 -1
  62. package/dist/onboarding/onboarding.min.js +1 -1
  63. package/dist/order-again/order-again.min.js +2 -2
  64. package/dist/planner/helpers/get-planner-onboarding-modal-config.min.js +1 -0
  65. package/dist/planner/helpers/init-planner-onboarding-modal.min.js +1 -0
  66. package/dist/planner/helpers/open-onboarding-modal.min.js +1 -1
  67. package/dist/planner/planner-abandon-modal/planner-abandon-modal.min.js +1 -1
  68. package/dist/planner/planner-budget-edit-modal/planner-budget-edit-modal.min.js +1 -1
  69. package/dist/planner/planner-budget-gauge/planner-budget-gauge.min.js +1 -1
  70. package/dist/planner/planner-catalog/planner-catalog.min.js +1 -1
  71. package/dist/planner/planner-current-menu/planner-current-menu.css +1 -1
  72. package/dist/planner/planner-current-menu/planner-current-menu.min.js +1 -1
  73. package/dist/planner/planner-current-menu-modal/planner-current-menu-modal.min.js +1 -1
  74. package/dist/planner/planner-dashboard/planner-dashboard.min.js +1 -1
  75. package/dist/planner/planner-form/planner-form.min.js +1 -1
  76. package/dist/planner/planner-menu-option/planner-menu-option.min.js +1 -1
  77. package/dist/planner/planner-onboarding/planner-onboarding.min.js +1 -1
  78. package/dist/planner/planner-onboarding-modal/planner-onboarding-modal.min.js +2 -2
  79. package/dist/planner/planner-open-catalog-modal/planner-open-catalog-modal.min.js +1 -1
  80. package/dist/planner/planner-quick-menu/planner-quick-menu.min.js +1 -1
  81. package/dist/planner/planner-recipe-card/planner-recipe-card.min.js +1 -1
  82. package/dist/planner/planner-recipe-list/planner-recipe-list.css +1 -1
  83. package/dist/planner/planner-recipe-list/planner-recipe-list.min.js +1 -1
  84. package/dist/planner/planner-recipe-suggestion/planner-recipe-suggestion.css +1 -1
  85. package/dist/planner/planner-recipe-suggestion/planner-recipe-suggestion.min.js +1 -1
  86. package/dist/planner/planner-welcome-modal/planner-welcome-modal.min.js +1 -1
  87. package/dist/planner/to-basket-loader/to-basket-loader.min.js +1 -1
  88. package/dist/planner-entry/planner-entry.css +1 -1
  89. package/dist/planner-entry/planner-entry.min.js +1 -1
  90. package/dist/preferences/preferences.min.js +1 -1
  91. package/dist/price/price.min.js +3 -3
  92. package/dist/product-badges/product-badges.css +1 -1
  93. package/dist/product-card/product-card.css +1 -1
  94. package/dist/products-to-basket-cta/products-to-basket-cta.css +1 -0
  95. package/dist/products-to-basket-cta/products-to-basket-cta.min.js +1 -0
  96. package/dist/recipe-card/recipe-card.min.js +1 -1
  97. package/dist/recipe-card-cta/recipe-card-cta.min.js +1 -1
  98. package/dist/recipe-details/recipe-details.css +1 -1
  99. package/dist/recipe-details/recipe-details.min.js +41 -43
  100. package/dist/recipe-pricing/recipe-pricing.min.js +1 -1
  101. package/dist/recipe-to-basket/recipe-to-basket.css +1 -0
  102. package/dist/recipe-to-basket/recipe-to-basket.min.js +1 -0
  103. package/dist/replace-item/replace-item-card/replace-item-card.min.js +1 -1
  104. package/dist/replace-item/replace-item.min.js +18 -18
  105. package/dist/replace-item-planner/replace-item-card-planner/replace-item-card-planner.min.js +1 -1
  106. package/dist/replace-item-planner/replace-item-planner.min.js +1 -1
  107. package/dist/select/select.min.js +1 -1
  108. package/dist/slider-tabs/slider-tabs.min.js +1 -1
  109. package/dist/store-indicator/store-indicator.min.js +1 -1
  110. package/dist/store-locator/store-locator.min.js +1 -1
  111. package/dist/store-locator-drawer/store-locator-drawer.min.js +1 -1
  112. package/dist/supplier-selector/supplier-selector.min.js +1 -1
  113. package/package.json +1 -1
  114. package/dist/assets/delay-BNnJ-6LE.js +0 -1
  115. package/dist/assets/empty-0eVnsLmk.js +0 -1
  116. package/dist/assets/isScheduler-C5PGPVU1.js +0 -1
  117. package/dist/assets/mapOneOrManyArgs-COA1aRZM.js +0 -1
  118. package/dist/assets/merge-Cm-mm3_Q.js +0 -1
  119. package/dist/assets/mergeAll-BdUAXyrs.js +0 -1
  120. package/dist/assets/no-shadow-element-YPHUv5PR.js +0 -21
  121. package/dist/assets/of-DiALp3BZ.js +0 -1
  122. package/dist/assets/price-DAxY_7sk.js +0 -1
  123. package/dist/assets/product-card-HetVhdJ3.js +0 -189
  124. package/dist/assets/skip-zbH-ayby.js +0 -1
  125. package/dist/assets/timer-D82-ik89.js +0 -1
@@ -1,4 +1,4 @@
1
- import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";import{_ as re,n as B,p as X,b as ne,c as oe,q as le,N as g,D as c,k as r}from"../assets/no-shadow-element-YPHUv5PR.js";import{t as v}from"../assets/custom-element-BhZVzxrc.js";import{n as p}from"../assets/property-_7ObQ3dl.js";import{P as ce}from"../assets/price-DAxY_7sk.js";import{m as o}from"../assets/mealz-sdk-E_fNZM-c.js";import{m as Z}from"../assets/merge-Cm-mm3_Q.js";import{m}from"../assets/map-BVOhpQm0.js";import{t as O}from"../assets/take-CozE9iSG.js";import{c as ee}from"../assets/capitalize-DUAqYmp4.js";import"../counter/counter.min.js";import{G as te}from"../assets/product-card-HetVhdJ3.js";import"../price/price.min.js";import"../assets/promotion-badge-8Arhhb-p.js";import"../assets/accordion-DJLqKUJq.js";import"../store-indicator/store-indicator.min.js";import"../last-order-badge/last-order-badge.min.js";import"../order-again/order-again.min.js";import"../like-button/like-button.min.js";import{L as de}from"../last-order-modal/last-order-modal.min.js";import{a as pe}from"../assets/unsafe-html-CY0Np4--.js";import{M as ue}from"../planner/planner-onboarding/planner-onboarding.min.js";import{o as se,c as he}from"../assets/OperatorSubscriber-BaYaQC1O.js";import{i as H}from"../assets/innerFrom-BgPDnAsH.js";import{f as Q}from"../assets/filter-BZ75lS5D.js";import{t as z}from"../assets/tap-C8CJ3R2H.js";import{s as Y}from"../assets/switchMap-Dk_0Nhlo.js";import{c as J}from"../assets/combineLatest-BmqPE0OB.js";import{d as me}from"../assets/async-CFBGA-Dz.js";import"../assets/viewport-listener-CDsKFDz1.js";import"../assets/debounceTime-B4DpnstH.js";import"../assets/skipWhile-BZVFq1Cg.js";import"../assets/mergeAll-BdUAXyrs.js";import"../assets/mergeMap-Dw_YYHwH.js";import"../assets/executeSchedule-CEDvgTzM.js";import"../assets/empty-0eVnsLmk.js";import"../assets/args-BozZ6oU-.js";import"../assets/isScheduler-C5PGPVU1.js";import"../assets/from-CAidt5N1.js";import"../assets/delay-BNnJ-6LE.js";import"../assets/timer-D82-ik89.js";import"../store-locator/store-locator.min.js";import"../assets/state-W5mtSPAs.js";import"../assets/query-BApjzB0v.js";import"../onboarding/onboarding.min.js";import"../onboarding/events.min.js";import"../onboarding/analytics/onboarding-analytics.min.js";import"../assets/responsive-C7Qf71r3.js";import"../assets/mapOneOrManyArgs-COA1aRZM.js";var ge=function(e){re(t,e);function t(s,a,i){s===void 0&&(s=1/0),a===void 0&&(a=1/0),i===void 0&&(i=me);var n=e.call(this)||this;return n._bufferSize=s,n._windowTime=a,n._timestampProvider=i,n._buffer=[],n._infiniteTimeWindow=!0,n._infiniteTimeWindow=a===1/0,n._bufferSize=Math.max(1,s),n._windowTime=Math.max(1,a),n}return t.prototype.next=function(s){var a=this,i=a.isStopped,n=a._buffer,l=a._infiniteTimeWindow,d=a._timestampProvider,u=a._windowTime;i||(n.push(s),!l&&n.push(d.now()+u)),this._trimBuffer(),e.prototype.next.call(this,s)},t.prototype._subscribe=function(s){this._throwIfClosed(),this._trimBuffer();for(var a=this._innerSubscribe(s),i=this,n=i._infiniteTimeWindow,l=i._buffer,d=l.slice(),u=0;u<d.length&&!s.closed;u+=n?1:2)s.next(d[u]);return this._checkFinalizedStatuses(s),a},t.prototype._trimBuffer=function(){var s=this,a=s._bufferSize,i=s._timestampProvider,n=s._buffer,l=s._infiniteTimeWindow,d=(l?1:2)*a;if(a<1/0&&d<n.length&&n.splice(0,n.length-d),!l){for(var u=i.now(),k=0,h=1;h<n.length&&n[h]<=u;h+=2)k=h;k&&n.splice(0,k+1)}},t}(B);function ve(e){e===void 0&&(e={});var t=e.connector,s=t===void 0?function(){return new B}:t,a=e.resetOnError,i=a===void 0?!0:a,n=e.resetOnComplete,l=n===void 0?!0:n,d=e.resetOnRefCountZero,u=d===void 0?!0:d;return function(k){var h,f,I,T=0,w=!1,S=!1,C=function(){f==null||f.unsubscribe(),f=void 0},U=function(){C(),h=I=void 0,w=S=!1},ae=function(){var P=h;U(),P==null||P.unsubscribe()};return se(function(P,K){T++,!S&&!w&&C();var x=I=I??s();K.add(function(){T--,T===0&&!S&&!w&&(f=A(ae,u))}),x.subscribe(K),!h&&T>0&&(h=new X({next:function(R){return x.next(R)},error:function(R){S=!0,C(),f=A(U,i,R),x.error(R)},complete:function(){w=!0,C(),f=A(U,l),x.complete()}}),H(P).subscribe(h))})(k)}}function A(e,t){for(var s=[],a=2;a<arguments.length;a++)s[a-2]=arguments[a];if(t===!0){e();return}if(t!==!1){var i=new X({next:function(){i.unsubscribe(),e()}});return H(t.apply(void 0,ne([],oe(s)))).subscribe(i)}}function be(e,t,s){var a,i=!1;return a=e,ve({connector:function(){return new ge(a,t,s)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:i})}function D(e){return se(function(t,s){H(e).subscribe(he(s,function(){return s.complete()},le)),!s.closed&&t.subscribe(s)})}var _e=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,y=(e,t,s,a)=>{for(var i=a>1?void 0:a?fe(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=(a?l(t,s,i):l(i))||i);return a&&i&&_e(t,s,i),i};let b=class extends g{constructor(){super(),this.noPosDisplay=!1,this.noSupplier=!1,this.recipeId="",this.plannerMode=!1,this.guests=0,this.recipe=null,this.analyticsPath="",this.subscriptions=[],this.remainingBasketEntries=[],this.recipePrice={remaining:0,inBasket:0,total:0,totalPerGuest:0},this.priceService=ce.getInstance(),this.allIngredientsToBasketLoading=!1,this.ingredientToBasketLoading=!1,this.updateIngredientFromBasketLoading=!1,this.productsLoading=!1,this.inMenu=!1,this.menuUpdateLoading=!1,this.styleURL=new URL("./recipe-details/details-footer/details-footer.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.priceService.initFormatter(),this.analyticsPath=`/recipes/${this.recipeId}/shopping`,this.subscriptions.push(Z(o.recipes.remainingBasketEntries$.pipe(m(e=>{this.remainingBasketEntries=e})),o.recipes.recipePrice$.pipe(m(e=>{const t=e.remaining+e.inBasket;this.recipePrice={...e,total:t,totalPerGuest:0}})),o.recipes.allIngredientsToBasketLoading$.pipe(m(e=>{this.allIngredientsToBasketLoading=e})),o.recipes.ingredientToBasketLoading$.pipe(m(e=>{this.ingredientToBasketLoading=e})),o.recipes.updateIngredientFromBasketLoading$.pipe(m(e=>{this.updateIngredientFromBasketLoading=e})),o.recipes.productsLoading$.pipe(m(e=>{this.productsLoading=e})),o.planner.plannerRecipePrice$.pipe(m(e=>{this.recipePrice.totalPerGuest=this.guests>0?e/this.guests:e}))).subscribe(()=>this.requestUpdate())),this.subscribeIsRecipeInMenu()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe()),this.isRecipeInMenuSub&&(this.isRecipeInMenuSub.unsubscribe(),this.isRecipeInMenuSub=void 0)}updated(e){super.updated(e),e.has("recipeId")&&this.subscribeIsRecipeInMenu()}subscribeIsRecipeInMenu(){this.recipeId&&(this.isRecipeInMenuSub&&this.isRecipeInMenuSub.unsubscribe(),this.isRecipeInMenuSub=o.planner.isRecipeInMenu$(this.recipeId).pipe(m(e=>{this.inMenu=e})).subscribe(()=>this.requestUpdate()))}closeRecipeDetails(e=!1){o.recipes.displayedRecipe$.next(null),e&&o.basket.basketPreviewState$.next({isOpen:!0,activeTabIndex:o.basket.basketPreviewState$.getValue().activeTabIndex})}continueShopping(){this.closeRecipeDetails(),this.sendContinueEvent()}addToMenu(){o.hook.hookCallback().pipe(O(1)).subscribe(e=>{var i,n;if(!e)return;this.menuUpdateLoading=!0,this.requestUpdate();const t=document.querySelector("mealz-planner-recipe-suggestion"),s=!!t&&!!t.recipeId&&t.recipeId===this.recipeId,a=document.querySelector("mealz-planner-current-menu");if(!a){const l=(n=(i=o.recipes)==null?void 0:i.productsPlannerByCategory$)==null?void 0:n.value,d=(l==null?void 0:l.toPickProducts)||[];o.planner.addRecipeToMenu(this.recipeId,this.guests,!!o.pos.currentPos().value,d).pipe(O(1)).subscribe(()=>{this.inMenu=!0;const u=document.querySelector("mealz-planner-recipe-list");u==null||u.addRecipeCardToList(this.recipeId),this.menuUpdateLoading=!1,this.requestUpdate(),this.closeRecipeDetails()});return}if(s){t.addRecipeFromDetails$(this.guests).subscribe({next:()=>{this.inMenu=!0,this.menuUpdateLoading=!1,this.requestUpdate(),this.closeRecipeDetails()},error:()=>{this.menuUpdateLoading=!1,this.requestUpdate()}});return}a.addRecipe(this.recipeId,this.guests).pipe(O(1)).subscribe({next:()=>{this.inMenu=!0,t==null||t.addAndSelectNewSuggestion(this.recipe||void 0),this.menuUpdateLoading=!1,this.requestUpdate(),this.closeRecipeDetails()},error:()=>{this.menuUpdateLoading=!1,this.requestUpdate()}})})}removeFromMenu(){this.menuUpdateLoading=!0,this.requestUpdate();const e=document.querySelector("mealz-planner-recipe-suggestion");if(!e){o.planner.removeRecipeFromMenu(this.recipeId).pipe(O(1)).subscribe(()=>{this.inMenu=!1,this.menuUpdateLoading=!1,this.requestUpdate()});return}e.removeRecipe(this.recipeId).subscribe(()=>{this.inMenu=!1,this.menuUpdateLoading=!1,this.requestUpdate()})}addAllIngredients(){o.recipes.addAllIngredientsToBasket({originPath:this.analyticsPath,props:{}}),this.sendAddAllEvent(),this.recipePrice.inBasket===0&&this.sendAddRecipeEvent()}render(){if(this.noPosDisplay&&!this.plannerMode)return c;const e=this.remainingBasketEntries.length>0&&!this.plannerMode,t=this.plannerMode&&this.noPosDisplay,s=this.plannerMode&&!this.inMenu;return r`
1
+ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";import{_ as re,n as D,p as X,b as ne,c as oe,q as le,N as $,D as c,k as r}from"../assets/no-shadow-element-D62BBu0I.js";import{t as k}from"../assets/custom-element-BhZVzxrc.js";import{n as h}from"../assets/property-CoRN-Ln2.js";import{P as ce}from"../assets/price-D6RVRYHJ.js";import{m as o}from"../assets/mealz-sdk-E_fNZM-c.js";import{m as Z}from"../assets/merge-DzIA6T0M.js";import{m as y}from"../assets/map-DT-7dkaR.js";import{t as L}from"../assets/take-CpvJwza7.js";import{c as ee}from"../assets/capitalize-DUAqYmp4.js";import"../counter/counter.min.js";import"../assets/product-card-TLfT6URx.js";import"../price/price.min.js";import"../assets/promotion-badge-B-er7bV2.js";import{G as te}from"../assets/guestObserver-C5qvv1Ll.js";import"../assets/accordion-sjJSL32r.js";import"../store-indicator/store-indicator.min.js";import"../last-order-badge/last-order-badge.min.js";import"../order-again/order-again.min.js";import"../like-button/like-button.min.js";import{L as de}from"../last-order-modal/last-order-modal.min.js";import{a as pe}from"../assets/unsafe-html-DWUMaK1p.js";import{M as ue}from"../planner/planner-onboarding/planner-onboarding.min.js";import{o as se,c as he}from"../assets/OperatorSubscriber-DfCnFunn.js";import{i as H}from"../assets/innerFrom-DePszgj9.js";import{f as Q}from"../assets/filter-q99GWcpD.js";import{t as T}from"../assets/tap-BN_fPb40.js";import{s as Y}from"../assets/switchMap-BAdE9Uzw.js";import{c as J}from"../assets/combineLatest-Capvy1jI.js";import{d as me}from"../assets/async-C5Kj_SqM.js";import"../assets/viewport-listener-DsRHfwo4.js";import"../assets/debounceTime-Cf_7YmIn.js";import"../assets/skipWhile-Beza3ws3.js";import"../assets/singleton-COF3iBbF.js";import"../assets/mergeAll-DpEYIxY3.js";import"../assets/mergeMap-D2yctTHQ.js";import"../assets/executeSchedule-CEDvgTzM.js";import"../assets/empty-qrpgDBbc.js";import"../assets/args-DAL2bHut.js";import"../assets/isScheduler-CqHuyMwD.js";import"../assets/from-D8c5akO7.js";import"../assets/delay-DHNms76g.js";import"../assets/timer-3Kpx74mt.js";import"../assets/isDate-BwHtzZM4.js";import"../store-locator/store-locator.min.js";import"../assets/state-DDIoBQp5.js";import"../assets/query-BApjzB0v.js";import"../onboarding/onboarding.min.js";import"../onboarding/events.min.js";import"../onboarding/analytics/onboarding-analytics.min.js";import"../assets/responsive-C7Qf71r3.js";import"../assets/mapOneOrManyArgs-CHGhEDCk.js";var ge=function(e){re(t,e);function t(s,a,i){s===void 0&&(s=1/0),a===void 0&&(a=1/0),i===void 0&&(i=me);var n=e.call(this)||this;return n._bufferSize=s,n._windowTime=a,n._timestampProvider=i,n._buffer=[],n._infiniteTimeWindow=!0,n._infiniteTimeWindow=a===1/0,n._bufferSize=Math.max(1,s),n._windowTime=Math.max(1,a),n}return t.prototype.next=function(s){var a=this,i=a.isStopped,n=a._buffer,l=a._infiniteTimeWindow,d=a._timestampProvider,u=a._windowTime;i||(n.push(s),!l&&n.push(d.now()+u)),this._trimBuffer(),e.prototype.next.call(this,s)},t.prototype._subscribe=function(s){this._throwIfClosed(),this._trimBuffer();for(var a=this._innerSubscribe(s),i=this,n=i._infiniteTimeWindow,l=i._buffer,d=l.slice(),u=0;u<d.length&&!s.closed;u+=n?1:2)s.next(d[u]);return this._checkFinalizedStatuses(s),a},t.prototype._trimBuffer=function(){var s=this,a=s._bufferSize,i=s._timestampProvider,n=s._buffer,l=s._infiniteTimeWindow,d=(l?1:2)*a;if(a<1/0&&d<n.length&&n.splice(0,n.length-d),!l){for(var u=i.now(),g=0,p=1;p<n.length&&n[p]<=u;p+=2)g=p;g&&n.splice(0,g+1)}},t}(D);function ve(e){e===void 0&&(e={});var t=e.connector,s=t===void 0?function(){return new D}:t,a=e.resetOnError,i=a===void 0?!0:a,n=e.resetOnComplete,l=n===void 0?!0:n,d=e.resetOnRefCountZero,u=d===void 0?!0:d;return function(g){var p,m,v,b=0,_=!1,f=!1,z=function(){m==null||m.unsubscribe(),m=void 0},A=function(){z(),p=v=void 0,_=f=!1},ae=function(){var w=p;A(),w==null||w.unsubscribe()};return se(function(w,K){b++,!f&&!_&&z();var R=v=v??s();K.add(function(){b--,b===0&&!f&&!_&&(m=U(ae,u))}),R.subscribe(K),!p&&b>0&&(p=new X({next:function(x){return R.next(x)},error:function(x){f=!0,z(),m=U(A,i,x),R.error(x)},complete:function(){_=!0,z(),m=U(A,l),R.complete()}}),H(w).subscribe(p))})(g)}}function U(e,t){for(var s=[],a=2;a<arguments.length;a++)s[a-2]=arguments[a];if(t===!0){e();return}if(t!==!1){var i=new X({next:function(){i.unsubscribe(),e()}});return H(t.apply(void 0,ne([],oe(s)))).subscribe(i)}}function be(e,t,s){var a,i=!1;return a=e,ve({connector:function(){return new ge(a,t,s)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:i})}function O(e){return se(function(t,s){H(e).subscribe(he(s,function(){return s.complete()},le)),!s.closed&&t.subscribe(s)})}var _e=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,E=(e,t,s,a)=>{for(var i=a>1?void 0:a?fe(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=(a?l(t,s,i):l(i))||i);return a&&i&&_e(t,s,i),i};let I=class extends ${constructor(){super(),this.noPosDisplay=!1,this.noSupplier=!1,this.recipeId="",this.plannerMode=!1,this.guests=0,this.recipe=null,this.analyticsPath="",this.subscriptions=[],this.remainingBasketEntries=[],this.recipePrice={remaining:0,inBasket:0,total:0,totalPerGuest:0},this.priceService=ce.getInstance(),this.allIngredientsToBasketLoading=!1,this.ingredientToBasketLoading=!1,this.updateIngredientFromBasketLoading=!1,this.productsLoading=!1,this.inMenu=!1,this.menuUpdateLoading=!1,this.styleURL=new URL("./recipe-details/details-footer/details-footer.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.priceService.initFormatter(),this.analyticsPath=`/recipes/${this.recipeId}/shopping`,this.subscriptions.push(Z(o.recipes.remainingBasketEntries$.pipe(y(e=>{this.remainingBasketEntries=e})),o.recipes.recipePrice$.pipe(y(e=>{const t=e.remaining+e.inBasket;this.recipePrice={...e,total:t,totalPerGuest:0}})),o.recipes.allIngredientsToBasketLoading$.pipe(y(e=>{this.allIngredientsToBasketLoading=e})),o.recipes.ingredientToBasketLoading$.pipe(y(e=>{this.ingredientToBasketLoading=e})),o.recipes.updateIngredientFromBasketLoading$.pipe(y(e=>{this.updateIngredientFromBasketLoading=e})),o.recipes.productsLoading$.pipe(y(e=>{this.productsLoading=e})),o.planner.plannerRecipePrice$.pipe(y(e=>{this.recipePrice.totalPerGuest=this.guests>0?e/this.guests:e}))).subscribe(()=>this.requestUpdate())),this.subscribeIsRecipeInMenu()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe()),this.isRecipeInMenuSub&&(this.isRecipeInMenuSub.unsubscribe(),this.isRecipeInMenuSub=void 0)}updated(e){super.updated(e),e.has("recipeId")&&this.subscribeIsRecipeInMenu()}subscribeIsRecipeInMenu(){this.recipeId&&(this.isRecipeInMenuSub&&this.isRecipeInMenuSub.unsubscribe(),this.isRecipeInMenuSub=o.planner.isRecipeInMenu$(this.recipeId).pipe(y(e=>{this.inMenu=e})).subscribe(()=>this.requestUpdate()))}closeRecipeDetails(e=!1){o.recipes.displayedRecipe$.next(null),e&&o.basket.basketPreviewState$.next({isOpen:!0,activeTabIndex:o.basket.basketPreviewState$.getValue().activeTabIndex})}continueShopping(){this.closeRecipeDetails(),this.sendContinueEvent()}addToMenu(){var a,i;this.menuUpdateLoading=!0,this.requestUpdate();const e=document.querySelector("mealz-planner-recipe-suggestion"),t=!!e&&!!e.recipeId&&e.recipeId===this.recipeId,s=document.querySelector("mealz-planner-current-menu");if(!s){const n=(i=(a=o.recipes)==null?void 0:a.productsPlannerByCategory$)==null?void 0:i.value,l=(n==null?void 0:n.toPickProducts)||[];o.planner.addRecipeToMenu(this.recipeId,this.guests,!!o.pos.currentPos().value,l).pipe(L(1)).subscribe(()=>{this.inMenu=!0;const d=document.querySelector("mealz-planner-recipe-list");d==null||d.addRecipeCardToList(this.recipeId),this.menuUpdateLoading=!1,this.requestUpdate(),this.closeRecipeDetails()});return}if(t){e.addRecipeFromDetails$(this.guests).subscribe({next:()=>{this.inMenu=!0,this.menuUpdateLoading=!1,this.requestUpdate(),this.closeRecipeDetails()},error:()=>{this.menuUpdateLoading=!1,this.requestUpdate()}});return}s.addRecipe(this.recipeId,this.guests).pipe(L(1)).subscribe({next:()=>{this.inMenu=!0,e==null||e.addAndSelectNewSuggestion(this.recipe||void 0),this.menuUpdateLoading=!1,this.requestUpdate(),this.closeRecipeDetails()},error:()=>{this.menuUpdateLoading=!1,this.requestUpdate()}})}removeFromMenu(){this.menuUpdateLoading=!0,this.requestUpdate();const e=document.querySelector("mealz-planner-recipe-suggestion");if(!e){o.planner.removeRecipeFromMenu(this.recipeId).pipe(L(1)).subscribe(()=>{this.inMenu=!1,this.menuUpdateLoading=!1,this.requestUpdate()});return}e.removeRecipe(this.recipeId).subscribe(()=>{this.inMenu=!1,this.menuUpdateLoading=!1,this.requestUpdate()})}addAllIngredients(){o.recipes.addAllIngredientsToBasket({originPath:this.analyticsPath,props:{}}),this.sendAddAllEvent(),this.recipePrice.inBasket===0&&this.sendAddRecipeEvent()}render(){if(this.noPosDisplay&&!this.plannerMode)return c;const e=this.remainingBasketEntries.length>0&&!this.plannerMode,t=this.plannerMode&&this.noPosDisplay,s=this.plannerMode&&!this.inMenu;return r`
2
2
  <div class="mealz-recipe-details__footer">
3
3
  ${this.productsLoading&&!this.plannerMode?c:r`
4
4
  <!-- ADD TO BASKET CTA -->
@@ -10,12 +10,12 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
10
10
  `}
11
11
  ${this.noPosDisplay?c:this.renderPrice()}
12
12
  </div>`}renderAddToBasketButton(){const e=this.remainingBasketEntries.length;return this.allIngredientsToBasketLoading||this.menuUpdateLoading?r`
13
- <button class="mealz-recipe-details__add-to-basket-cta mealz-ds-button primary">
13
+ <button class="mealz-recipe-details__add-to-basket-cta mealz-recipe-details__add-to-basket-cta--loading mealz-ds-button primary">
14
14
  <div class="mealz-ds-loader"></div>
15
15
  </button>
16
16
  `:this.plannerMode?r`
17
17
  <button
18
- class="mealz-recipe-details__add-to-basket-cta mealz-ds-button primary"
18
+ class="mealz-recipe-details__add-to-basket-cta mealz-recipe-details__add-to-basket-cta--to-menu mealz-ds-button primary"
19
19
  @click=${()=>this.addToMenu()}
20
20
  >
21
21
  <span class="mealz-ds-text size-s weight-xl">Ajouter au menu</span>
@@ -23,7 +23,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
23
23
  </button>
24
24
  `:r`
25
25
  <button
26
- class="mealz-recipe-details__add-to-basket-cta mealz-ds-text mealz-ds-button size-m weight-xl primary"
26
+ class="mealz-recipe-details__add-to-basket-cta mealz-recipe-details__add-to-basket-cta--to-basket mealz-ds-text mealz-ds-button size-m weight-xl primary"
27
27
  @click=${()=>this.addAllIngredients()}
28
28
  >
29
29
  <img
@@ -91,7 +91,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
91
91
  ${this.plannerMode?"par personne":"dans votre panier"}
92
92
  </span>
93
93
  </div>
94
- `}sendAddAllEvent(){o.analytics.sendEvent("entry.add-all",this.analyticsPath,{recipe_id:this.recipeId,entry_count:this.remainingBasketEntries.length})}sendAddRecipeEvent(){o.analytics.sendEvent("recipe.add",this.analyticsPath,{recipe_id:this.recipeId})}sendContinueEvent(){o.analytics.sendEvent("recipe.continue",this.analyticsPath,{recipe_id:this.recipeId})}};y([p({type:Boolean})],b.prototype,"noPosDisplay",2);y([p({type:Boolean})],b.prototype,"noSupplier",2);y([p({type:String})],b.prototype,"recipeId",2);y([p({type:Boolean})],b.prototype,"plannerMode",2);y([p({type:Number})],b.prototype,"guests",2);y([p({attribute:!1})],b.prototype,"recipe",2);b=y([v("mealz-details-footer")],b);customElements.get("mealz-details-footer")||customElements.define("mealz-details-footer",b);var ze=Object.getOwnPropertyDescriptor,ye=(e,t,s,a)=>{for(var i=a>1?void 0:a?ze(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let N=class extends g{constructor(){super(),this.tags=[],this.displayTags=!1,this.subscriptions=[],this.styleURL=new URL("./recipe-details/details-infos/details-infos.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(o.recipes.displayedRecipe$.subscribe(e=>{e&&(this.recipe=e.recipe,this.tags=e.recipe.relationships.tags.data.map(t=>t.attributes.name),this.requestUpdate())}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}toggleTags(){this.displayTags=!this.displayTags,this.requestUpdate()}noTimePlaceholder(){return r`<span class="mealz-recipe-details-infos__no-time-placeholder">0 min</span>`}noDataPlaceholder(){return r`<span class="mealz-recipe-details-infos__no-data-placeholder">-</span>`}getRecipeDifficultyIntoClassName(){switch(this.recipe.attributes.difficulty){case 1:return"easy";case 2:return"medium";case 3:return"hard";default:return"no-difficulty-defined"}}getRecipeDifficultyIntoText(){switch(this.recipe.attributes.difficulty){case 1:return r`<span class="mealz-ds-text">Facile</span>`;case 2:return r`<span class="mealz-ds-text">Moyen</span>`;case 3:return r`<span class="mealz-ds-text">Difficile</span>`;default:return c}}renderPreparationTime(){return r`
94
+ `}sendAddAllEvent(){o.analytics.sendEvent("entry.add-all",this.analyticsPath,{recipe_id:this.recipeId,entry_count:this.remainingBasketEntries.length})}sendAddRecipeEvent(){o.analytics.sendEvent("recipe.add",this.analyticsPath,{recipe_id:this.recipeId})}sendContinueEvent(){o.analytics.sendEvent("recipe.continue",this.analyticsPath,{recipe_id:this.recipeId})}};E([h({type:Boolean})],I.prototype,"noPosDisplay",2);E([h({type:Boolean})],I.prototype,"noSupplier",2);E([h({type:String})],I.prototype,"recipeId",2);E([h({type:Boolean})],I.prototype,"plannerMode",2);E([h({type:Number})],I.prototype,"guests",2);E([h({attribute:!1})],I.prototype,"recipe",2);I=E([k("mealz-details-footer")],I);customElements.get("mealz-details-footer")||customElements.define("mealz-details-footer",I);var ze=Object.getOwnPropertyDescriptor,ye=(e,t,s,a)=>{for(var i=a>1?void 0:a?ze(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let N=class extends ${constructor(){super(),this.tags=[],this.displayTags=!1,this.subscriptions=[],this.styleURL=new URL("./recipe-details/details-infos/details-infos.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(o.recipes.displayedRecipe$.subscribe(e=>{e&&(this.recipe=e.recipe,this.tags=e.recipe.relationships.tags.data.map(t=>t.attributes.name),this.requestUpdate())}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}toggleTags(){this.displayTags=!this.displayTags,this.requestUpdate()}noTimePlaceholder(){return r`<span class="mealz-recipe-details-infos__no-time-placeholder">0 min</span>`}noDataPlaceholder(){return r`<span class="mealz-recipe-details-infos__no-data-placeholder">-</span>`}getRecipeDifficultyIntoClassName(){switch(this.recipe.attributes.difficulty){case 1:return"easy";case 2:return"medium";case 3:return"hard";default:return"no-difficulty-defined"}}getRecipeDifficultyIntoText(){switch(this.recipe.attributes.difficulty){case 1:return r`<span class="mealz-ds-text">Facile</span>`;case 2:return r`<span class="mealz-ds-text">Moyen</span>`;case 3:return r`<span class="mealz-ds-text">Difficile</span>`;default:return c}}renderPreparationTime(){return r`
95
95
  <!-- PREPARATION TIME -->
96
96
  <div
97
97
  class="
@@ -157,7 +157,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
157
157
  ${this.renderRecipeDifficulty()}
158
158
  ${this.renderMoreTags()}
159
159
  </div>
160
- `}};N=ye([v("mealz-details-infos")],N);customElements.get("mealz-details-infos")||customElements.define("mealz-details-infos",N);var $e=Object.getOwnPropertyDescriptor,ke=(e,t,s,a)=>{for(var i=a>1?void 0:a?$e(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let q=class extends g{constructor(){super(),this.steps=[],this.subscriptions=[],this.styleURL=new URL("./recipe-details/details-steps/details-steps.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(o.recipes.displayedRecipe$.subscribe(e=>{e&&(this.steps=e.recipe.relationships["recipe-steps"].data.sort((t,s)=>t.attributes["step-number"]-s.attributes["step-number"]).map(t=>t.attributes.description),this.requestUpdate())}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}render(){return r`
160
+ `}};N=ye([k("mealz-details-infos")],N);customElements.get("mealz-details-infos")||customElements.define("mealz-details-infos",N);var $e=Object.getOwnPropertyDescriptor,ke=(e,t,s,a)=>{for(var i=a>1?void 0:a?$e(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let q=class extends ${constructor(){super(),this.steps=[],this.subscriptions=[],this.styleURL=new URL("./recipe-details/details-steps/details-steps.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(o.recipes.displayedRecipe$.subscribe(e=>{e&&(this.steps=e.recipe.relationships["recipe-steps"].data.sort((t,s)=>t.attributes["step-number"]-s.attributes["step-number"]).map(t=>t.attributes.description),this.requestUpdate())}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}render(){return r`
161
161
  <div class="mealz-details-steps">
162
162
  <!-- HEADER -->
163
163
  <div class="mealz-ds-text weight-xxl mealz-details-steps__header">
@@ -180,7 +180,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
180
180
  `)}
181
181
  </div>
182
182
  </div>
183
- `}};q=ke([v("mealz-details-steps")],q);customElements.get("mealz-details-steps")||customElements.define("mealz-details-steps",q);var Ie=Object.getOwnPropertyDescriptor,Pe=(e,t,s,a)=>{for(var i=a>1?void 0:a?Ie(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let G=class extends g{constructor(){super(),this.ingredients=[],this.subscriptions=[],this.styleURL=new URL("./recipe-details/details-ingredients/details-ingredients.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(o.recipes.displayedRecipe$.subscribe(e=>{e&&(this.ingredients=e.recipe.relationships.ingredients.data,this.requestUpdate())}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}render(){var e,t;return r`
183
+ `}};q=ke([k("mealz-details-steps")],q);customElements.get("mealz-details-steps")||customElements.define("mealz-details-steps",q);var Ie=Object.getOwnPropertyDescriptor,Pe=(e,t,s,a)=>{for(var i=a>1?void 0:a?Ie(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let G=class extends ${constructor(){super(),this.ingredients=[],this.subscriptions=[],this.styleURL=new URL("./recipe-details/details-ingredients/details-ingredients.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(o.recipes.displayedRecipe$.subscribe(e=>{e&&(this.ingredients=e.recipe.relationships.ingredients.data,this.requestUpdate())}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}render(){var e,t;return r`
184
184
  <div class="mealz-details-ingredients">
185
185
  <!-- HEADER -->
186
186
  <div class="mealz-ds-text weight-xxl mealz-details-ingredients__header">
@@ -209,7 +209,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
209
209
  `)}
210
210
  </div>
211
211
  </div>
212
- `}ingredientPicture(e){return e.picture||"https://storage.googleapis.com/assets.miam.tech/generic/images/default-ingredient-picture.svg"}};G=Pe([v("mealz-details-ingredients")],G);customElements.get("mealz-details-ingredients")||customElements.define("mealz-details-ingredients",G);var Ee=Object.defineProperty,Te=Object.getOwnPropertyDescriptor,$=(e,t,s,a)=>{for(var i=a>1?void 0:a?Te(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=(a?l(t,s,i):l(i))||i);return a&&i&&Ee(t,s,i),i};const M=["unavailable"],we=["ticked","unselected"];let _=class extends g{constructor(){super(),this.subscriptions=[],this.guestObserverService=te.getInstance(),this.modifiedIngQty=0,this.analyticsPath="/meals-planner/current",this.styleURL=new URL("./product-card/product-card-planner.css",this.getBaseURL())}get status(){var e;return(e=this.product)==null?void 0:e.status}set status(e){this.product.status=e,this.requestUpdate()}get productImage(){var e;return((e=this.product.item)==null?void 0:e.attributes.image)||"https://storage.googleapis.com/assets.miam.tech/generic/images/default-ingredient-picture.svg"}get ingredientPicture(){return this.product.ingredient.picture||"https://storage.googleapis.com/assets.miam.tech/generic/images/default-ingredient-picture.svg"}get isSponsored(){var e,t,s;return((s=(t=(e=this.product)==null?void 0:e.item)==null?void 0:t.attributes)==null?void 0:s.sponsored)===!0}connectedCallback(){super.connectedCallback(),this.listenGuestsChange(),this.calculateQty()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}listenGuestsChange(){this.subscriptions.push(this.guestObserverService.guests$.subscribe(e=>{this.currentGuests=e,this.calculateQty()}))}calculateQty(){const e=this.product.ingredient.attributes.quantity/this.initialGuests;this.modifiedIngQty=Number((e*this.currentGuests).toFixed(2)),this.requestUpdate()}openReplaceItemView(){o.planner.openReplaceItemView(this.product),this.replaceItemViewEvent()}onCheckboxChange(e){e.target.checked?(this.status="ticked",o.planner.selectProduct(+this.product.item.id,this.product.ingredient.relationships.definition.data.id),this.addItemEvent()):(this.status="unselected",o.planner.unselectProduct(+this.product.item.id,this.product.ingredient.relationships.definition.data.id),this.deleteItemEvent()),this.requestUpdate()}render(){return r`
212
+ `}ingredientPicture(e){return e.picture||"https://storage.googleapis.com/assets.miam.tech/generic/images/default-ingredient-picture.svg"}};G=Pe([k("mealz-details-ingredients")],G);customElements.get("mealz-details-ingredients")||customElements.define("mealz-details-ingredients",G);var Te=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,S=(e,t,s,a)=>{for(var i=a>1?void 0:a?Ee(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=(a?l(t,s,i):l(i))||i);return a&&i&&Te(t,s,i),i};const M=["unavailable"],Se=["ticked","unselected"];let P=class extends ${constructor(){super(),this.recipeId="",this.initialGuests=0,this.currentGuests=0,this.oftenIgnored=!1,this.subscriptions=[],this.guestObserverService=te.getInstance(),this.modifiedIngQty=0,this.analyticsPath="/meals-planner/current",this.styleURL=new URL("./product-card/product-card-planner.css",this.getBaseURL())}get status(){var e;return(e=this.product)==null?void 0:e.status}set status(e){this.product.status=e,this.requestUpdate()}get productImage(){var e;return((e=this.product.item)==null?void 0:e.attributes.image)||"https://storage.googleapis.com/assets.miam.tech/generic/images/default-ingredient-picture.svg"}get ingredientPicture(){return this.product.ingredient.picture||"https://storage.googleapis.com/assets.miam.tech/generic/images/default-ingredient-picture.svg"}get isSponsored(){var e,t,s;return((s=(t=(e=this.product)==null?void 0:e.item)==null?void 0:t.attributes)==null?void 0:s.sponsored)===!0}connectedCallback(){super.connectedCallback(),this.listenGuestsChange(),this.calculateQty()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}listenGuestsChange(){this.subscriptions.push(this.guestObserverService.guests$.subscribe(e=>{this.currentGuests=e,this.calculateQty()}))}calculateQty(){const e=this.product.ingredient.attributes.quantity/this.initialGuests;this.modifiedIngQty=Number((e*this.currentGuests).toFixed(2)),this.requestUpdate()}openReplaceItemView(){o.planner.openReplaceItemView(this.product),this.replaceItemViewEvent()}onCheckboxChange(e){e.target.checked?(this.status="ticked",o.planner.selectProduct(+this.product.item.id,this.product.ingredient.relationships.definition.data.id),this.addItemEvent()):(this.status="unselected",o.planner.unselectProduct(+this.product.item.id,this.product.ingredient.relationships.definition.data.id),this.deleteItemEvent()),this.requestUpdate()}render(){return r`
213
213
  <div class="mealz-product-card-planner
214
214
  ${this.status==="ticked"?"added":""}
215
215
  ${M.includes(this.status)||this.oftenIgnored?"disabled":""}
@@ -220,7 +220,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
220
220
  ${this.oftenIgnored?"disabled":""}
221
221
  ${this.status==="unavailable"?"unavailable":""}"
222
222
  >
223
- ${we.includes(this.status)&&!this.oftenIgnored?this.renderEnabledProductCard():this.renderDisabledOrUnavailableProduct()}
223
+ ${Se.includes(this.status)&&!this.oftenIgnored?this.renderEnabledProductCard():this.renderDisabledOrUnavailableProduct()}
224
224
  </div>
225
225
  </div>
226
226
  `}renderEnabledProductCard(){return r`
@@ -318,7 +318,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
318
318
  <span>Remplacer</span>
319
319
  </button>
320
320
  `:""}
321
- `}addItemEvent(){o.analytics.sendEvent("planner.item.add",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}deleteItemEvent(){o.analytics.sendEvent("planner.item.delete",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}replaceItemViewEvent(){o.analytics.sendEvent("planner.item.replace",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}};$([p({type:Object})],_.prototype,"product",2);$([p({type:String})],_.prototype,"recipeId",2);$([p({type:Number})],_.prototype,"initialGuests",2);$([p({type:Number})],_.prototype,"currentGuests",2);$([p({type:Boolean})],_.prototype,"oftenIgnored",2);_=$([v("mealz-product-card-planner")],_);customElements.get("mealz-product-card-planner")||customElements.define("mealz-product-card-planner",_);var Se=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,ie=(e,t,s,a)=>{for(var i=a>1?void 0:a?Ce(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=(a?l(t,s,i):l(i))||i);return a&&i&&Se(t,s,i),i};let L=class extends g{constructor(){super(),this.styleURL=new URL("./legal-notice/legal-notice.css",this.getBaseURL())}get containsAlcohol(){var t;return(((t=this.tags)==null?void 0:t.data)||[]).some(s=>s.id==="ingredient_category_alcool")}render(){return this.containsAlcohol?r`
321
+ `}addItemEvent(){o.analytics.sendEvent("planner.item.add",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}deleteItemEvent(){o.analytics.sendEvent("planner.item.delete",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}replaceItemViewEvent(){o.analytics.sendEvent("planner.item.replace",this.analyticsPath,{recipe_id:this.recipeId,item_id:this.product.item.id})}};S([h({type:Object})],P.prototype,"product",2);S([h({type:String})],P.prototype,"recipeId",2);S([h({type:Number})],P.prototype,"initialGuests",2);S([h({type:Number})],P.prototype,"currentGuests",2);S([h({type:Boolean})],P.prototype,"oftenIgnored",2);P=S([k("mealz-product-card-planner")],P);customElements.get("mealz-product-card-planner")||customElements.define("mealz-product-card-planner",P);var we=Object.defineProperty,Ce=Object.getOwnPropertyDescriptor,ie=(e,t,s,a)=>{for(var i=a>1?void 0:a?Ce(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=(a?l(t,s,i):l(i))||i);return a&&i&&we(t,s,i),i};let B=class extends ${constructor(){super(),this.styleURL=new URL("./legal-notice/legal-notice.css",this.getBaseURL())}get containsAlcohol(){var t;return(((t=this.tags)==null?void 0:t.data)||[]).some(s=>s.id==="ingredient_category_alcool")}render(){return this.containsAlcohol?r`
322
322
  <div class="mealz-products-picker__legal-notices">
323
323
  <span class="mealz-ds-text weight-xxl mealz-products-picker__legal-notices-header">Mentions légales</span>
324
324
  <div class="mealz-products-picker__legal-notices-content">
@@ -330,7 +330,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
330
330
  </span>
331
331
  </div>
332
332
  </div>
333
- `:c}};ie([p()],L.prototype,"tags",2);L=ie([v("mealz-legal-notice")],L);customElements.get("mealz-legal-notice")||customElements.define("mealz-legal-notice",L);var xe=Object.getOwnPropertyDescriptor,Re=(e,t,s,a)=>{for(var i=a>1?void 0:a?xe(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let F=class extends g{constructor(){super(),this.styleURL=[new URL("./product-card/product-card-skeleton/product-card-skeleton.css",this.getBaseURL()),new URL("./product-card/product-card.css",this.getBaseURL())]}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}render(){return r`
333
+ `:c}};ie([h()],B.prototype,"tags",2);B=ie([k("mealz-legal-notice")],B);customElements.get("mealz-legal-notice")||customElements.define("mealz-legal-notice",B);var Re=Object.getOwnPropertyDescriptor,xe=(e,t,s,a)=>{for(var i=a>1?void 0:a?Re(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let F=class extends ${constructor(){super(),this.styleURL=[new URL("./product-card/product-card-skeleton/product-card-skeleton.css",this.getBaseURL()),new URL("./product-card/product-card.css",this.getBaseURL())]}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}render(){return r`
334
334
  <!-- PRODUCT CARD -->
335
335
  <div class="mealz-product-card skeleton">
336
336
  <!-- HEADER -->
@@ -373,7 +373,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
373
373
  </div>
374
374
  </div>
375
375
  </div>
376
- `}};F=Re([v("mealz-products-card-skeleton")],F);customElements.get("mealz-products-card-skeleton")||customElements.define("mealz-products-card-skeleton",F);var Oe=Object.defineProperty,De=Object.getOwnPropertyDescriptor,W=(e,t,s,a)=>{for(var i=a>1?void 0:a?De(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=(a?l(t,s,i):l(i))||i);return a&&i&&Oe(t,s,i),i};let E=class extends g{constructor(){super(),this.inBasket=!1,this.plannerMode=!1,this.numberUnavailableProducts=0,this.subscriptions=[],this.noSupplier=o.supplier.isNoSupplier(),this.hasEmittedReady=!1,this.styleURL=new URL("./products-picker/products-picker.css",this.getBaseURL())}get totalProducts(){return this.recipe.relationships.ingredients.data.length}connectedCallback(){super.connectedCallback(),this.resetProducts(),this.listenToProducts(),this.subscriptions.push(o.recipes.displayedRecipe$.subscribe(e=>{e&&(this.recipe=e.recipe,this.analyticsPath=`/recipes/${this.recipe.id}/shopping`,this.requestUpdate())}))}disconnectedCallback(){super.disconnectedCallback(),this.resetProducts(),this.subscriptions.forEach(e=>e.unsubscribe())}resetProducts(){this.productsByCategory={toPickProducts:[],oftenIgnoredProducts:[]},this.numberUnavailableProducts=0,this.requestUpdate()}listenToProducts(){const e=this.plannerMode?o.recipes.productsPlannerByCategory$:o.recipes.productsByCategory$;this.subscriptions.push(e.subscribe(t=>{this.productsByCategory=t,this.plannerMode?this.numberUnavailableProducts=[...t.oftenIgnoredProducts,...t.toPickProducts].filter(s=>s.status==="unavailable").length:this.numberUnavailableProducts=[...t.oftenIgnoredProducts,...t.toPickProducts].filter(s=>s.basketEntry.status==="out_of_stock").length,this.requestUpdate(),this.notifyReadyIfRendered()}))}async notifyReadyIfRendered(){if(this.hasEmittedReady)return;if(await this.updateComplete,this.querySelector(".mealz-product-card-planner__checkbox")||this.querySelector(".mealz-product-card__checkbox")){this.hasEmittedReady=!0;const t=new CustomEvent("products-picker-ready",{bubbles:!0,composed:!0});this.dispatchEvent(t)}}scrollToFirstUnavailable(){const e=document.querySelector(this.plannerMode?".mealz-products-picker":".mealz-products-picker__container");if(e){const t=e.querySelector(this.plannerMode?".mealz-product-card-planner.unavailable":".mealz-product-card__container.out_of_stock");t&&t.scrollIntoView({behavior:"smooth",block:"center"})}}isAlreadyOnCatalogPage(){return window.location.href.includes(o.router.getCatalogUrl())}closeRecipeModal(){}currentPath(){return""}guestsChange(e){const t=new CustomEvent("guestChange",{bubbles:!0,composed:!0,detail:{value:e.detail.value}});this.dispatchEvent(t)}render(){var e,t,s;return r`
376
+ `}};F=xe([k("mealz-products-card-skeleton")],F);customElements.get("mealz-products-card-skeleton")||customElements.define("mealz-products-card-skeleton",F);var Oe=Object.defineProperty,De=Object.getOwnPropertyDescriptor,W=(e,t,s,a)=>{for(var i=a>1?void 0:a?De(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=(a?l(t,s,i):l(i))||i);return a&&i&&Oe(t,s,i),i};let C=class extends ${constructor(){super(),this.inBasket=!1,this.plannerMode=!1,this.productsByCategory={toPickProducts:[],oftenIgnoredProducts:[]},this.numberUnavailableProducts=0,this.analyticsPath="",this.subscriptions=[],this.noSupplier=o.supplier.isNoSupplier(),this.hasEmittedReady=!1,this.hydrateOnly=!1,this.ssrTemplateRemoved=!1,this.styleURL=new URL("./products-picker/products-picker.css",this.getBaseURL())}get selectors(){return{unavailableBadge:"mealz-unavailable-badge"}}get totalProducts(){var e,t,s;return Array.isArray((s=(t=(e=this.recipe)==null?void 0:e.relationships)==null?void 0:t.ingredients)==null?void 0:s.data)?this.recipe.relationships.ingredients.data.length:0}connectedCallback(){var t,s;super.connectedCallback(),this.getInitialStatus(),this.resetProducts(),this.listenToProducts();const e=(s=(t=o)==null?void 0:t.recipes)==null?void 0:s.displayedRecipe$;e&&typeof e.subscribe=="function"&&this.subscriptions.push(e.subscribe(a=>{a&&(this.recipe=a.recipe,this.analyticsPath=`/recipes/${this.recipe.id}/shopping`,this.requestUpdate())}))}disconnectedCallback(){super.disconnectedCallback(),this.resetProducts(),this.subscriptions.forEach(e=>e.unsubscribe())}resetProducts(){this.productsByCategory={toPickProducts:[],oftenIgnoredProducts:[]},this.numberUnavailableProducts=0,this.requestUpdate()}getInitialStatus(){const e=this.getAttribute("starting-data");if(e)try{const t=JSON.parse(e);this.plannerMode=!!t.planner,this.hydrateOnly=!0,t.analyticsPath&&(this.analyticsPath=t.analyticsPath),t.recipeId&&(this.recipe={id:t.recipeId,attributes:{"number-of-guests":t.guests||4}})}catch(t){console.warn("[products-picker] starting-data parse error",t)}finally{this.removeAttribute("starting-data")}}removeSSRTemplate(){const e=this.querySelector(".mealz-products-picker");e&&e.parentElement===this&&e.remove()}listenToProducts(){const e=this.plannerMode?o.recipes.productsPlannerByCategory$:o.recipes.productsByCategory$;!e||typeof e.subscribe!="function"||this.subscriptions.push(e.subscribe(t=>{(t.toPickProducts.length>0||t.oftenIgnoredProducts.length>0)&&!this.ssrTemplateRemoved&&this.hydrateOnly&&(this.removeSSRTemplate(),this.ssrTemplateRemoved=!0),this.productsByCategory=t,this.plannerMode?this.numberUnavailableProducts=[...t.oftenIgnoredProducts,...t.toPickProducts].filter(s=>s.status==="unavailable").length:this.numberUnavailableProducts=[...t.oftenIgnoredProducts,...t.toPickProducts].filter(s=>s.basketEntry.status==="out_of_stock").length,this.requestUpdate(),this.notifyReadyIfRendered()}))}async notifyReadyIfRendered(){if(this.hasEmittedReady)return;if(await this.updateComplete,this.querySelector(".mealz-product-card-planner__checkbox")||this.querySelector(".mealz-product-card__checkbox")){this.hasEmittedReady=!0;const t=new CustomEvent("products-picker-ready",{bubbles:!0,composed:!0});this.dispatchEvent(t)}}scrollToFirstUnavailable(){const e=document.querySelector(this.plannerMode?".mealz-products-picker":".mealz-products-picker__container");if(e){const t=e.querySelector(this.plannerMode?".mealz-product-card-planner.unavailable":".mealz-product-card__container.out_of_stock");t&&t.scrollIntoView({behavior:"smooth",block:"center"})}}isAlreadyOnCatalogPage(){return window.location.href.includes(o.router.getCatalogUrl())}closeRecipeModal(){}currentPath(){return""}guestsChange(e){const t=new CustomEvent("guestChange",{bubbles:!0,composed:!0,detail:{value:e.detail.value}});this.dispatchEvent(t)}render(){var i,n;const e=!!this.recipe&&this.recipe.id!==void 0,t=Array.isArray((i=this.productsByCategory)==null?void 0:i.toPickProducts)?this.productsByCategory.toPickProducts:[],s=Array.isArray((n=this.productsByCategory)==null?void 0:n.oftenIgnoredProducts)?this.productsByCategory.oftenIgnoredProducts:[],a=this.totalProducts||t.length||0;return r`
377
377
  <div class="mealz-products-picker">
378
378
  ${this.inBasket&&this.plannerMode?r`
379
379
  <div class="mealz-products-picker__overlay">
@@ -388,56 +388,54 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
388
388
  ${this.renderHeader()}
389
389
  <div class="mealz-products-picker__list">
390
390
  <!-- TO PICK PRODUCTS -->
391
- ${((e=this.productsByCategory)==null?void 0:e.toPickProducts.length)>0?this.productsByCategory.toPickProducts.map(a=>{var i,n,l,d;return this.plannerMode?r`
391
+ ${e&&t.length>0?t.map(l=>{var d,u,g,p,m,v,b,_,f,z;return this.plannerMode?r`
392
392
  <mealz-product-card-planner
393
- .product="${a}"
393
+ .product="${l}"
394
394
  .recipeId="${this.recipe.id}"
395
395
  .oftenIgnored="${!1}"
396
- .initialGuests="${((i=this.recipe)==null?void 0:i.attributes["number-of-guests"])||4}"
397
- .currentGuests="${this.recipe.modifiedGuests||((n=this.recipe)==null?void 0:n.attributes["number-of-guests"])||4}"
396
+ .initialGuests="${((u=(d=this.recipe)==null?void 0:d.attributes)==null?void 0:u["number-of-guests"])||4}"
397
+ .currentGuests="${((g=this.recipe)==null?void 0:g.modifiedGuests)||((m=(p=this.recipe)==null?void 0:p.attributes)==null?void 0:m["number-of-guests"])||4}"
398
398
  ></mealz-product-card-planner>
399
399
  `:r`
400
400
  <mealz-product-card
401
- .product="${a}"
401
+ .product="${l}"
402
402
  .recipeId="${this.recipe.id}"
403
- .initialGuests="${((l=this.recipe)==null?void 0:l.attributes["number-of-guests"])||4}"
404
- .currentGuests="${this.recipe.modifiedGuests||((d=this.recipe)==null?void 0:d.attributes["number-of-guests"])||4}"
403
+ .initialGuests="${((b=(v=this.recipe)==null?void 0:v.attributes)==null?void 0:b["number-of-guests"])||4}"
404
+ .currentGuests="${((_=this.recipe)==null?void 0:_.modifiedGuests)||((z=(f=this.recipe)==null?void 0:f.attributes)==null?void 0:z["number-of-guests"])||4}"
405
405
  ></mealz-product-card>
406
- `}):Array(this.totalProducts).fill(r`
407
- <mealz-products-card-skeleton></mealz-products-card-skeleton>
408
- `)}
406
+ `}):new Array(a).fill(r`<mealz-products-card-skeleton></mealz-products-card-skeleton>`)}
409
407
  </div>
410
408
  <!-- OFTEN IGNORED PRODUCTS -->
411
409
  <div class="mealz-products-picker__secondary-list">
412
- ${((s=(t=this.productsByCategory)==null?void 0:t.oftenIgnoredProducts)==null?void 0:s.length)>0?r`
410
+ ${e&&s.length>0?r`
413
411
  <mealz-accordion
414
412
  .noStyling=${!0}
415
- .titleSlot=${r`
413
+ >
414
+ <div slot="title">
416
415
  <span class="mealz-ds-text weight-xl">
417
416
  Déjà dans le placard
418
417
  </span>
419
- `}
420
- .contentSlot=${r`
418
+ </div>
419
+ <div slot="content">
421
420
  <div class="mealz-products-picker__list">
422
- ${this.productsByCategory.oftenIgnoredProducts.map(a=>{var i,n,l,d;return this.plannerMode?r`
421
+ ${s.map(l=>{var d,u,g,p,m,v,b,_,f,z;return this.plannerMode?r`
423
422
  <mealz-product-card-planner
424
- .product=${a}
425
- .recipeId=${this.recipe.id}
426
- .oftenIgnored=${!0}
427
- .initialGuests=${((i=this.recipe)==null?void 0:i.attributes["number-of-guests"])||4}
428
- .currentGuests=${this.recipe.modifiedGuests||((n=this.recipe)==null?void 0:n.attributes["number-of-guests"])||4}
423
+ .product="${l}"
424
+ .recipeId="${this.recipe.id}"
425
+ .oftenIgnored="${!0}"
426
+ .initialGuests="${((u=(d=this.recipe)==null?void 0:d.attributes)==null?void 0:u["number-of-guests"])||4}"
427
+ .currentGuests="${((g=this.recipe)==null?void 0:g.modifiedGuests)||((m=(p=this.recipe)==null?void 0:p.attributes)==null?void 0:m["number-of-guests"])||4}"
429
428
  ></mealz-product-card-planner>
430
429
  `:r`
431
430
  <mealz-product-card
432
- .product=${a}
433
- .recipeId=${this.recipe.id}
434
- .initialGuests=${((l=this.recipe)==null?void 0:l.attributes["number-of-guests"])||4}
435
- .currentGuests=${this.recipe.modifiedGuests||((d=this.recipe)==null?void 0:d.attributes["number-of-guests"])||4}
431
+ .product="${l}"
432
+ .recipeId="${this.recipe.id}"
433
+ .initialGuests="${((b=(v=this.recipe)==null?void 0:v.attributes)==null?void 0:b["number-of-guests"])||4}"
434
+ .currentGuests="${((_=this.recipe)==null?void 0:_.modifiedGuests)||((z=(f=this.recipe)==null?void 0:f.attributes)==null?void 0:z["number-of-guests"])||4}"
436
435
  ></mealz-product-card>
437
436
  `})}
438
437
  </div>
439
- `}
440
- >
438
+ </div>
441
439
  </mealz-accordion>
442
440
  `:c}
443
441
  </div>
@@ -478,7 +476,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
478
476
  </select>
479
477
  </div> -->
480
478
  </div>
481
- `}renderLowerContent(){return r`
479
+ `}renderLowerContent(){var e,t;return r`
482
480
  <!-- MORE RECIPE IDEAS -->
483
481
  <div class="mealz-products-picker__more">
484
482
  ${!this.isAlreadyOnCatalogPage()&&!this.plannerMode?r`
@@ -495,8 +493,8 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
495
493
  </button>
496
494
  `}
497
495
  </div>
498
- <mealz-legal-notice .tags="${this.recipe.relationships.tags}"></mealz-legal-notice>
499
- `}sendHomeDisplayEvent(){o.analytics.sendEvent("home.display",this.analyticsPath,{})}};W([p({type:Boolean})],E.prototype,"inBasket",2);W([p({type:Boolean})],E.prototype,"plannerMode",2);E=W([v("mealz-products-picker")],E);customElements.get("mealz-products-picker")||customElements.define("mealz-products-picker",E);var Be=Object.getOwnPropertyDescriptor,Le=(e,t,s,a)=>{for(var i=a>1?void 0:a?Be(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let V=class extends g{constructor(){super(),this.invalidPos=!1,this.subscriptions=[],this.styleURL=new URL("./recipe-details/no-pos-selected/no-pos-selected.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.listenIfPosInvalid()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}listenIfPosInvalid(){this.subscriptions.push(o.recipes.invalidPosDisplay$.subscribe(e=>{this.invalidPos=e,this.requestUpdate()}))}callPosSelector(){const e=new CustomEvent("posSelected",{bubbles:!0,composed:!0});this.dispatchEvent(e)}openStoreLocator(){window.mealzInternal.noSupplier.displaySupplierSelector$.next(!0)}render(){return r`
496
+ <mealz-legal-notice .tags="${(t=(e=this.recipe)==null?void 0:e.relationships)==null?void 0:t.tags}"></mealz-legal-notice>
497
+ `}sendHomeDisplayEvent(){o.analytics.sendEvent("home.display",this.analyticsPath,{})}};W([h({type:Boolean})],C.prototype,"inBasket",2);W([h({type:Boolean})],C.prototype,"plannerMode",2);C=W([k("mealz-products-picker")],C);customElements.get("mealz-products-picker")||customElements.define("mealz-products-picker",C);var Be=Object.getOwnPropertyDescriptor,Ae=(e,t,s,a)=>{for(var i=a>1?void 0:a?Be(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let V=class extends ${constructor(){super(),this.invalidPos=!1,this.subscriptions=[],this.styleURL=new URL("./recipe-details/no-pos-selected/no-pos-selected.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.listenIfPosInvalid()}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}listenIfPosInvalid(){this.subscriptions.push(o.recipes.invalidPosDisplay$.subscribe(e=>{this.invalidPos=e,this.requestUpdate()}))}callPosSelector(){const e=new CustomEvent("posSelected",{bubbles:!0,composed:!0});this.dispatchEvent(e)}openStoreLocator(){window.mealzInternal.noSupplier.displaySupplierSelector$.next(!0)}render(){return r`
500
498
  <div class="mealz-no-pos-selected">
501
499
  ${this.invalidPos?r`
502
500
  <!-- INVALID POS -->
@@ -536,7 +534,7 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
536
534
  Sélectionner un magasin
537
535
  </button>
538
536
  </div>
539
- `}};V=Le([v("mealz-no-pos-selected")],V);customElements.get("mealz-no-pos-selected")||customElements.define("mealz-no-pos-selected",V);var Ue=Object.getOwnPropertyDescriptor,Ae=(e,t,s,a)=>{for(var i=a>1?void 0:a?Ue(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let j=class extends g{constructor(){super(),this.activeTabIndex=0,this.destroy$=new B,this.remainingBasketEntries=[],this.guestObserverService=te.getInstance(),this.isSticky=!1,this.hasBackNavigation=!1,this.drawerViewSwapper=null,this.styleURL=new URL("./recipe-details/recipe-details.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.destroy$=new B,this.handleNoSupplierMode(),Z(o.recipes.displayedRecipe$.pipe(D(this.destroy$),Q(e=>!!e),z(e=>{e.recipe!==null&&(this.recipe=e.recipe,this.sponsor=e.recipe.relationships.sponsors.data[0],this.analyticsPath=`/recipes/${this.recipe.id}/shopping`,this.plannerMode=!!e.planner,this.getLikeButton(),this.checkSponsorStorytelling(),this.pageview(),this.listenToCloseEvent(),this.setStickyObserver())}),Y(e=>e.recipe===null?[]:this.listenToRecipeInBasket())),this.listenPosStatus(),this.listenRemainingBasketEntries(),this.listenLastOrderDate(),this.listenToLoadingStates(),this.listenToAddAllToBasket()).pipe(D(this.destroy$)).subscribe({next:()=>this.requestUpdate(),error:e=>console.error("Recipe details error:",e)}),this.addEventListener("products-picker-ready",()=>this.startRecipeDetailsOnboardingIfNeeded()),this.setupDrawerBackNavigationIndicator()}disconnectedCallback(){super.disconnectedCallback(),this.destroy$.next(),this.destroy$.complete(),this.topObserver&&this.topObserver.disconnect(),this.stickyTimeout&&clearTimeout(this.stickyTimeout),this.drawerViewSwapper&&this.onActiveViewsChanged&&this.drawerViewSwapper.removeEventListener("mealz-active-views-changed",this.onActiveViewsChanged)}setupDrawerBackNavigationIndicator(){const e=this.closest("mealz-drawer-view-swapper");this.drawerViewSwapper=e??document.querySelector("mealz-drawer-view-swapper"),this.drawerViewSwapper&&(this.updateBackNavigationFromActiveViews(this.drawerViewSwapper.getActiveViewNames()),this.onActiveViewsChanged=t=>{const s=t==null?void 0:t.detail;s!=null&&s.activeViews&&this.updateBackNavigationFromActiveViews(s.activeViews)},this.drawerViewSwapper.addEventListener("mealz-active-views-changed",this.onActiveViewsChanged))}updateBackNavigationFromActiveViews(e){const t=Array.isArray(e)&&e.length>1;this.hasBackNavigation!==t&&(this.hasBackNavigation=t,this.requestUpdate())}getRecipeDetailsCloseIcon(){return this.hasBackNavigation?{src:"https://storage.googleapis.com/assets.miam.tech/generic/icons/arrow-right.svg",alt:"back button",className:"mealz-recipe-details__close-icon is-back"}:{src:"https://storage.googleapis.com/assets.miam.tech/generic/icons/Cross_primary.svg",alt:"modal close button",className:"mealz-recipe-details__close-icon"}}getRecipeDetailsStickyCloseIcon(){return this.hasBackNavigation?{src:"https://storage.googleapis.com/assets.miam.tech/generic/icons/ArrowLeft_dark.svg",alt:"back button",className:"mealz-recipe-details__close-icon before-title is-back"}:{src:"https://storage.googleapis.com/assets.miam.tech/generic/icons/Cross_Black.svg",alt:"modal close button",className:"mealz-recipe-details__close-icon"}}setStickyObserver(){this.topObserver||this.updateComplete.then(()=>{const e=this.querySelector(".mealz-recipe-details__sticky-anchor");e&&(this.topObserver=new IntersectionObserver(([t])=>{this.stickyTimeout&&clearTimeout(this.stickyTimeout),this.stickyTimeout=window.setTimeout(()=>{const s=!t.isIntersecting;this.isSticky!==s&&(this.isSticky=s,this.requestUpdate())},150)},{threshold:0}),this.topObserver.observe(e))})}startRecipeDetailsOnboardingIfNeeded(){localStorage.getItem("_miam/recipeDetailsOnboarding")==="true"||!this.plannerMode||this.updateComplete.then(()=>{this.scrollJustAfterImage();let t=document.querySelector("mealz-planner-onboarding");t?t.type="recipe-details":(t=new ue,t.type="recipe-details",document.body.appendChild(t)),t.launchOnboardingTour()})}scrollJustAfterImage(){const e=this.querySelector(".mealz-recipe-details__tabs");if(!e)return;const t=document.querySelector(".mealz-drawer__content-container");if(t){const s=e.getBoundingClientRect(),a=t.getBoundingClientRect();t.scrollTop+=s.top-a.top;return}e.scrollIntoView({behavior:"smooth",block:"start"})}handleNoSupplierMode(){this.noSupplier=!!o.supplier.isNoSupplier(),this.requestUpdate()}close(){this.sendCloseEvent(),o.recipes.displayedRecipe$.next(null)}listenToCloseEvent(){const e=document.querySelector("mealz-drawer");e&&e.addEventListener("drawerClosed",()=>{this.sendCloseEvent()})}selectTab(e){this.activeTabIndex=e,this.activeTabIndex===1&&this.sendCookingDisplayEvent(),this.requestUpdate()}getLikeButton(){this.noSupplier||o.user.isAuthenticated().pipe(D(this.destroy$),Q(e=>e),Y(()=>o.html.like(this.recipe.id))).subscribe({next:e=>{this.likeButtonHTML=e,this.requestUpdate()},error:e=>console.error("Like button error:",e)})}checkSponsorStorytelling(){this.sponsor&&o.sponsor.hasStorytelling(this.sponsor.id).pipe(D(this.destroy$)).subscribe({next:e=>{this.hasSponsorStorytelling=e,this.requestUpdate()},error:e=>console.error("Sponsor storytelling error:",e)})}listenPosStatus(){return J({noPosDisplay:o.recipes.noPosDisplay$,invalidPosDisplay:o.recipes.invalidPosDisplay$}).pipe(z(({noPosDisplay:e,invalidPosDisplay:t})=>{this.noPosDisplay=e,this.invalidPosDisplay=t,this.activeTabIndex=e?1:0}),m(()=>{}))}listenLastOrderDate(){return o.recipes.orderHistoryDate$.pipe(z(e=>{this.orderHistoryDate=e}))}listenToLoadingStates(){return J([o.recipes.ingredientToBasketLoading$,o.recipes.updateIngredientFromBasketLoading$]).pipe(m(([e,t])=>e||t),z(e=>{this.basketIsUpdating=e}),be(1))}listenRemainingBasketEntries(){return o.recipes.remainingBasketEntries$.pipe(z(e=>{this.remainingBasketEntries=e}))}listenToAddAllToBasket(){return o.recipes.allIngredientsToBasketLoading$.pipe(z(e=>{e&&(this.selectTab(0),setTimeout(()=>{this.scrollToPicker()},50))}))}listenToRecipeInBasket(){return o.recipes.isRecipeInBasket(this.recipe.id).pipe(z(e=>{this.inBasket=e}))}scrollToPicker(){const e=this.querySelector(".mealz-products-picker");if(e){const t=this.querySelector(".mealz-recipe-details__title-container"),s=(t==null?void 0:t.offsetHeight)||0;e.style.scrollMarginTop=`${s}px`,e.scrollIntoView({behavior:"instant",block:"start"})}}scrollToReplacedItem(e){var s,a;const t=this.querySelectorAll("mealz-product-card-planner");for(const i of Array.from(t)){const n=i;if(((a=(s=n.product)==null?void 0:s.item)==null?void 0:a.id)===e){n.scrollIntoView({behavior:"instant",block:"center"});break}}}openLastOrderModal(){this.sendOrderedDisplayEvent();const e=new de;e.recipeId=this.recipe.id,e.addEventListener("orderAgain",()=>this.orderAgain()),e.displayLastOrderModal(this.orderHistoryDate)}orderAgain(){o.recipes.addAllIngredientsToBasket({originPath:this.analyticsPath,props:{}})}updateGuests(e){if(this.recipe.modifiedGuests===e.detail.value)return;this.recipe.modifiedGuests=e.detail.value,this.guestObserverService.updateGuests(this.recipe.modifiedGuests);const t={originPath:this.analyticsPath,props:{}};this.plannerMode?o.planner.updateGuests(this.recipe.modifiedGuests,t):o.recipes.updateGuests(t),this.requestUpdate()}render(){const e=this.getRecipeDetailsCloseIcon(),t=this.getRecipeDetailsStickyCloseIcon();return r`
537
+ `}};V=Ae([k("mealz-no-pos-selected")],V);customElements.get("mealz-no-pos-selected")||customElements.define("mealz-no-pos-selected",V);var Le=Object.getOwnPropertyDescriptor,Ue=(e,t,s,a)=>{for(var i=a>1?void 0:a?Le(t,s):t,n=e.length-1,l;n>=0;n--)(l=e[n])&&(i=l(i)||i);return i};let j=class extends ${constructor(){super(),this.activeTabIndex=0,this.destroy$=new D,this.remainingBasketEntries=[],this.guestObserverService=te.getInstance(),this.isSticky=!1,this.hasBackNavigation=!1,this.drawerViewSwapper=null,this.styleURL=new URL("./recipe-details/recipe-details.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.destroy$=new D,this.handleNoSupplierMode(),Z(o.recipes.displayedRecipe$.pipe(O(this.destroy$),Q(e=>!!e),T(e=>{e.recipe!==null&&(this.recipe=e.recipe,this.sponsor=e.recipe.relationships.sponsors.data[0],this.analyticsPath=`/recipes/${this.recipe.id}/shopping`,this.plannerMode=!!e.planner,this.getLikeButton(),this.checkSponsorStorytelling(),this.pageview(),this.listenToCloseEvent(),this.setStickyObserver())}),Y(e=>e.recipe===null?[]:this.listenToRecipeInBasket())),this.listenPosStatus(),this.listenRemainingBasketEntries(),this.listenLastOrderDate(),this.listenToLoadingStates(),this.listenToAddAllToBasket()).pipe(O(this.destroy$)).subscribe({next:()=>this.requestUpdate(),error:e=>console.error("Recipe details error:",e)}),this.addEventListener("products-picker-ready",()=>this.startRecipeDetailsOnboardingIfNeeded()),this.setupDrawerBackNavigationIndicator()}disconnectedCallback(){super.disconnectedCallback(),this.destroy$.next(),this.destroy$.complete(),this.topObserver&&this.topObserver.disconnect(),this.stickyTimeout&&clearTimeout(this.stickyTimeout),this.drawerViewSwapper&&this.onActiveViewsChanged&&this.drawerViewSwapper.removeEventListener("mealz-active-views-changed",this.onActiveViewsChanged)}setupDrawerBackNavigationIndicator(){const e=this.closest("mealz-drawer-view-swapper");this.drawerViewSwapper=e??document.querySelector("mealz-drawer-view-swapper"),this.drawerViewSwapper&&(this.updateBackNavigationFromActiveViews(this.drawerViewSwapper.getActiveViewNames()),this.onActiveViewsChanged=t=>{const s=t==null?void 0:t.detail;s!=null&&s.activeViews&&this.updateBackNavigationFromActiveViews(s.activeViews)},this.drawerViewSwapper.addEventListener("mealz-active-views-changed",this.onActiveViewsChanged))}updateBackNavigationFromActiveViews(e){const t=Array.isArray(e)&&e.length>1;this.hasBackNavigation!==t&&(this.hasBackNavigation=t,this.requestUpdate())}getRecipeDetailsCloseIcon(){return this.hasBackNavigation?{src:"https://storage.googleapis.com/assets.miam.tech/generic/icons/arrow-right.svg",alt:"back button",className:"mealz-recipe-details__close-icon is-back"}:{src:"https://storage.googleapis.com/assets.miam.tech/generic/icons/Cross_primary.svg",alt:"modal close button",className:"mealz-recipe-details__close-icon"}}getRecipeDetailsStickyCloseIcon(){return this.hasBackNavigation?{src:"https://storage.googleapis.com/assets.miam.tech/generic/icons/ArrowLeft_dark.svg",alt:"back button",className:"mealz-recipe-details__close-icon before-title is-back"}:{src:"https://storage.googleapis.com/assets.miam.tech/generic/icons/Cross_Black.svg",alt:"modal close button",className:"mealz-recipe-details__close-icon"}}setStickyObserver(){this.topObserver||this.updateComplete.then(()=>{const e=this.querySelector(".mealz-recipe-details__sticky-anchor");e&&(this.topObserver=new IntersectionObserver(([t])=>{this.stickyTimeout&&clearTimeout(this.stickyTimeout),this.stickyTimeout=window.setTimeout(()=>{const s=!t.isIntersecting;this.isSticky!==s&&(this.isSticky=s,this.requestUpdate())},150)},{threshold:0}),this.topObserver.observe(e))})}startRecipeDetailsOnboardingIfNeeded(){localStorage.getItem("_miam/recipeDetailsOnboarding")==="true"||!this.plannerMode||this.updateComplete.then(()=>{this.scrollJustAfterImage();let t=document.querySelector("mealz-planner-onboarding");t?t.type="recipe-details":(t=new ue,t.type="recipe-details",document.body.appendChild(t)),t.launchOnboardingTour()})}scrollJustAfterImage(){const e=this.querySelector(".mealz-recipe-details__tabs");if(!e)return;const t=document.querySelector(".mealz-drawer__content-container");if(t){const s=e.getBoundingClientRect(),a=t.getBoundingClientRect();t.scrollTop+=s.top-a.top;return}e.scrollIntoView({behavior:"smooth",block:"start"})}handleNoSupplierMode(){this.noSupplier=!!o.supplier.isNoSupplier(),this.requestUpdate()}close(){this.sendCloseEvent(),o.recipes.displayedRecipe$.next(null)}listenToCloseEvent(){const e=document.querySelector("mealz-drawer");e&&e.addEventListener("drawerClosed",()=>{this.sendCloseEvent()})}selectTab(e){this.activeTabIndex=e,this.activeTabIndex===1&&this.sendCookingDisplayEvent(),this.requestUpdate()}getLikeButton(){this.noSupplier||o.user.isAuthenticated().pipe(O(this.destroy$),Q(e=>e),Y(()=>o.html.like(this.recipe.id))).subscribe({next:e=>{this.likeButtonHTML=e,this.requestUpdate()},error:e=>console.error("Like button error:",e)})}checkSponsorStorytelling(){this.sponsor&&o.sponsor.hasStorytelling(this.sponsor.id).pipe(O(this.destroy$)).subscribe({next:e=>{this.hasSponsorStorytelling=e,this.requestUpdate()},error:e=>console.error("Sponsor storytelling error:",e)})}listenPosStatus(){return J({noPosDisplay:o.recipes.noPosDisplay$,invalidPosDisplay:o.recipes.invalidPosDisplay$}).pipe(T(({noPosDisplay:e,invalidPosDisplay:t})=>{this.noPosDisplay=e,this.invalidPosDisplay=t,this.activeTabIndex=e?1:0}),y(()=>{}))}listenLastOrderDate(){return o.recipes.orderHistoryDate$.pipe(T(e=>{this.orderHistoryDate=e}))}listenToLoadingStates(){return J([o.recipes.ingredientToBasketLoading$,o.recipes.updateIngredientFromBasketLoading$]).pipe(y(([e,t])=>e||t),T(e=>{this.basketIsUpdating=e}),be(1))}listenRemainingBasketEntries(){return o.recipes.remainingBasketEntries$.pipe(T(e=>{this.remainingBasketEntries=e}))}listenToAddAllToBasket(){return o.recipes.allIngredientsToBasketLoading$.pipe(T(e=>{e&&(this.selectTab(0),setTimeout(()=>{this.scrollToPicker()},50))}))}listenToRecipeInBasket(){return o.recipes.isRecipeInBasket(this.recipe.id).pipe(T(e=>{this.inBasket=e}))}scrollToPicker(){const e=this.querySelector(".mealz-products-picker");if(e){const t=this.querySelector(".mealz-recipe-details__title-container"),s=(t==null?void 0:t.offsetHeight)||0;e.style.scrollMarginTop=`${s}px`,e.scrollIntoView({behavior:"instant",block:"start"})}}scrollToReplacedItem(e){var s,a;const t=this.querySelectorAll("mealz-product-card-planner");for(const i of Array.from(t)){const n=i;if(((a=(s=n.product)==null?void 0:s.item)==null?void 0:a.id)===e){n.scrollIntoView({behavior:"instant",block:"center"});break}}}openLastOrderModal(){this.sendOrderedDisplayEvent();const e=new de;e.recipeId=this.recipe.id,e.addEventListener("orderAgain",()=>this.orderAgain()),e.displayLastOrderModal(this.orderHistoryDate)}orderAgain(){o.recipes.addAllIngredientsToBasket({originPath:this.analyticsPath,props:{}})}updateGuests(e){if(this.recipe.modifiedGuests===e.detail.value)return;this.recipe.modifiedGuests=e.detail.value,this.guestObserverService.updateGuests(this.recipe.modifiedGuests);const t={originPath:this.analyticsPath,props:{}};this.plannerMode?o.planner.updateGuests(this.recipe.modifiedGuests,t):o.recipes.updateGuests(t),this.requestUpdate()}render(){const e=this.getRecipeDetailsCloseIcon(),t=this.getRecipeDetailsStickyCloseIcon();return r`
540
538
  <div class="mealz-recipe-details">
541
539
  <!-- IF IS LOADING -->
542
540
  ${this.recipe?c:r`
@@ -704,4 +702,4 @@ import"../drawer/drawer.min.js";import"../recipe-pricing/recipe-pricing.min.js";
704
702
  </div>
705
703
  `:c}
706
704
  </div>
707
- `}showRecipeAddon(){this.sendSponsorDisplayEvent();const e=document.querySelector("mealz-drawer-view-swapper");e&&e.displayRecipeAddon$.next(!0)}pageview(){o.analytics.sendEvent("pageview",this.analyticsPath,{})}sendSponsorDisplayEvent(){o.analytics.sendEvent("sponsor.display",this.analyticsPath,{recipe_id:this.recipe.id})}sendCloseEvent(){o.analytics.sendEvent("recipe.close",this.analyticsPath,{recipe_id:this.recipe.id})}sendCookingDisplayEvent(){o.analytics.sendEvent("recipe.cooking.display",this.analyticsPath,{recipe_id:this.recipe.id})}sendOrderedDisplayEvent(){o.analytics.sendEvent("recipe.ordered.display",this.analyticsPath,{recipe_id:this.recipe.id})}};j=Ae([v("mealz-recipe-details")],j);customElements.get("mealz-recipe-details")||customElements.define("mealz-recipe-details",j);
705
+ `}showRecipeAddon(){this.sendSponsorDisplayEvent();const e=document.querySelector("mealz-drawer-view-swapper");e&&e.displayRecipeAddon$.next(!0)}pageview(){o.analytics.sendEvent("pageview",this.analyticsPath,{})}sendSponsorDisplayEvent(){o.analytics.sendEvent("sponsor.display",this.analyticsPath,{recipe_id:this.recipe.id})}sendCloseEvent(){o.analytics.sendEvent("recipe.close",this.analyticsPath,{recipe_id:this.recipe.id})}sendCookingDisplayEvent(){o.analytics.sendEvent("recipe.cooking.display",this.analyticsPath,{recipe_id:this.recipe.id})}sendOrderedDisplayEvent(){o.analytics.sendEvent("recipe.ordered.display",this.analyticsPath,{recipe_id:this.recipe.id})}};j=Ue([k("mealz-recipe-details")],j);customElements.get("mealz-recipe-details")||customElements.define("mealz-recipe-details",j);
@@ -1 +1 @@
1
- import{N as P,B as m}from"../assets/no-shadow-element-YPHUv5PR.js";import{V as b}from"../assets/viewport-listener-CDsKFDz1.js";import{t as f}from"../assets/custom-element-BhZVzxrc.js";import{w as I,m as n}from"../assets/mealz-sdk-E_fNZM-c.js";import{s as g}from"../assets/skipWhile-BZVFq1Cg.js";import{t as l}from"../assets/take-CozE9iSG.js";import{f as h}from"../assets/filter-BZ75lS5D.js";import"../assets/debounceTime-B4DpnstH.js";import"../assets/async-CFBGA-Dz.js";import"../assets/OperatorSubscriber-BaYaQC1O.js";import"../assets/empty-0eVnsLmk.js";class p{constructor(){this.priceMemorized=new Map,this.displayedPrices=new Set,this.cleanupInterval=null,this.MAX_MEMO_SIZE=500,this.CLEANUP_INTERVAL=600*1e3,this.handlePageUnload=()=>{this.destroy()},this.startAutoCleanup(),this.setupPageUnloadListener()}static getInstance(){return p.instance||(p.instance=new p),p.instance}getMemorizedPrice(e,r){const s=`${e}-${r}`;return this.priceMemorized.get(s)}memorizedPrice(e,r,s){const c=`${e}-${r}`;this.priceMemorized.size>=this.MAX_MEMO_SIZE&&this.cleanOldPrices(),this.priceMemorized.set(c,{price:s,guests:r})}isPriceDisplayed(e,r){const s=`${e}-${r}`;return this.displayedPrices.has(s)}markPriceAsDisplayed(e,r){const s=`${e}-${r}`;this.displayedPrices.add(s)}cleanOldPrices(){this.priceMemorized.size>this.MAX_MEMO_SIZE*.8&&Array.from(this.priceMemorized.entries()).slice(0,Math.floor(this.priceMemorized.size*.3)).forEach(([s])=>{this.priceMemorized.delete(s),this.displayedPrices.delete(s)})}clearAllPrices(){this.priceMemorized.clear(),this.displayedPrices.clear()}destroy(){window.removeEventListener("beforeunload",this.handlePageUnload),this.cleanupInterval&&(clearInterval(this.cleanupInterval),this.cleanupInterval=null),this.priceMemorized.clear(),this.displayedPrices.clear(),p.instance=null}startAutoCleanup(){this.cleanupInterval=window.setInterval(()=>{this.cleanOldPrices()},this.CLEANUP_INTERVAL)}setupPageUnloadListener(){window.addEventListener("beforeunload",this.handlePageUnload)}}var v=Object.getOwnPropertyDescriptor,y=(i,e,r,s)=>{for(var c=s>1?void 0:s?v(e,r):e,t=i.length-1,a;t>=0;t--)(a=i[t])&&(c=a(c)||c);return c};let o=class extends P{constructor(){super(...arguments),this.recipePricing=null,this.formattedPrice="",this.recipeId="",this.pricePerServe="",this.recipePricingValue=null,this.serves=0,this.posId="",this.extStoreId="",this.rendered=new m(!1),this.priceViewportObserver=null,this.priceFetched=!1,this.planner=!1,this.lastDisplayedRecipeId="",this.lastPlannerPrice=0,this.plannerPriceSubscription=null,this.lastAppliedPrice="",this.priceDisplayed=!1,this.subscriptions=[]}connectedCallback(){super.connectedCallback(),this.classList.add("re-rendering"),this.getInitialStatus(),this.listenInView(),I().then(()=>{this.setupSubscriptions()}).catch(i=>{console.warn("Failed to initialize SDK subscriptions:",i)}),requestAnimationFrame(()=>{this.classList.remove("re-rendering")})}disconnectedCallback(){var i;super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe()),this.plannerPriceSubscription&&(this.plannerPriceSubscription.unsubscribe(),this.plannerPriceSubscription=null),(i=this.priceViewportObserver)==null||i.disconnect()}setupSubscriptions(){const i=n;this.subscriptions.push(this.rendered.pipe(g(e=>!e),l(1)).subscribe(()=>{const e=i.basket.recipePricesInBasket$().subscribe(r=>{if(!r)return;const s=r.find(c=>c.id===this.recipeId);r.length>0&&s&&parseFloat(s.price)>0&&(this.serves=i.basket.guestsForRecipe(s.id),this.recipePricingValue={id:s.id,price:parseFloat(s.price),guests:this.serves},this.recalculatePrice(parseFloat(s.price),this.serves))});this.subscriptions.push(e)}),i.recipes.recipePriceUpdated().subscribe(e=>{e.recipeId===this.recipeId&&!e.inBasket&&this.recipePricingValue&&(this.recipePricingValue.price=e.remaining,this.recalculatePrice(e.remaining,this.serves))}),this.setupDisplayedRecipeSubscription(),this.setupGuestUpdatesSubscription(),this.setupMenuPriceSubscription())}setupDisplayedRecipeSubscription(){return n.recipes.displayedRecipe$.pipe(h(()=>this.planner&&!!this.recipeId)).subscribe(e=>{var r;((r=e==null?void 0:e.recipe)==null?void 0:r.id)===this.recipeId?(this.lastDisplayedRecipeId=this.recipeId,this.trackPlannerRecipePrice(),this.updateGuestCountFromMenu()):!(e!=null&&e.recipe)&&this.lastDisplayedRecipeId===this.recipeId&&(this.updatePriceFromCapturedPlannerPrice(),this.lastDisplayedRecipeId="",this.plannerPriceSubscription&&(this.plannerPriceSubscription.unsubscribe(),this.plannerPriceSubscription=null))})}setupGuestUpdatesSubscription(){return n.recipes.guestsUpdated().pipe(h(()=>!!this.recipeId)).subscribe(({guests:e,recipeId:r})=>{r===this.recipeId&&(this.serves=e,this.recipePricingValue&&this.recipePricingValue.price!==null&&this.recalculatePrice(this.recipePricingValue.price,this.serves))})}setupMenuPriceSubscription(){return n.planner.menuPrice$.pipe(h(()=>this.planner&&!!this.recipeId)).subscribe(()=>{if(this.lastPlannerPrice>0&&this.serves>0){const e=this.lastPlannerPrice/this.serves;this.applyCurrencyDisplay(e.toFixed(2))}})}fetchPrice(){const i=p.getInstance(),e=i.getMemorizedPrice(this.recipeId,this.serves);if(e){requestAnimationFrame(()=>{this.applyCurrencyDisplay(e.price),i.markPriceAsDisplayed(this.recipeId,this.serves)});return}this.fetchAndUpdatePrice()}render(){this.recipePricing=this.querySelector(".mealz-recipe-pricing"),this.recipePricing&&(this.recipeId&&this.pricePerServe&&p.getInstance().isPriceDisplayed(this.recipeId,this.serves)&&requestAnimationFrame(()=>{this.applyCurrencyDisplay(this.pricePerServe)}),this.rendered.next(!0),this.getInitialStatus())}getInitialStatus(){const i=this.attributes.getNamedItem("starting-data"),e=i==null?void 0:i.value;if(!e)return;const r=JSON.parse(e),{recipeId:s,extStoreId:c,posId:t,pricePerServe:a,serves:d,planner:u}=r;this.extStoreId=c||"",this.posId=t||"",this.recipeId=s,this.pricePerServe=(a==null?void 0:a.toString())??"",this.serves=d,this.planner=u||!1,this.recipePricingValue={id:this.recipeId,price:null,guests:this.serves},this.pricePerServe&&this.applyCurrencyDisplay(this.pricePerServe)}applyCurrencyDisplay(i){if(this.lastAppliedPrice===i)return;const e=parseFloat(i);isNaN(e)||(this.lastAppliedPrice=i,this.formattedPrice=e.toLocaleString("fr-FR",{minimumFractionDigits:2,maximumFractionDigits:2}),this.recipePricing||(this.recipePricing=this.querySelector(".mealz-recipe-pricing")),this.updateDOM())}showPrice(){var r,s;if(this.priceDisplayed)return;const i=(r=this.recipePricing)==null?void 0:r.querySelector(".mealz-recipe-pricing__loading"),e=(s=this.recipePricing)==null?void 0:s.querySelector(".mealz-recipe-pricing__wrapper");i==null||i.classList.replace("active","hidden"),e==null||e.classList.replace("hidden","active"),this.priceDisplayed=!0}updateDOM(){var e;const i=(e=this.recipePricing)==null?void 0:e.querySelector(".mealz-recipe-pricing__wrapper__price");i&&(i.innerHTML=this.formattedPrice+" €",this.showPrice())}recalculatePrice(i,e){const r=(i/e).toString();this.applyCurrencyDisplay(r)}trackPlannerRecipePrice(){const i=n;this.plannerPriceSubscription&&(this.plannerPriceSubscription.unsubscribe(),this.plannerPriceSubscription=null),this.plannerPriceSubscription=i.planner.plannerRecipePrice$.subscribe(e=>{e>0&&(this.lastPlannerPrice=e)})}updateGuestCountFromMenu(){if(!this.planner||!this.recipeId)return;n.planner.getGuestsForRecipe(this.recipeId).pipe(l(1)).subscribe(e=>{e&&e>0&&(this.serves=e)})}updatePriceFromCapturedPlannerPrice(){if(!this.planner||!this.recipeId)return;n.planner.isRecipeInMenu$(this.recipeId).pipe(l(1)).subscribe(e=>{if(e&&this.lastPlannerPrice>0){if(this.serves>0){const r=this.lastPlannerPrice/this.serves;this.applyCurrencyDisplay(r.toFixed(2))}}else this.pricePerServe&&this.applyCurrencyDisplay(this.pricePerServe)})}listenInView(){this.priceViewportObserver=new b(this,()=>{var i;!this.priceFetched&&((i=this.recipePricingValue)==null?void 0:i.price)===null&&this.fetchPrice()})}fetchAndUpdatePrice(){const i=this.posId||this.extStoreId,e=!!this.extStoreId;if(!i||!this.recipeId||!this.serves)return;const c=n.recipes.fetchPricing(this.recipeId,i,this.serves,e).subscribe({next:t=>{t&&t["price-per-serve"]&&(this.pricePerServe=t["price-per-serve"].toString(),this.recipePricingValue={id:this.recipeId,price:t.price,guests:this.serves},this.recalculatePrice(t.price,this.serves),this.priceFetched=!0)},error:t=>{console.error("Failed to fetch recipe pricing:",t)}});this.subscriptions.push(c)}};o=y([f("mealz-recipe-pricing")],o);customElements.get("mealz-recipe-pricing")||customElements.define("mealz-recipe-pricing",o);
1
+ import{N as P,B as m}from"../assets/no-shadow-element-D62BBu0I.js";import{V as b}from"../assets/viewport-listener-DsRHfwo4.js";import{t as f}from"../assets/custom-element-BhZVzxrc.js";import{w as I,m as n}from"../assets/mealz-sdk-E_fNZM-c.js";import{s as g}from"../assets/skipWhile-Beza3ws3.js";import{t as l}from"../assets/take-CpvJwza7.js";import{f as h}from"../assets/filter-q99GWcpD.js";import"../assets/debounceTime-Cf_7YmIn.js";import"../assets/async-C5Kj_SqM.js";import"../assets/OperatorSubscriber-DfCnFunn.js";import"../assets/empty-qrpgDBbc.js";class p{constructor(){this.priceMemorized=new Map,this.displayedPrices=new Set,this.cleanupInterval=null,this.MAX_MEMO_SIZE=500,this.CLEANUP_INTERVAL=600*1e3,this.handlePageUnload=()=>{this.destroy()},this.startAutoCleanup(),this.setupPageUnloadListener()}static getInstance(){return p.instance||(p.instance=new p),p.instance}getMemorizedPrice(e,r){const s=`${e}-${r}`;return this.priceMemorized.get(s)}memorizedPrice(e,r,s){const c=`${e}-${r}`;this.priceMemorized.size>=this.MAX_MEMO_SIZE&&this.cleanOldPrices(),this.priceMemorized.set(c,{price:s,guests:r})}isPriceDisplayed(e,r){const s=`${e}-${r}`;return this.displayedPrices.has(s)}markPriceAsDisplayed(e,r){const s=`${e}-${r}`;this.displayedPrices.add(s)}cleanOldPrices(){this.priceMemorized.size>this.MAX_MEMO_SIZE*.8&&Array.from(this.priceMemorized.entries()).slice(0,Math.floor(this.priceMemorized.size*.3)).forEach(([s])=>{this.priceMemorized.delete(s),this.displayedPrices.delete(s)})}clearAllPrices(){this.priceMemorized.clear(),this.displayedPrices.clear()}destroy(){window.removeEventListener("beforeunload",this.handlePageUnload),this.cleanupInterval&&(clearInterval(this.cleanupInterval),this.cleanupInterval=null),this.priceMemorized.clear(),this.displayedPrices.clear(),p.instance=null}startAutoCleanup(){this.cleanupInterval=window.setInterval(()=>{this.cleanOldPrices()},this.CLEANUP_INTERVAL)}setupPageUnloadListener(){window.addEventListener("beforeunload",this.handlePageUnload)}}var v=Object.getOwnPropertyDescriptor,y=(i,e,r,s)=>{for(var c=s>1?void 0:s?v(e,r):e,t=i.length-1,a;t>=0;t--)(a=i[t])&&(c=a(c)||c);return c};let o=class extends P{constructor(){super(...arguments),this.recipePricing=null,this.formattedPrice="",this.recipeId="",this.pricePerServe="",this.recipePricingValue=null,this.serves=0,this.posId="",this.extStoreId="",this.rendered=new m(!1),this.priceViewportObserver=null,this.priceFetched=!1,this.planner=!1,this.lastDisplayedRecipeId="",this.lastPlannerPrice=0,this.plannerPriceSubscription=null,this.lastAppliedPrice="",this.priceDisplayed=!1,this.subscriptions=[]}connectedCallback(){super.connectedCallback(),this.classList.add("re-rendering"),this.getInitialStatus(),this.listenInView(),I().then(()=>{this.setupSubscriptions()}).catch(i=>{console.warn("Failed to initialize SDK subscriptions:",i)}),requestAnimationFrame(()=>{this.classList.remove("re-rendering")})}disconnectedCallback(){var i;super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe()),this.plannerPriceSubscription&&(this.plannerPriceSubscription.unsubscribe(),this.plannerPriceSubscription=null),(i=this.priceViewportObserver)==null||i.disconnect()}setupSubscriptions(){const i=n;this.subscriptions.push(this.rendered.pipe(g(e=>!e),l(1)).subscribe(()=>{const e=i.basket.recipePricesInBasket$().subscribe(r=>{if(!r)return;const s=r.find(c=>c.id===this.recipeId);r.length>0&&s&&parseFloat(s.price)>0&&(this.serves=i.basket.guestsForRecipe(s.id),this.recipePricingValue={id:s.id,price:parseFloat(s.price),guests:this.serves},this.recalculatePrice(parseFloat(s.price),this.serves))});this.subscriptions.push(e)}),i.recipes.recipePriceUpdated().subscribe(e=>{e.recipeId===this.recipeId&&!e.inBasket&&this.recipePricingValue&&(this.recipePricingValue.price=e.remaining,this.recalculatePrice(e.remaining,this.serves))}),this.setupDisplayedRecipeSubscription(),this.setupGuestUpdatesSubscription(),this.setupMenuPriceSubscription())}setupDisplayedRecipeSubscription(){return n.recipes.displayedRecipe$.pipe(h(()=>this.planner&&!!this.recipeId)).subscribe(e=>{var r;((r=e==null?void 0:e.recipe)==null?void 0:r.id)===this.recipeId?(this.lastDisplayedRecipeId=this.recipeId,this.trackPlannerRecipePrice(),this.updateGuestCountFromMenu()):!(e!=null&&e.recipe)&&this.lastDisplayedRecipeId===this.recipeId&&(this.updatePriceFromCapturedPlannerPrice(),this.lastDisplayedRecipeId="",this.plannerPriceSubscription&&(this.plannerPriceSubscription.unsubscribe(),this.plannerPriceSubscription=null))})}setupGuestUpdatesSubscription(){return n.recipes.guestsUpdated().pipe(h(()=>!!this.recipeId)).subscribe(({guests:e,recipeId:r})=>{r===this.recipeId&&(this.serves=e,this.recipePricingValue&&this.recipePricingValue.price!==null&&this.recalculatePrice(this.recipePricingValue.price,this.serves))})}setupMenuPriceSubscription(){return n.planner.menuPrice$.pipe(h(()=>this.planner&&!!this.recipeId)).subscribe(()=>{if(this.lastPlannerPrice>0&&this.serves>0){const e=this.lastPlannerPrice/this.serves;this.applyCurrencyDisplay(e.toFixed(2))}})}fetchPrice(){const i=p.getInstance(),e=i.getMemorizedPrice(this.recipeId,this.serves);if(e){requestAnimationFrame(()=>{this.applyCurrencyDisplay(e.price),i.markPriceAsDisplayed(this.recipeId,this.serves)});return}this.fetchAndUpdatePrice()}render(){this.recipePricing=this.querySelector(".mealz-recipe-pricing"),this.recipePricing&&(this.recipeId&&this.pricePerServe&&p.getInstance().isPriceDisplayed(this.recipeId,this.serves)&&requestAnimationFrame(()=>{this.applyCurrencyDisplay(this.pricePerServe)}),this.rendered.next(!0),this.getInitialStatus())}getInitialStatus(){const i=this.attributes.getNamedItem("starting-data"),e=i==null?void 0:i.value;if(!e)return;const r=JSON.parse(e),{recipeId:s,extStoreId:c,posId:t,pricePerServe:a,serves:d,planner:u}=r;this.extStoreId=c||"",this.posId=t||"",this.recipeId=s,this.pricePerServe=(a==null?void 0:a.toString())??"",this.serves=d,this.planner=u||!1,this.recipePricingValue={id:this.recipeId,price:null,guests:this.serves},this.pricePerServe&&this.applyCurrencyDisplay(this.pricePerServe)}applyCurrencyDisplay(i){if(this.lastAppliedPrice===i)return;const e=parseFloat(i);isNaN(e)||(this.lastAppliedPrice=i,this.formattedPrice=e.toLocaleString("fr-FR",{minimumFractionDigits:2,maximumFractionDigits:2}),this.recipePricing||(this.recipePricing=this.querySelector(".mealz-recipe-pricing")),this.updateDOM())}showPrice(){var r,s;if(this.priceDisplayed)return;const i=(r=this.recipePricing)==null?void 0:r.querySelector(".mealz-recipe-pricing__loading"),e=(s=this.recipePricing)==null?void 0:s.querySelector(".mealz-recipe-pricing__wrapper");i==null||i.classList.replace("active","hidden"),e==null||e.classList.replace("hidden","active"),this.priceDisplayed=!0}updateDOM(){var e;const i=(e=this.recipePricing)==null?void 0:e.querySelector(".mealz-recipe-pricing__wrapper__price");i&&(i.innerHTML=this.formattedPrice+" €",this.showPrice())}recalculatePrice(i,e){const r=(i/e).toString();this.applyCurrencyDisplay(r)}trackPlannerRecipePrice(){const i=n;this.plannerPriceSubscription&&(this.plannerPriceSubscription.unsubscribe(),this.plannerPriceSubscription=null),this.plannerPriceSubscription=i.planner.plannerRecipePrice$.subscribe(e=>{e>0&&(this.lastPlannerPrice=e)})}updateGuestCountFromMenu(){if(!this.planner||!this.recipeId)return;n.planner.getGuestsForRecipe(this.recipeId).pipe(l(1)).subscribe(e=>{e&&e>0&&(this.serves=e)})}updatePriceFromCapturedPlannerPrice(){if(!this.planner||!this.recipeId)return;n.planner.isRecipeInMenu$(this.recipeId).pipe(l(1)).subscribe(e=>{if(e&&this.lastPlannerPrice>0){if(this.serves>0){const r=this.lastPlannerPrice/this.serves;this.applyCurrencyDisplay(r.toFixed(2))}}else this.pricePerServe&&this.applyCurrencyDisplay(this.pricePerServe)})}listenInView(){this.priceViewportObserver=new b(this,()=>{var i;!this.priceFetched&&((i=this.recipePricingValue)==null?void 0:i.price)===null&&this.fetchPrice()})}fetchAndUpdatePrice(){const i=this.posId||this.extStoreId,e=!!this.extStoreId;if(!i||!this.recipeId||!this.serves)return;const c=n.recipes.fetchPricing(this.recipeId,i,this.serves,e).subscribe({next:t=>{t&&t["price-per-serve"]&&(this.pricePerServe=t["price-per-serve"].toString(),this.recipePricingValue={id:this.recipeId,price:t.price,guests:this.serves},this.recalculatePrice(t.price,this.serves),this.priceFetched=!0)},error:t=>{console.error("Failed to fetch recipe pricing:",t)}});this.subscriptions.push(c)}};o=y([f("mealz-recipe-pricing")],o);customElements.get("mealz-recipe-pricing")||customElements.define("mealz-recipe-pricing",o);
@@ -0,0 +1 @@
1
+ .mealz-recipe-to-basket{display:flex;flex-direction:column}.mealz-recipe-to-basket>*:not(:last-child){margin-bottom:16px}
@@ -0,0 +1 @@
1
+ import{t as p}from"../assets/custom-element-BhZVzxrc.js";import{N as h}from"../assets/no-shadow-element-D62BBu0I.js";import{w as d,m as o}from"../assets/mealz-sdk-E_fNZM-c.js";import{G as g}from"../assets/guestObserver-C5qvv1Ll.js";import"../assets/singleton-COF3iBbF.js";var m=Object.getOwnPropertyDescriptor,v=(t,e,a,i)=>{for(var s=i>1?void 0:i?m(e,a):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(s=n(s)||s);return s};let c=class extends h{constructor(){super(),this.plannerMode=!1,this.analyticsPath="",this.counterListener=t=>this.onCounterValueChange(t),this.guestObserverService=g.getInstance(),this.styleURL=new URL("./recipe-to-basket/recipe-to-basket.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.initializeFromStartingData(),this.addEventListener("valueChange",this.counterListener)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("valueChange",this.counterListener)}initializeFromStartingData(){const t=this.getAttribute("starting-data");if(t){try{const e=JSON.parse(t),a=typeof e.recipeId=="string"?e.recipeId:void 0,i=typeof e.guests=="number"?e.guests:void 0;this.plannerMode=!!e.planner,this.guests=i,a&&(this.analyticsPath=`/recipes/${a}/shopping`,d().then(()=>{var s,r;(r=(s=o)==null?void 0:s.recipes)==null||r.loadAndSetupRecipe(a,i).subscribe()}))}catch(e){console.warn("[mealz-recipe-to-basket] invalid starting-data attribute",e),this.removeAttribute("starting-data");return}this.removeAttribute("starting-data")}}onCounterValueChange(t){var s,r,n,u,l;const e=t.target;if(!(e!=null&&e.closest("mealz-counter")))return;const a=(s=t.detail)==null?void 0:s.value;if(typeof a!="number"||this.guests===a)return;this.guests=a,this.guestObserverService.updateGuests(this.guests);const i={originPath:this.analyticsPath,props:{}};this.plannerMode&&((n=(r=o)==null?void 0:r.planner)!=null&&n.updateGuests)?o.planner.updateGuests(this.guests,i):(l=(u=o)==null?void 0:u.recipes)==null||l.updateGuests(i,this.guests)}};c=v([p("mealz-recipe-to-basket")],c);customElements.get("mealz-recipe-to-basket")||customElements.define("mealz-recipe-to-basket",c);
@@ -1,4 +1,4 @@
1
- import"../../assets/promotion-badge-8Arhhb-p.js";import{N as n,k as s}from"../../assets/no-shadow-element-YPHUv5PR.js";import{t as h}from"../../assets/custom-element-BhZVzxrc.js";import{n as p}from"../../assets/property-_7ObQ3dl.js";import{g as u,a as z}from"../../assets/price-utils-BRFZa-3D.js";import{m as o}from"../../assets/mealz-sdk-E_fNZM-c.js";import"../../assets/price-DAxY_7sk.js";var b=Object.defineProperty,_=Object.getOwnPropertyDescriptor,l=(e,i,c,a)=>{for(var t=a>1?void 0:a?_(i,c):i,m=e.length-1,d;m>=0;m--)(d=e[m])&&(t=(a?d(i,c,t):d(t))||t);return a&&t&&b(i,c,t),t};let r=class extends n{constructor(){super(),this.noSupplier=o.supplier.isNoSupplier(),this.subscriptions=[],this.styleURL=new URL("./replace-item/replace-item-card/replace-item-card.css",this.getBaseURL()),this.subscriptions.push(o.replaceItem.replaceItemLoading$.subscribe(e=>{this.replaceItemLoading=e,this.requestUpdate()}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}onSelectItem(e){const i={detail:{item:e},bubbles:!0,composed:!0};this.dispatchEvent(new CustomEvent("selectItem",i))}render(){var e,i,c,a,t,m;return s`
1
+ import"../../assets/promotion-badge-B-er7bV2.js";import{N as n,k as s}from"../../assets/no-shadow-element-D62BBu0I.js";import{t as h}from"../../assets/custom-element-BhZVzxrc.js";import{n as p}from"../../assets/property-CoRN-Ln2.js";import{g as u,a as z}from"../../assets/price-utils-BRFZa-3D.js";import{m as o}from"../../assets/mealz-sdk-E_fNZM-c.js";import"../../assets/price-D6RVRYHJ.js";import"../../assets/singleton-COF3iBbF.js";var b=Object.defineProperty,_=Object.getOwnPropertyDescriptor,l=(e,i,c,a)=>{for(var t=a>1?void 0:a?_(i,c):i,m=e.length-1,d;m>=0;m--)(d=e[m])&&(t=(a?d(i,c,t):d(t))||t);return a&&t&&b(i,c,t),t};let r=class extends n{constructor(){super(),this.noSupplier=o.supplier.isNoSupplier(),this.subscriptions=[],this.styleURL=new URL("./replace-item/replace-item-card/replace-item-card.css",this.getBaseURL()),this.subscriptions.push(o.replaceItem.replaceItemLoading$.subscribe(e=>{this.replaceItemLoading=e,this.requestUpdate()}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}onSelectItem(e){const i={detail:{item:e},bubbles:!0,composed:!0};this.dispatchEvent(new CustomEvent("selectItem",i))}render(){var e,i,c,a,t,m;return s`
2
2
  <div
3
3
  class="
4
4
  mealz-replace-item-card
@@ -1,6 +1,6 @@
1
- import"./replace-item-card/replace-item-card.min.js";import{N as h,n as u,D as o,k as i}from"../assets/no-shadow-element-YPHUv5PR.js";import{t as g}from"../assets/custom-element-BhZVzxrc.js";import{c as _}from"../assets/capitalize-DUAqYmp4.js";import{m as s}from"../assets/mealz-sdk-E_fNZM-c.js";import{m as b}from"../assets/merge-Cm-mm3_Q.js";import{m as n}from"../assets/map-BVOhpQm0.js";import{d as z}from"../assets/debounceTime-B4DpnstH.js";import{f as v}from"../assets/filter-BZ75lS5D.js";import{d as S}from"../assets/distinctUntilChanged-91AVuO2B.js";import{s as $}from"../assets/switchMap-Dk_0Nhlo.js";import"../assets/promotion-badge-8Arhhb-p.js";import"../assets/property-_7ObQ3dl.js";import"../assets/price-DAxY_7sk.js";import"../assets/price-utils-BRFZa-3D.js";import"../assets/mergeAll-BdUAXyrs.js";import"../assets/mergeMap-Dw_YYHwH.js";import"../assets/innerFrom-BgPDnAsH.js";import"../assets/OperatorSubscriber-BaYaQC1O.js";import"../assets/executeSchedule-CEDvgTzM.js";import"../assets/empty-0eVnsLmk.js";import"../assets/args-BozZ6oU-.js";import"../assets/isScheduler-C5PGPVU1.js";import"../assets/from-CAidt5N1.js";import"../assets/async-CFBGA-Dz.js";var f=Object.getOwnPropertyDescriptor,I=(e,t,c,a)=>{for(var r=a>1?void 0:a?f(t,c):t,l=e.length-1,m;l>=0;l--)(m=e[l])&&(r=m(r)||r);return r};let p=class extends h{constructor(){super(),this.addProductMode=!1,this.fromRecipeDetails=!1,this.isLoading=!1,this.subscriptions=[],this.searchString="",this.itemsWithPricesList=[],this.searchSubject=new u,this.styleURL=new URL("./replace-item/replace-item.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(this.setupSearchObservable(),s.replaceItem.basketEntryToReplace$.subscribe(e=>{this.handleToReplace(e)}),b(s.recipes.displayedRecipe$.pipe(n(e=>{var t;this.currentRecipeId=(t=e==null?void 0:e.recipe)==null?void 0:t.id,this.fromRecipeDetails=!!this.currentRecipeId})),s.replaceItem.replaceProductFromPreviewOpen$.pipe(n(e=>{this.basketEntry=e})),s.replaceItem.additionModalOpen$.pipe(n(e=>{this.addProductMode=e})),s.replaceItem.itemsWithPricesList$.pipe(n(e=>{this.itemsWithPricesList=e})),s.replaceItem.fetchingItemLoading$.pipe(n(e=>{this.isLoading=e}))).subscribe(()=>this.requestUpdate()))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}handleToReplace(e){if(this.searchString="",!e){this.basketEntry=void 0,this.ingredient=void 0,this.ignoreSelected=!1;return}this.basketEntry=e.basketEntry,this.ingredient=e.ingredient,this.ignoreSelected=e.ignoreSelected||!1,this.requestUpdate()}onClose(){s.replaceItem.replaceItemLoading$.next(void 0),s.replaceItem.basketEntryToReplace$.next(void 0),s.productAddition.close()}onSearchInputChange(e){this.searchString=e.target.value,this.searchSubject.next(this.searchString)}setupSearchObservable(){return this.searchSubject.pipe(z(200),v(e=>e.length>=3),S(),$(e=>s.replaceItem.searchItem(e))).subscribe()}onSelectItem(e){var a;const t=(a=this.basketEntry)==null?void 0:a.id,c=this.fromRecipeDetails?`/recipes/${this.currentRecipeId}/shopping`:"/basket/products";s.replaceItem.onSelectItem(e.detail.item,this.searchString,()=>{this.onClose(),s.productAddition.productAdded$.next(t)},{originPath:`${c}/item-selector`,props:{}})}renderIssues(){var e,t;return i`
1
+ import"./replace-item-card/replace-item-card.min.js";import{N as g,n as b,D as d,k as l}from"../assets/no-shadow-element-D62BBu0I.js";import{t as _}from"../assets/custom-element-BhZVzxrc.js";import{c as v}from"../assets/capitalize-DUAqYmp4.js";import{m as c}from"../assets/mealz-sdk-E_fNZM-c.js";import{G as f}from"../assets/guestObserver-C5qvv1Ll.js";import{m as z}from"../assets/merge-DzIA6T0M.js";import{m}from"../assets/map-DT-7dkaR.js";import{d as I}from"../assets/debounceTime-Cf_7YmIn.js";import{f as S}from"../assets/filter-q99GWcpD.js";import{d as $}from"../assets/distinctUntilChanged-kXqVrZ5h.js";import{s as y}from"../assets/switchMap-BAdE9Uzw.js";import"../assets/promotion-badge-B-er7bV2.js";import"../assets/property-CoRN-Ln2.js";import"../assets/price-D6RVRYHJ.js";import"../assets/singleton-COF3iBbF.js";import"../assets/price-utils-BRFZa-3D.js";import"../assets/mergeAll-DpEYIxY3.js";import"../assets/mergeMap-D2yctTHQ.js";import"../assets/innerFrom-DePszgj9.js";import"../assets/OperatorSubscriber-DfCnFunn.js";import"../assets/executeSchedule-CEDvgTzM.js";import"../assets/empty-qrpgDBbc.js";import"../assets/args-DAL2bHut.js";import"../assets/isScheduler-CqHuyMwD.js";import"../assets/from-D8c5akO7.js";import"../assets/async-C5Kj_SqM.js";var E=Object.getOwnPropertyDescriptor,P=(e,t,r,s)=>{for(var i=s>1?void 0:s?E(t,r):t,a=e.length-1,n;a>=0;a--)(n=e[a])&&(i=n(i)||i);return i};let u=class extends g{constructor(){super(),this.addProductMode=!1,this.fromRecipeDetails=!1,this.isLoading=!1,this.subscriptions=[],this.searchString="",this.itemsWithPricesList=[],this.searchSubject=new b,this.guestObserverService=f.getInstance(),this.initialGuests=1,this.currentGuests=1,this.styleURL=new URL("./replace-item/replace-item.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(this.setupSearchObservable(),c.replaceItem.basketEntryToReplace$.subscribe(e=>{this.handleToReplace(e)}),z(c.recipes.displayedRecipe$.pipe(m(e=>{var r,s,i,a;const t=(r=e==null?void 0:e.recipe)==null?void 0:r.id;if(t){this.currentRecipeId=t,this.fromRecipeDetails=!0;const n=((i=(s=e==null?void 0:e.recipe)==null?void 0:s.attributes)==null?void 0:i["number-of-guests"])||1,o=(a=e==null?void 0:e.recipe)==null?void 0:a.modifiedGuests;this.initialGuests=Number(n)||1,this.currentGuests=Number(o||n)||1,this.calculateQty()}})),c.replaceItem.replaceProductFromPreviewOpen$.pipe(m(e=>{e&&(this.basketEntry=e)})),c.replaceItem.additionModalOpen$.pipe(m(e=>{this.addProductMode=e})),c.replaceItem.itemsWithPricesList$.pipe(m(e=>{this.itemsWithPricesList=e})),c.replaceItem.fetchingItemLoading$.pipe(m(e=>{this.isLoading=e}))).subscribe(()=>this.requestUpdate()),this.guestObserverService.guests$.subscribe(e=>{this.currentGuests=Number(e)||this.currentGuests||1,this.calculateQty()}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}handleToReplace(e){var r;if(this.searchString="",!e){this.basketEntry=void 0,this.ingredient=void 0,this.ignoreSelected=!1;return}this.basketEntry=e.basketEntry,this.ingredient=e.ingredient,this.ignoreSelected=e.ignoreSelected||!1,e.initialGuests&&(this.initialGuests=Number(e.initialGuests)||this.initialGuests),e.currentGuests&&(this.currentGuests=Number(e.currentGuests)||this.currentGuests);const t=this.basketEntry;if(t&&t.name&&!(t.attributes&&t.attributes.name)&&(t.attributes={...t.attributes||{},name:t.name}),this.ingredient&&(this.fromRecipeDetails=!0,!this.currentRecipeId)){const s=this.basketEntry,i=(s==null?void 0:s.recipesIds)&&s.recipesIds[0]||((r=s==null?void 0:s.attributes)==null?void 0:r["recipe-ids"])&&s.attributes["recipe-ids"][0];i&&(this.currentRecipeId=String(i))}this.calculateQty(),this.requestUpdate()}calculateQty(){var i,a,n;if(!this.ingredient)return;const e=((i=this.ingredient)==null?void 0:i.quantity)??((n=(a=this.ingredient)==null?void 0:a.attributes)==null?void 0:n.quantity),t=Number(e);if(!Number.isFinite(t))return;const r=this.initialGuests||1,s=t/r;this.modifiedIngQty=Number((s*(this.currentGuests||r)).toFixed(2))}onClose(){c.replaceItem.replaceItemLoading$.next(void 0),c.replaceItem.basketEntryToReplace$.next(void 0),c.productAddition.close()}onSearchInputChange(e){this.searchString=e.target.value,this.searchSubject.next(this.searchString)}setupSearchObservable(){return this.searchSubject.pipe(I(200),S(e=>e.length>=3),$(),y(e=>c.replaceItem.searchItem(e))).subscribe()}onSelectItem(e){var s;const t=(s=this.basketEntry)==null?void 0:s.id,r=this.fromRecipeDetails?`/recipes/${this.currentRecipeId}/shopping`:"/basket/products";c.replaceItem.onSelectItem(e.detail.item,this.searchString,()=>{this.onClose(),c.productAddition.productAdded$.next(t)},{originPath:`${r}/item-selector`,props:{}})}renderIssues(){var e,t;return l`
2
2
  <!-- NO SUBSTITUTION PRODUCT -->
3
- ${!this.isLoading&&this.itemsWithPricesList.length===1&&!this.searchString?i`
3
+ ${!this.isLoading&&this.itemsWithPricesList.length===1&&!this.searchString?l`
4
4
  <div class="mealz-replace-item__error">
5
5
  <div class="mealz-replace-item__error-image-container small-img">
6
6
  <img class="mealz-replace-item__error-image"
@@ -13,10 +13,10 @@ import"./replace-item-card/replace-item-card.min.js";import{N as h,n as u,D as o
13
13
  <span>Aucun produit de substitution trouvé</span>
14
14
  </span>
15
15
  </div>
16
- `:o}
16
+ `:d}
17
17
 
18
18
  <!-- NO PRODUCTS FOUND -->
19
- ${!this.addProductMode&&!this.isLoading&&this.itemsWithPricesList.length===0?i`
19
+ ${!this.addProductMode&&!this.isLoading&&this.itemsWithPricesList.length===0?l`
20
20
  <div class="mealz-replace-item__error">
21
21
  <div class="mealz-replace-item__error-image-container">
22
22
  <img class="mealz-replace-item__error-image"
@@ -27,8 +27,8 @@ import"./replace-item-card/replace-item-card.min.js";import{N as h,n as u,D as o
27
27
  <span class="mealz-replace-item__issue-title mealz-replace-item__issue-title__not-found mealz-ds-text"><span>Aucun produit trouvé pour cette recherche</span></span>
28
28
  <span class="mealz-replace-item__issue-description mealz-ds-text weight-xxl"><span>Essayez avec un autre mot-clé</span></span>
29
29
  </div>
30
- `:o}
31
- `}render(){var e,t,c,a,r,l;return i`
30
+ `:d}
31
+ `}render(){var e,t,r,s,i,a,n,o;return l`
32
32
  <div class="mealz-replace-item">
33
33
  <!-- HEADER -->
34
34
  <div class="mealz-replace-item__header mealz-ds-text weight-xxl">
@@ -40,7 +40,7 @@ import"./replace-item-card/replace-item-card.min.js";import{N as h,n as u,D as o
40
40
  class="mealz-replace-item__back-button-icon"
41
41
  >
42
42
  </button>
43
- ${(e=this.basketEntry)!=null&&e.selectedItem&&!this.ignoreSelected&&!this.addProductMode?i`<span>Remplacer un produit</span>`:i`<span>Ajouter un produit</span>`}
43
+ ${(e=this.basketEntry)!=null&&e.selectedItem&&!this.ignoreSelected&&!this.addProductMode?l`<span>Remplacer un produit</span>`:l`<span>Ajouter un produit</span>`}
44
44
  </div>
45
45
  <div class="mealz-replace-item__top-container">
46
46
  <!-- SEARCH -->
@@ -57,32 +57,32 @@ import"./replace-item-card/replace-item-card.min.js";import{N as h,n as u,D as o
57
57
  <div class="mealz-ds-loader ${this.isLoading?"":"hidden"}"></div>
58
58
  </div>
59
59
  <!-- PRODUCT NEEDED BANNER -->
60
- ${this.fromRecipeDetails?i`
60
+ ${this.fromRecipeDetails?l`
61
61
  <div class="mealz-replace-item__product-banner">
62
62
  <span class="mealz-replace-item__banner-product-name mealz-ds-text size-s">
63
- <span>${_(((c=(t=this.basketEntry)==null?void 0:t.attributes)==null?void 0:c.name)||"")} :</span>
63
+ <span>${v(((r=(t=this.basketEntry)==null?void 0:t.attributes)==null?void 0:r.name)||"")} :</span>
64
64
  <span class="mealz-replace-item__banner-quantity mealz-ds-text weight-xxl">
65
- ${this.modifiedIngQty||((a=this.ingredient)==null?void 0:a.quantity)} ${(l=(r=this.ingredient)==null?void 0:r.attributes)==null?void 0:l.unit}
65
+ ${this.modifiedIngQty||((s=this.ingredient)==null?void 0:s.quantity)||((a=(i=this.ingredient)==null?void 0:i.attributes)==null?void 0:a.quantity)} ${(o=(n=this.ingredient)==null?void 0:n.attributes)==null?void 0:o.unit}
66
66
  </span>
67
67
  </span>
68
68
  </div>
69
- `:o}
69
+ `:d}
70
70
  </div>
71
71
  <!-- PRODUCT LIST GRID -->
72
72
  <div class="mealz-replace-item__product-list ${this.itemsWithPricesList.length<2?"full-width":""}">
73
73
  <!-- PRODUCT CARD -->
74
- ${this.itemsWithPricesList.map((m,d)=>i`
74
+ ${this.itemsWithPricesList.map((p,h)=>l`
75
75
  <mealz-replace-item-card
76
- .itemWithPrice=${m}
77
- .index=${d}
76
+ .itemWithPrice=${p}
77
+ .index=${h}
78
78
  .basketEntry=${this.basketEntry}
79
- .ignoreSelected=${this.ignoreSelected}
79
+ .ignoreSelected=${!!this.ignoreSelected}
80
80
  @selectItem=${this.onSelectItem}
81
81
  ></mealz-replace-item-card>`)}
82
82
  <!-- ISSUES -->
83
83
  ${this.renderIssues()}
84
84
  <!-- ADD PRODUCT DEFAULT VIEW -->
85
- ${this.addProductMode&&!this.isLoading&&this.itemsWithPricesList.length===0?i`
85
+ ${this.addProductMode&&!this.isLoading&&this.itemsWithPricesList.length===0?l`
86
86
  <div class="mealz-replace-item__add-product-default">
87
87
  <div class="mealz-replace-item__add-product-image-container">
88
88
  <img class="mealz-replace-item__add-product-image"
@@ -90,7 +90,7 @@ import"./replace-item-card/replace-item-card.min.js";import{N as h,n as u,D as o
90
90
  alt="search icon"/>
91
91
  </div>
92
92
  <span class="mealz-replace-item__add-product-title mealz-ds-text">Trouver une liste de produit en effectuant votre recherche</span>
93
- </div>`:o}
93
+ </div>`:d}
94
94
  </div>
95
95
  </div>
96
- `}};p=I([g("mealz-replace-item")],p);customElements.get("mealz-replace-item")||customElements.define("mealz-replace-item",p);
96
+ `}};u=P([_("mealz-replace-item")],u);customElements.get("mealz-replace-item")||customElements.define("mealz-replace-item",u);
@@ -1,4 +1,4 @@
1
- import"../../assets/promotion-badge-8Arhhb-p.js";import{N as d,k as t}from"../../assets/no-shadow-element-YPHUv5PR.js";import{t as o}from"../../assets/custom-element-BhZVzxrc.js";import{n}from"../../assets/property-_7ObQ3dl.js";import{g as h,a as u}from"../../assets/price-utils-BRFZa-3D.js";import{m as z}from"../../assets/mealz-sdk-E_fNZM-c.js";import"../../assets/price-DAxY_7sk.js";var P=Object.defineProperty,_=Object.getOwnPropertyDescriptor,p=(a,r,l,s)=>{for(var e=s>1?void 0:s?_(r,l):r,c=a.length-1,m;c>=0;c--)(m=a[c])&&(e=(s?m(r,l,e):m(e))||e);return s&&e&&P(r,l,e),e};let i=class extends d{constructor(){super(),this.noSupplier=z.supplier.isNoSupplier(),this.styleURL=new URL("./replace-item-planner/replace-item-card-planner/replace-item-card-planner.css",this.getBaseURL())}onSelectItem(){this.itemWithPrice.status="ticked";const a={detail:{itemWithPrice:this.itemWithPrice},bubbles:!0,composed:!0};this.dispatchEvent(new CustomEvent("selectItem",a)),this.requestUpdate()}render(){return t`
1
+ import"../../assets/promotion-badge-B-er7bV2.js";import{N as d,k as t}from"../../assets/no-shadow-element-D62BBu0I.js";import{t as o}from"../../assets/custom-element-BhZVzxrc.js";import{n}from"../../assets/property-CoRN-Ln2.js";import{g as h,a as u}from"../../assets/price-utils-BRFZa-3D.js";import{m as z}from"../../assets/mealz-sdk-E_fNZM-c.js";import"../../assets/price-D6RVRYHJ.js";import"../../assets/singleton-COF3iBbF.js";var P=Object.defineProperty,_=Object.getOwnPropertyDescriptor,p=(a,r,l,s)=>{for(var e=s>1?void 0:s?_(r,l):r,c=a.length-1,m;c>=0;c--)(m=a[c])&&(e=(s?m(r,l,e):m(e))||e);return s&&e&&P(r,l,e),e};let i=class extends d{constructor(){super(),this.noSupplier=z.supplier.isNoSupplier(),this.styleURL=new URL("./replace-item-planner/replace-item-card-planner/replace-item-card-planner.css",this.getBaseURL())}onSelectItem(){this.itemWithPrice.status="ticked";const a={detail:{itemWithPrice:this.itemWithPrice},bubbles:!0,composed:!0};this.dispatchEvent(new CustomEvent("selectItem",a)),this.requestUpdate()}render(){return t`
2
2
  <div class=" mealz-replace-item-card-planner
3
3
  ${this.itemWithPrice.status==="ticked"?"selected":""}"
4
4
  >
@@ -1,4 +1,4 @@
1
- import"./replace-item-card-planner/replace-item-card-planner.min.js";import{N as h,n as d,D as o,k as a}from"../assets/no-shadow-element-YPHUv5PR.js";import{c as u}from"../assets/capitalize-DUAqYmp4.js";import{t as g}from"../assets/custom-element-BhZVzxrc.js";import{m as i}from"../assets/mealz-sdk-E_fNZM-c.js";import{m as _}from"../assets/merge-Cm-mm3_Q.js";import{m}from"../assets/map-BVOhpQm0.js";import{d as b}from"../assets/debounceTime-B4DpnstH.js";import{f as z}from"../assets/filter-BZ75lS5D.js";import{d as v}from"../assets/distinctUntilChanged-91AVuO2B.js";import{s as S}from"../assets/switchMap-Dk_0Nhlo.js";import"../assets/promotion-badge-8Arhhb-p.js";import"../assets/property-_7ObQ3dl.js";import"../assets/price-DAxY_7sk.js";import"../assets/price-utils-BRFZa-3D.js";import"../assets/mergeAll-BdUAXyrs.js";import"../assets/mergeMap-Dw_YYHwH.js";import"../assets/innerFrom-BgPDnAsH.js";import"../assets/OperatorSubscriber-BaYaQC1O.js";import"../assets/executeSchedule-CEDvgTzM.js";import"../assets/empty-0eVnsLmk.js";import"../assets/args-BozZ6oU-.js";import"../assets/isScheduler-C5PGPVU1.js";import"../assets/from-CAidt5N1.js";import"../assets/async-CFBGA-Dz.js";var f=Object.getOwnPropertyDescriptor,$=(e,t,s,n)=>{for(var r=n>1?void 0:n?f(t,s):t,l=e.length-1,c;l>=0;l--)(c=e[l])&&(r=c(r)||r);return r};let p=class extends h{constructor(){super(),this.isLoading=!1,this.subscriptions=[],this.searchString="",this.itemsWithPricesList=[],this.analyticsPath="/meals-planner/current",this.searchSubject=new d,this.styleURL=new URL("./replace-item-planner/replace-item-planner.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(this.setupSearchObservable(),i.planner.itemToReplace$.subscribe(e=>{this.handleToReplace(e)}),_(i.recipes.displayedRecipe$.pipe(m(e=>{var t;this.currentRecipeId=(t=e==null?void 0:e.recipe)==null?void 0:t.id})),i.planner.itemsWithPricesList$.pipe(m(e=>{this.itemsWithPricesList=e})),i.planner.fetchingItemLoading$.pipe(m(e=>{this.isLoading=e}))).subscribe(()=>{this.requestUpdate()}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}handleToReplace(e){if(this.searchString="",!e){this.item=void 0,this.ingredient=void 0;return}this.item=e.item,this.ingredient=e.ingredient,this.requestUpdate()}onClose(){i.planner.itemToReplace$.next(void 0)}onSearchInputChange(e){this.searchString=e.target.value,this.searchSubject.next(this.searchString)}setupSearchObservable(){return this.searchSubject.pipe(b(200),z(e=>e.length>=3),v(),S(e=>i.planner.searchItem(e,this.ingredient,this.item))).subscribe()}onSelectItem(e){this.replacedItemEvent(e.detail.itemWithPrice),i.planner.replaceProduct(e.detail.itemWithPrice),this.item=e.detail.itemWithPrice.item,this.onClose()}formatNumber(e){const t=i.user.getLanguage()||"fr";return new Intl.NumberFormat(t,{minimumFractionDigits:1,maximumFractionDigits:2}).format(e)}renderIssues(){var e,t;return a`
1
+ import"./replace-item-card-planner/replace-item-card-planner.min.js";import{N as h,n as d,D as o,k as a}from"../assets/no-shadow-element-D62BBu0I.js";import{c as u}from"../assets/capitalize-DUAqYmp4.js";import{t as g}from"../assets/custom-element-BhZVzxrc.js";import{m as i}from"../assets/mealz-sdk-E_fNZM-c.js";import{m as _}from"../assets/merge-DzIA6T0M.js";import{m}from"../assets/map-DT-7dkaR.js";import{d as b}from"../assets/debounceTime-Cf_7YmIn.js";import{f as z}from"../assets/filter-q99GWcpD.js";import{d as v}from"../assets/distinctUntilChanged-kXqVrZ5h.js";import{s as S}from"../assets/switchMap-BAdE9Uzw.js";import"../assets/promotion-badge-B-er7bV2.js";import"../assets/property-CoRN-Ln2.js";import"../assets/price-D6RVRYHJ.js";import"../assets/singleton-COF3iBbF.js";import"../assets/price-utils-BRFZa-3D.js";import"../assets/mergeAll-DpEYIxY3.js";import"../assets/mergeMap-D2yctTHQ.js";import"../assets/innerFrom-DePszgj9.js";import"../assets/OperatorSubscriber-DfCnFunn.js";import"../assets/executeSchedule-CEDvgTzM.js";import"../assets/empty-qrpgDBbc.js";import"../assets/args-DAL2bHut.js";import"../assets/isScheduler-CqHuyMwD.js";import"../assets/from-D8c5akO7.js";import"../assets/async-C5Kj_SqM.js";var f=Object.getOwnPropertyDescriptor,$=(e,t,s,n)=>{for(var r=n>1?void 0:n?f(t,s):t,l=e.length-1,c;l>=0;l--)(c=e[l])&&(r=c(r)||r);return r};let p=class extends h{constructor(){super(),this.isLoading=!1,this.subscriptions=[],this.searchString="",this.itemsWithPricesList=[],this.analyticsPath="/meals-planner/current",this.searchSubject=new d,this.styleURL=new URL("./replace-item-planner/replace-item-planner.css",this.getBaseURL())}connectedCallback(){super.connectedCallback(),this.subscriptions.push(this.setupSearchObservable(),i.planner.itemToReplace$.subscribe(e=>{this.handleToReplace(e)}),_(i.recipes.displayedRecipe$.pipe(m(e=>{var t;this.currentRecipeId=(t=e==null?void 0:e.recipe)==null?void 0:t.id})),i.planner.itemsWithPricesList$.pipe(m(e=>{this.itemsWithPricesList=e})),i.planner.fetchingItemLoading$.pipe(m(e=>{this.isLoading=e}))).subscribe(()=>{this.requestUpdate()}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}handleToReplace(e){if(this.searchString="",!e){this.item=void 0,this.ingredient=void 0;return}this.item=e.item,this.ingredient=e.ingredient,this.requestUpdate()}onClose(){i.planner.itemToReplace$.next(void 0)}onSearchInputChange(e){this.searchString=e.target.value,this.searchSubject.next(this.searchString)}setupSearchObservable(){return this.searchSubject.pipe(b(200),z(e=>e.length>=3),v(),S(e=>i.planner.searchItem(e,this.ingredient,this.item))).subscribe()}onSelectItem(e){this.replacedItemEvent(e.detail.itemWithPrice),i.planner.replaceProduct(e.detail.itemWithPrice),this.item=e.detail.itemWithPrice.item,this.onClose()}formatNumber(e){const t=i.user.getLanguage()||"fr";return new Intl.NumberFormat(t,{minimumFractionDigits:1,maximumFractionDigits:2}).format(e)}renderIssues(){var e,t;return a`
2
2
  <!-- NO SUBSTITUTION PRODUCT -->
3
3
  ${!this.isLoading&&this.itemsWithPricesList.length===1&&!this.searchString?a`
4
4
  <div class="mealz-replace-item-planner__error">