import '../../internal/application/ProgressionRule.dart'; class ExercisePrescription { String? id; String sessionTemplateId; String exerciseId; String exerciseName; /// Primary muscle group, for weekly volume tracking. String muscleGroup; int sets; int targetReps; /// For timed holds and intervals; 0 when the work is rep-based. int targetTimeSeconds; int restSeconds; /// Eccentric-pause-concentric-pause, e.g. "3010". String tempo; ProgressionRule progressionRule; /// Ground contacts per set, for the plyometric weekly ceiling. int contactsPerSet; /// Whether this is a hard exercise for integrity scoring. Derived from /// historical RPE rather than set statically. bool hard; ExercisePrescription({ this.id, this.sessionTemplateId = "", this.exerciseId = "", this.exerciseName = "", this.muscleGroup = "", this.sets = 0, this.targetReps = 0, this.targetTimeSeconds = 0, this.restSeconds = 0, this.tempo = "", this.progressionRule = ProgressionRule.Reps, this.contactsPerSet = 0, this.hard = false, }); factory ExercisePrescription.fromJson(Map json) { return ExercisePrescription( id: json['id'], sessionTemplateId: json['sessionTemplateId'] ?? "", exerciseId: json['exerciseId'] ?? "", exerciseName: json['exerciseName'] ?? "", muscleGroup: json['muscleGroup'] ?? "", sets: json['sets'] ?? 0, targetReps: json['targetReps'] ?? 0, targetTimeSeconds: json['targetTimeSeconds'] ?? 0, restSeconds: json['restSeconds'] ?? 0, tempo: json['tempo'] ?? "", progressionRule: getProgressionRule(json['progressionRule']), contactsPerSet: json['contactsPerSet'] ?? 0, hard: json['hard'] ?? false, ); } Map toJson() { final Map data = {}; data['id'] = id; data['sessionTemplateId'] = sessionTemplateId; data['exerciseId'] = exerciseId; data['exerciseName'] = exerciseName; data['muscleGroup'] = muscleGroup; data['sets'] = sets; data['targetReps'] = targetReps; data['targetTimeSeconds'] = targetTimeSeconds; data['restSeconds'] = restSeconds; data['tempo'] = tempo; data['progressionRule'] = progressionRule.name; data['contactsPerSet'] = contactsPerSet; data['hard'] = hard; return data; } int get plannedContacts { return contactsPerSet * sets; } }