UNPKG

fitness-progression-calculator

Version:
48 lines (47 loc) 2.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getIncrement = getIncrement; exports.calculateCycleReps = calculateCycleReps; exports.clampReps = clampReps; exports.checkExerciseTransition = checkExerciseTransition; const constants_1 = require("./constants"); function getIncrement(equipment_type, settings = constants_1.DEFAULT_SETTINGS) { var _a, _b, _c, _d; switch (equipment_type) { case 'BARBELL': return (_a = settings.barbellIncrement) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_SETTINGS.barbellIncrement; case 'DUMBBELL': case 'BODYWEIGHT': return (_b = settings.dumbbellIncrement) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_SETTINGS.dumbbellIncrement; case 'CABLE': return (_c = settings.cableIncrement) !== null && _c !== void 0 ? _c : constants_1.DEFAULT_SETTINGS.cableIncrement; case 'MACHINE': return (_d = settings.machineIncrement) !== null && _d !== void 0 ? _d : constants_1.DEFAULT_SETTINGS.machineIncrement; default: return 2.5; } } function calculateCycleReps(currentReps, currentWeight, newWeight, volumeFactor) { if (newWeight <= 0) return currentReps; const targetVolume = currentReps * currentWeight * volumeFactor; const calculatedReps = Math.floor(targetVolume / newWeight); return clampReps(calculatedReps); } function clampReps(reps) { return Math.max(constants_1.MIN_REPS, Math.min(constants_1.MAX_REPS, reps)); } function checkExerciseTransition(exerciseId, newWeight) { var _a; const config = constants_1.EXERCISE_CONFIGS[exerciseId]; if (!config) return undefined; if (config.weightCeiling && newWeight >= config.weightCeiling && config.suggestedExerciseId) { return { type: 'CHANGE_EXERCISE', message: (_a = config.suggestedExerciseMessage) !== null && _a !== void 0 ? _a : 'Consider progressing to a more advanced exercise.', suggestedExerciseId: config.suggestedExerciseId, }; } return undefined; }