var m=Object.defineProperty;var g=(n,t,e)=>t in n?m(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var o=(n,t,e)=>g(n,typeof t!="symbol"?t+"":t,e);import{d as c}from"./vendor-CI5NvTnj.js";const l=1800,h=800,M=30,N=h*.85,I=7,y=8,P=10;class f{constructor(t){o(this,"nutritionPerPortion",(t,e,s,i=100)=>Number.parseFloat(t)*(s*e/i));o(this,"roundNutrition",t=>t?Number(t.toFixed(2)):0);this.mix=t}calculate(){this.resetNutrients();let t=0;const{base:e,basePercent:s,nutrients:i,nonBaseItems:a}=this.mix;for(const r of a)t+=r.ingredient.weight*r.amount,i.fats=i.fats+this.nutritionPerPortion(r.ingredient.fats,r.ingredient.weight,r.amount),i.saturatedFats=i.saturatedFats+this.nutritionPerPortion(r.ingredient.saturatedFats,r.ingredient.weight,r.amount),i.carbohydrates=i.carbohydrates+this.nutritionPerPortion(r.ingredient.carbohydrates,r.ingredient.weight,r.amount),i.sugars=i.sugars+this.nutritionPerPortion(r.ingredient.sugars,r.ingredient.weight,r.amount),i.fibre=i.fibre+this.nutritionPerPortion(r.ingredient.fibre,r.ingredient.weight,r.amount),i.proteins=i.proteins+this.nutritionPerPortion(r.ingredient.proteins,r.ingredient.weight,r.amount),i.salt=i.salt+this.nutritionPerPortion(r.ingredient.salt,r.ingredient.weight,r.amount),i.energy=i.energy+this.nutritionPerPortion(r.ingredient.energy,r.ingredient.weight,r.amount);if(e!==void 0){const r=e.ingredient.weight*(s/100);t+=r,i.fats=i.fats+this.nutritionPerPortion(e.ingredient.fats,r,e.amount),i.saturatedFats=i.saturatedFats+this.nutritionPerPortion(e.ingredient.saturatedFats,r,e.amount),i.carbohydrates=i.carbohydrates+this.nutritionPerPortion(e.ingredient.carbohydrates,r,e.amount),i.sugars=i.sugars+this.nutritionPerPortion(e.ingredient.sugars,r,e.amount),i.fibre=i.fibre+this.nutritionPerPortion(e.ingredient.fibre,r,e.amount),i.proteins=i.proteins+this.nutritionPerPortion(e.ingredient.proteins,r,e.amount),i.salt=i.salt+this.nutritionPerPortion(e.ingredient.salt,r,e.amount),i.energy=i.energy+this.nutritionPerPortion(e.ingredient.energy,r,e.amount)}const u=i.energy*100/t;i.fats=this.roundNutrition(i.fats*100/t),i.saturatedFats=this.roundNutrition(i.saturatedFats*100/t),i.carbohydrates=this.roundNutrition(i.carbohydrates*100/t),i.sugars=this.roundNutrition(i.sugars*100/t),i.fibre=this.roundNutrition(i.fibre*100/t),i.proteins=this.roundNutrition(i.proteins*100/t),i.salt=this.roundNutrition(i.salt*100/t),i.energy=this.roundNutrition(u),i.energyKcal=this.roundNutrition(u/4.185)}resetNutrients(){this.mix.nutrients={fats:0,saturatedFats:0,carbohydrates:0,sugars:0,fibre:0,proteins:0,salt:0,energy:0,energyKcal:0}}}class d{constructor(t){o(this,"name");o(this,"state","new");o(this,"quantity",1);o(this,"items",[]);o(this,"nutrients",{fats:0,saturatedFats:0,carbohydrates:0,sugars:0,fibre:0,proteins:0,salt:0,energy:0,energyKcal:0});this.kind=t}isEmpty(){var t;return((t=this.items)==null?void 0:t.length)===0}calculateNutrients(){new f(this).calculate()}incrementQuantity(){this.quantity++}decrementQuantity(){this.quantity>1&&this.quantity--}serializeMix(){return{kind:this.kind,name:this.name,items:this.items.map(t=>({id:t.ingredient.id,quantity:t.amount}))}}get totalNonBaseItemsQuantity(){return this.nonBaseItems.map(t=>t.amount).reduce((t,e)=>t+e,0)}get shouldHasBase(){return this.kind==="musli"||this.kind==="porridge"}get hasBase(){return this.baseItems.length>0}get totalWeight(){let t=0;for(const e of this.nonBaseItems)t+=e.ingredient.weight*e.amount;return this.base?this.base.ingredient.weight*(this.basePercent/100)+t:t}get totalPrice(){let t=0;for(const e of this.items)t+=Number.parseFloat(e.ingredient.price)*e.amount;return t}get pricePerPortion(){return this.totalPrice>0?this.totalPrice/(this.totalWeight/100):0}get baseItems(){return this.items.filter(t=>t.ingredient.isBase)}get nonBaseItems(){return this.items.filter(t=>!t.ingredient.isBase)}get baseExtendedItems(){return this.items.filter(t=>t.ingredient.parentCategoryId==="musli_base_extended")}get dryFruitsItems(){return this.items.filter(t=>t.ingredient.parentCategoryId==="dry_fruits"||t.ingredient.parentCategoryId==="crunchy_fruits")}get nutsItems(){return this.items.filter(t=>t.ingredient.parentCategoryId==="nuts")}get onTopItems(){return this.items.filter(t=>t.ingredient.parentCategoryId==="on_top")}get base(){return this.baseItems[0]}get tubeVolume(){return this.kind==="musli"||this.kind==="porridge"?l:h}get nonBaseItemsVolume(){return this.nonBaseItems.map(t=>Number.parseFloat(t.ingredient.constantGml)*t.ingredient.weight*t.amount).reduce((t,e)=>t+e,0)}get baseExtendedItemsVolume(){return this.baseExtendedItems.map(t=>Number.parseFloat(t.ingredient.constantGml)*t.ingredient.weight*t.amount).reduce((t,e)=>t+e,0)}get dryFruitItemsVolume(){return this.dryFruitsItems.map(t=>Number.parseFloat(t.ingredient.constantGml)*t.ingredient.weight*t.amount).reduce((t,e)=>t+e,0)}get nutItemsItemsVolume(){return this.nutsItems.map(t=>Number.parseFloat(t.ingredient.constantGml)*t.ingredient.weight*t.amount).reduce((t,e)=>t+e,0)}get onTopItemsVolume(){return this.onTopItems.map(t=>Number.parseFloat(t.ingredient.constantGml)*t.ingredient.weight*t.amount).reduce((t,e)=>t+e,0)}get baseExtendedItemsPercent(){return this.baseExtendedItemsVolume/this.tubeVolume*100}get dryFruitItemsPercent(){return this.dryFruitItemsVolume/this.tubeVolume*100}get nutItemsPercent(){return this.nutItemsItemsVolume/this.tubeVolume*100}get onTopItemsPercent(){return this.onTopItemsVolume/this.tubeVolume*100}get basePercent(){return this.hasBase?100-this.itemsPercent:0}get itemsPercent(){switch(this.kind){case"musli":case"porridge":return this.baseExtendedItemsPercent+this.dryFruitItemsPercent+this.nutItemsPercent+this.onTopItemsPercent;case"dry_fruits":case"crunchy_fruits":return this.dryFruitItemsPercent+this.nutItemsPercent+this.onTopItemsPercent;case"biscuits":return this.totalNonBaseItemsQuantity*100/I;case"fruit_bags":return this.totalNonBaseItemsQuantity*100/P;case"mixit_bars":return this.totalNonBaseItemsQuantity*100/y}return 0}get showBasePercent(){return this.kind==="musli"||this.kind==="porridge"}get showBaseExtendedItemsPercent(){return this.kind==="musli"}get showDryFruitItemsPercent(){return this.kind==="musli"||this.kind==="porridge"||this.kind==="dry_fruits"}get showNutItemsPercent(){return this.kind==="musli"||this.kind==="porridge"||this.kind==="dry_fruits"}get showOnTopItemsPercent(){return this.kind==="musli"||this.kind==="porridge"||this.kind==="dry_fruits"}get showNutritionTable(){return this.kind==="musli"||this.kind==="porridge"||this.kind==="dry_fruits"||this.kind==="crunchy_fruits"||this.kind==="biscuits"}}const b=new Set(["musli","porridge","dry_fruits","crunchy_fruits","mixit_bars","fruit_bags"]),_=c("mixStore",{state:()=>({editedMix:null,mix:null}),actions:{addItem(n){const{kind:t,ingredient:e,quantity:s}=n,i=this.getMix(t),a={ingredient:e,amount:s};i.items.push(a)},removeItem(n){const t=this.getMix(n.kind);t.items=t.items.filter(e=>e.ingredient.id!==n.ingredient.id)},increaseQuantity(n){const{kind:t,ingredient:e,quantity:s}=n,a=this.getMix(t).items.find(u=>u.ingredient.id===e.id);a.amount+=s},decreaseQuantity(n){const{kind:t,ingredient:e,quantity:s}=n,a=this.getMix(t).items.find(u=>u.ingredient.id===e.id);a.amount-=s},changeBase(n){const t=this.getMix(n.kind);if(!t.hasBase)return;const e={ingredient:n.ingredient,amount:1};t.items=t.items.filter(s=>s.ingredient.id!==t.base.ingredient.id),t.items.push(e)},resetMix(n){this.mix=new d(n)},editMix(n){this.editedMix&&this.resetMix(this.editedMix.kind),this.editedMix=n},cancelEditMix(n){this.resetMix(n),this.editedMix=null},getMix(n){var t;if(((t=this.mix)==null?void 0:t.kind)===n)return this.mix;if(b.has(n)){const e=new d(n);return this.editedMix=null,this.mix=e,e}return null}},getters:{getEditedMix:n=>n.editedMix,getActualMix:n=>n.mix,getMixItems:n=>{var t;return(t=n.mix)==null?void 0:t.items},getMixLength:n=>{var t,e;return(e=(t=n.mix)==null?void 0:t.items)==null?void 0:e.length}}});export{M,h as S,N as a,I as b,P as c,y as d,_ as u};