"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.NumBetweenHelper = void 0;
const handlebars_1 = __importDefault(require("handlebars"));
const logger_1 = __importDefault(require("../logger"));
/**
 * Defines and registers custom handlebar helper - num_between
 */
class NumBetweenHelper {
    constructor() {
        /**
         * Registers num_between helper
         * - If lower or upper value is not passed, return 0
         * - If lower value is greater than upper value, log error and return 0
         * @returns {void}
         */
        this.register = () => {
            handlebars_1.default.registerHelper("num_between", (context) => {
                if (typeof context.hash.lower === "undefined" || typeof context.hash.upper === "undefined") {
                    logger_1.default.error("lower or upper value not specified.");
                    return 0;
                }
                else {
                    const lower = parseInt(context.hash.lower);
                    const upper = parseInt(context.hash.upper);
                    if (lower > upper) {
                        logger_1.default.error("lower value cannot be greater than upper value.");
                        return 0;
                    }
                    const num = Math.floor(Math.random() * (upper - lower + 1) + lower);
                    return num;
                }
            });
        };
    }
}
exports.NumBetweenHelper = NumBetweenHelper;
//# sourceMappingURL=NumBetweenHelper.js.map