({
take: [
{ key: "kg", label: "Weight (kg)", type: "number" },
{ key: "cm", label: "Height (cm)", type: "number" },
],
make: ({ kg, cm }) => {
if (!kg || !cm) return "Add your weight and height to calculate your BMI."
const bmi = +(kg / Math.pow(cm / 100, 2)).toFixed(1)
const limits = [18.5, 25, 30]
const ranges = ["underweight", "normal weight", "overweight", "obese"]
let index = 0
while (limits.length && bmi > limits.shift()) index++
return {
type: "card",
title: bmi,
body: `Your BMI is in the ${ranges[index]} range.`,
}
},
})