"use strict";
var AndroidLogFilter = (function () {
    function AndroidLogFilter($loggingLevels) {
        this.$loggingLevels = $loggingLevels;
    }
    AndroidLogFilter.prototype.filterData = function (data, logLevel) {
        var specifiedLogLevel = (logLevel || '').toUpperCase();
        if (specifiedLogLevel === this.$loggingLevels.info) {
            var log = this.getConsoleLogFromLine(data);
            if (log) {
                if (log.tag) {
                    return log.tag + ": " + log.message;
                }
                else {
                    return log.message;
                }
            }
            return null;
        }
        return data;
    };
    AndroidLogFilter.prototype.getConsoleLogFromLine = function (lineText) {
        var acceptedTags = ["chromium", "Web Console", "JS"];
        var match = lineText.match(AndroidLogFilter.LINE_REGEX) || lineText.match(AndroidLogFilter.API_LEVEL_23_LINE_REGEX);
        if (match && acceptedTags.indexOf(match[1].trim()) !== -1) {
            return { tag: match[1].trim(), message: match[2] };
        }
        var matchingTag = _.any(acceptedTags, function (tag) { return lineText.indexOf(tag) !== -1; });
        return matchingTag ? { message: lineText } : null;
    };
    AndroidLogFilter.LINE_REGEX = /.\/(.+?)\s*\(\s*\d+?\): (.*)/;
    AndroidLogFilter.API_LEVEL_23_LINE_REGEX = /.+?\s+?(?:[A-Z]\s+?)([A-Za-z ]+?)\s*?\: (.*)/;
    return AndroidLogFilter;
})();
exports.AndroidLogFilter = AndroidLogFilter;
$injector.register("androidLogFilter", AndroidLogFilter);
