"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.filterRegExp = filterRegExp;
function escapeRegExp(s) {
    let re = s.replace(/[/\-\\^$+.()|[\]{}]/g, '\\$&');
    re = re.replaceAll('*', '.*');
    re = re.replaceAll('?', '.{1}');
    return re;
}
function filterRegExp(settings) {
    if (!settings?.text.length) {
        return null;
    }
    let source = settings.useRe ? settings.text : escapeRegExp(settings.text);
    if (settings.wholeWord) {
        source = `^${source}$`;
    }
    try {
        return new RegExp(source, settings.matchCase ? '' : 'i');
    }
    catch (e) {
        return null;
    }
}
