export const registerHelpers = async function () { // Handlebars template helpers Handlebars.registerHelper("eq", function (a, b) { return a == b; }); Handlebars.registerHelper("add", function (lh, rh) { return parseInt(lh) + parseInt(rh); }); Handlebars.registerHelper("subtract", function (lh, rh) { return parseInt(rh) - parseInt(lh); }); Handlebars.registerHelper("divide", function (lh, rh) { return Math.floor(parseFloat(lh) / parseFloat(rh)); }); Handlebars.registerHelper("mult", function (lh, rh) { return parseFloat(lh) * parseFloat(rh); }); Handlebars.registerHelper("counter", function (status, value, max) { return status ? Math.clamped((100.0 * value) / max, 0, 100) : Math.clamped(100 - (100.0 * value) / max, 0, 100); }); };