@@ -88,24 +88,54 @@ export function adjustCaloriesForGoal(tdee, goalType, customAmount = null) {
8888 }
8989}
9090
91+ /**
92+ * Get protein intake target (g/kg/day) based on goal and activity level
93+ * @param {string } goalType - 'lose', 'maintain', or 'gain'
94+ * @param {string } activityLevel - Activity level
95+ * @returns {number } Protein per kg (midpoint of range)
96+ */
97+ export function getProteinPerKg ( goalType , activityLevel ) {
98+ // Protein targets in g/kg/day based on goal and activity level
99+ // Values are midpoints of the ranges from research-based guidelines
100+ const proteinTargets = {
101+ lose : {
102+ sedentary : 1.7 , // 1.6-1.8
103+ lightly_active : 1.9 , // 1.8-2.0
104+ moderately_active : 2.1 , // 2.0-2.2
105+ very_active : 2.3 , // 2.2-2.4
106+ extra_active : 2.45 // 2.3-2.6
107+ } ,
108+ maintain : {
109+ sedentary : 1.3 , // 1.2-1.4
110+ lightly_active : 1.5 , // 1.4-1.6
111+ moderately_active : 1.7 , // 1.6-1.8
112+ very_active : 1.9 , // 1.8-2.0
113+ extra_active : 2.1 // 2.0-2.2
114+ } ,
115+ gain : {
116+ sedentary : 1.7 , // 1.6-1.8
117+ lightly_active : 1.9 , // 1.8-2.0
118+ moderately_active : 2.1 , // 2.0-2.2
119+ very_active : 2.3 , // 2.2-2.4
120+ extra_active : 2.5 // 2.4-2.6
121+ }
122+ } ;
123+
124+ const goalTargets = proteinTargets [ goalType ] || proteinTargets . maintain ;
125+ return goalTargets [ activityLevel ] || goalTargets . sedentary ;
126+ }
127+
91128/**
92129 * Calculate macronutrient targets
93130 * @param {number } calories - Total daily calories
94131 * @param {number } weight_kg - Weight in kilograms
95132 * @param {string } goalType - 'lose', 'maintain', or 'gain'
133+ * @param {string } activityLevel - Activity level
96134 * @returns {Object } Macro targets {protein, carbs, fat, fiber}
97135 */
98- export function calculateMacros ( calories , weight_kg , goalType ) {
99- // Protein: 1.8-2.2g per kg for muscle maintenance/growth
100- // Higher protein when cutting, moderate when maintaining/bulking
101- let proteinPerKg ;
102- if ( goalType === 'lose' ) {
103- proteinPerKg = 2.2 ; // Higher protein to preserve muscle while cutting
104- } else if ( goalType === 'gain' ) {
105- proteinPerKg = 1.8 ; // Moderate protein for muscle building
106- } else {
107- proteinPerKg = 2.0 ; // Maintenance
108- }
136+ export function calculateMacros ( calories , weight_kg , goalType , activityLevel = 'sedentary' ) {
137+ // Get protein target based on goal and activity level
138+ const proteinPerKg = getProteinPerKg ( goalType , activityLevel ) ;
109139
110140 const protein = Math . round ( weight_kg * proteinPerKg ) ;
111141 const proteinCalories = protein * 4 ; // 4 calories per gram of protein
0 commit comments