package com.bplscale

/**
 * BodyFat calculation wrapper
 * Loads the native libbodyfat.so library
 */
object BodyFat {
    init {
        System.loadLibrary("bodyfat") // libbodyfat.so
    }

    external fun getVersion(): String
    external fun getAuthToken(): String

    /**
     * Calculate body fat percentage
     * @param sex Boolean - true for female, false for male
     * @param age Float - user age
     * @param cm Float - height in cm
     * @param wtkg Float - weight in kg
     * @param imp Float - body impedance (Ohm)
     * @param althlevel Int - athletic level (keep 0)
     * @return Float - body fat percentage
     */
    external fun getFat(sex: Boolean, age: Float, cm: Float, wtkg: Float, imp: Float, althlevel: Int): Float

    /**
     * Calculate total body water (TBW)
     */
    external fun getTbw(sex: Boolean, age: Float, cm: Float, wtkg: Float, imp: Float, althlevel: Int): Float

    /**
     * Calculate muscle mass percentage
     */
    external fun getMus(sex: Boolean, age: Float, cm: Float, wtkg: Float, imp: Float, althlevel: Int): Float

    /**
     * Calculate bone mass percentage
     */
    external fun getBone(sex: Boolean, age: Float, cm: Float, wtkg: Float, imp: Float, althlevel: Int): Float

    /**
     * Calculate basal metabolic rate (BMR) in Kcal
     */
    external fun getKcal(sex: Boolean, age: Float, cm: Float, wtkg: Float, imp: Float, althlevel: Int): Float

    /**
     * Calculate visceral fat
     */
    external fun getVfat(sex: Boolean, age: Float, cm: Float, wtkg: Float, imp: Float, althlevel: Int): Float

    /**
     * Calculate body age
     */
    external fun getBage(sex: Boolean, age: Float, cm: Float, wtkg: Float, imp: Float, althlevel: Int): Float

    /**
     * Calculate best weight
     */
    external fun getBestWeight(sex: Boolean, age: Float, cm: Float, wtkg: Float, imp: Float, althlevel: Int): Float

    /**
     * Calculate BMI (Body Mass Index)
     */
    external fun getBMI(sex: Boolean, age: Float, cm: Float, wtkg: Float, imp: Float, althlevel: Int): Float

    /**
     * Calculate protein percentage
     */
    external fun getProtein(sex: Boolean, age: Float, cm: Float, wtkg: Float, imp: Float, althlevel: Int): Float

    /**
     * Calculate weight without fat (lean body mass)
     */
    external fun getWeightWithoutFat(sex: Boolean, age: Float, cm: Float, wtkg: Float, imp: Float, althlevel: Int): Float

    /**
     * Calculate obesity rate
     * obeserate = (actual weight - best weight) / best weight
     *
     * Evaluation:
     * < 10.0    - Healthy
     * < 20.0    - Over weight
     * < 30.0    - Mildly obese
     * < 50.0    - Moderate obesity
     * > 50      - Severe obesity
     */
    external fun getObeseRate(sex: Boolean, age: Float, cm: Float, wtkg: Float, imp: Float, althlevel: Int): Float

    /**
     * Calculate body score (0-100)
     */
    external fun getScore(sex: Boolean, age: Float, cm: Float, wtkg: Float, imp: Float, althlevel: Int): Float

    /**
     * Calculate body shape type
     *
     * < 0.5     - Lean type
     * < 1.5     - Normal type
     * < 2.5     - Over weight type
     * < 3.5     - Over fat
     * > 3.5     - Obese
     */
    external fun getBodyShape(sex: Boolean, age: Float, cm: Float, wtkg: Float, imp: Float, althlevel: Int): Float
}