"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileHelper = void 0;
const handlebars_1 = __importDefault(require("handlebars"));
const logger_1 = __importDefault(require("../logger"));
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
/**
 * Defines and registers custom handlebar helper - file
 */
class FileHelper {
    constructor() {
        /**
         * Registers file helper
         * - If file path is not included in the defined handlebar, log an error.
         * - If file path is passed, check if file exists and send the return value to HttpParser to process
         * @returns {void}
         */
        this.register = () => {
            handlebars_1.default.registerHelper("file", (context) => {
                if (typeof context.hash.path === "undefined") {
                    logger_1.default.error("File path not specified.");
                }
                else {
                    if (fs_1.default.existsSync(path_1.default.resolve(context.hash.path))) {
                        return `camouflage_file_helper=${path_1.default.resolve(context.hash.path)}`;
                    }
                }
            });
        };
    }
}
exports.FileHelper = FileHelper;
//# sourceMappingURL=FileHelper.js.map