import * as i0 from '@angular/core';
import { Injectable, InjectionToken, Inject, NgModule, Self } from '@angular/core';
import { isNil, isNotNil } from '@angular-ru/cdk/utils';
import { __decorate, __metadata } from 'tslib';
import { BoundClass } from '@angular-ru/cdk/decorators';
import { isString } from '@angular-ru/cdk/string';

class LoggerInjector {
    constructor(injector) {
        LoggerInjector.injector = injector;
    }
    static getInjector() {
        if (isNil(LoggerInjector.injector)) {
            throw new Error(`You've forgotten to import \`LoggerModule\``);
        }
        return LoggerInjector.injector;
    }
}
LoggerInjector.injector = null;
/** @nocollapse */ LoggerInjector.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: LoggerInjector, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
/** @nocollapse */ LoggerInjector.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: LoggerInjector });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: LoggerInjector, decorators: [{
            type: Injectable
        }], ctorParameters: function () { return [{ type: i0.Injector }]; } });

const LOGGER_OPTIONS = new InjectionToken('LOGGER_OPTIONS');
/**
 * Used in factory methods
 */
// eslint-disable-next-line no-restricted-syntax
var LoggerLevel;
(function (LoggerLevel) {
    LoggerLevel[LoggerLevel["ALL"] = 1] = "ALL";
    LoggerLevel[LoggerLevel["TRACE"] = 2] = "TRACE";
    LoggerLevel[LoggerLevel["DEBUG"] = 3] = "DEBUG";
    LoggerLevel[LoggerLevel["INFO"] = 4] = "INFO";
    LoggerLevel[LoggerLevel["LOG"] = 5] = "LOG";
    LoggerLevel[LoggerLevel["WARN"] = 6] = "WARN";
    LoggerLevel[LoggerLevel["ERROR"] = 7] = "ERROR";
    LoggerLevel[LoggerLevel["OFF"] = 8] = "OFF";
})(LoggerLevel || (LoggerLevel = {}));
var GroupLevel;
(function (GroupLevel) {
    GroupLevel["GROUP"] = "group";
    GroupLevel["GROUP_COLLAPSED"] = "groupCollapsed";
})(GroupLevel || (GroupLevel = {}));

class LoggerOptionsImpl {
    constructor() {
        this.instance = console;
        this.minLevel = LoggerLevel.ALL;
        this.globalLineStyle = '';
        this.cssClassMap = {};
        this.useLevelGroup = true;
        this.labelColors = {
            [LoggerLevel.TRACE]: "#000080" /* TRACE */,
            [LoggerLevel.DEBUG]: "#00BFFE" /* DEBUG */,
            [LoggerLevel.INFO]: "#000000" /* INFO */,
            [LoggerLevel.WARN]: "#FF6419" /* WARN */,
            [LoggerLevel.ERROR]: "#F1062D" /* ERROR */
        };
        this.labelNames = {
            [LoggerLevel.TRACE]: "TRACE" /* TRACE */,
            [LoggerLevel.DEBUG]: "DEBUG" /* DEBUG */,
            [LoggerLevel.INFO]: "INFO" /* INFO */,
            [LoggerLevel.WARN]: "WARN" /* WARN */,
            [LoggerLevel.ERROR]: "ERROR" /* ERROR */
        };
    }
    format(label, style) {
        return { label: `[${label}]:`, style };
    }
}
/** @nocollapse */ LoggerOptionsImpl.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: LoggerOptionsImpl, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
/** @nocollapse */ LoggerOptionsImpl.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: LoggerOptionsImpl });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: LoggerOptionsImpl, decorators: [{
            type: Injectable
        }] });

class ConsoleService {
    constructor(options) {
        this.options = options;
        this.minLevel = options.minLevel;
        this.instance = options.instance;
    }
    get noop() {
        // eslint-disable-next-line @typescript-eslint/no-empty-function
        return (() => { });
    }
    get console() {
        return this.instance;
    }
    set console(instance) {
        this.instance = instance;
    }
    getTemplateLabel(text) {
        return `%c${text}`;
    }
    getFormatTemplateLabel(text) {
        return `%c${text} %c%s`;
    }
    getTemplateWithoutLabel() {
        return `%c%s`;
    }
}
/** @nocollapse */ ConsoleService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: ConsoleService, deps: [{ token: LOGGER_OPTIONS }], target: i0.ɵɵFactoryTarget.Injectable });
/** @nocollapse */ ConsoleService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: ConsoleService });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: ConsoleService, decorators: [{
            type: Injectable
        }], ctorParameters: function () {
        return [{ type: LoggerOptionsImpl, decorators: [{
                        type: Inject,
                        args: [LOGGER_OPTIONS]
                    }] }];
    } });

class CssFactory {
    constructor(options) {
        this.options = options;
        this.lineStyle = null;
    }
    get style() {
        const style = this.localStyle;
        this.clearLocalStyle();
        return `${this.globalStyles}${style}`;
    }
    set style(css) {
        this.lineStyle = css;
    }
    get globalStyles() {
        return this.options.globalLineStyle ? `${this.options.globalLineStyle};` : '';
    }
    get localStyle() {
        var _a, _b;
        return ((_b = (_a = this.lineStyle) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0 ? `${this.lineStyle};` : '';
    }
    getStyleLabel(level) {
        const color = this.options.labelColors[level];
        return `color: ${color}; font-weight: bold`;
    }
    setClass(cssClassName) {
        const classList = cssClassName.split(/\s+/g);
        const styles = [];
        for (const className of classList) {
            const style = this.options.cssClassMap[className];
            if (isNotNil(style)) {
                styles.push(style);
            }
        }
        const localStyles = styles.length > 0 ? styles.join('; ') : '';
        this.lineStyle = `${this.globalStyles}${localStyles}`;
    }
    clearLocalStyle() {
        this.lineStyle = '';
    }
}
/** @nocollapse */ CssFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: CssFactory, deps: [{ token: LOGGER_OPTIONS }], target: i0.ɵɵFactoryTarget.Injectable });
/** @nocollapse */ CssFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: CssFactory });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: CssFactory, decorators: [{
            type: Injectable
        }], ctorParameters: function () {
        return [{ type: LoggerOptionsImpl, decorators: [{
                        type: Inject,
                        args: [LOGGER_OPTIONS]
                    }] }];
    } });

// eslint-disable-next-line @typescript-eslint/naming-convention
var LABELS;
(function (LABELS) {
    LABELS["TRACE"] = "TRACE";
    LABELS["DEBUG"] = "DEBUG";
    LABELS["INFO"] = "INFO";
    LABELS["WARN"] = "WARN";
    LABELS["ERROR"] = "ERROR";
})(LABELS || (LABELS = {}));
// eslint-disable-next-line @typescript-eslint/naming-convention
var COLORS;
(function (COLORS) {
    COLORS["TRACE"] = "#000080";
    COLORS["DEBUG"] = "#00BFFE";
    COLORS["INFO"] = "#000000";
    COLORS["WARN"] = "#FF6419";
    COLORS["ERROR"] = "#F1062D";
})(COLORS || (COLORS = {}));
const DEFAULT_METHODS = {
    /**
     * Used `debug` instead `trace` method because need
     * output without stack trace in console
     * LoggerLevel.TRACE -> console.debug
     */
    [LoggerLevel.TRACE]: 'debug',
    [LoggerLevel.LOG]: 'log',
    [LoggerLevel.DEBUG]: 'info',
    [LoggerLevel.INFO]: 'info',
    [LoggerLevel.WARN]: 'warn',
    [LoggerLevel.ERROR]: 'error'
};
const LEXER_JSON = /("(\\u[\dA-Za-z]{4}|\\[^u]|[^"\\])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[Ee][+\-]?\d+)?)/g;

class GroupFactory {
    constructor(console, cssFactory, options) {
        this.console = console;
        this.cssFactory = cssFactory;
        this.options = options;
        this.counterOpenedGroup = 0;
        this.executePipesGroup = false;
    }
    close() {
        if (this.executePipesGroup) {
            this.counterOpenedGroup--;
            this.console.instance.groupEnd();
        }
    }
    closeAll() {
        while (this.counterOpenedGroup > 0) {
            this.close();
        }
    }
    // eslint-disable-next-line max-params-no-constructor/max-params-no-constructor
    group(title, pipeline, logger, level) {
        const group = this.console.instance.group.bind(this.console.instance);
        return this.createGroupLogger(group, title, pipeline, logger, level);
    }
    // eslint-disable-next-line max-params-no-constructor/max-params-no-constructor
    groupCollapsed(title, pipeline, logger, level) {
        const groupCollapsed = this.console.instance.groupCollapsed.bind(this.console.instance);
        return this.createGroupLogger(groupCollapsed, title, pipeline, logger, level);
    }
    // eslint-disable-next-line max-lines-per-function,max-params-no-constructor/max-params-no-constructor
    createGroupLogger(groupType, title, pipeline, logger, level) {
        const showGroup = this.console.minLevel <= level;
        let pipeLineResult;
        if (showGroup) {
            this.executePipesGroup = true;
            this.counterOpenedGroup++;
            const lineStyle = this.cssFactory.getStyleLabel(level);
            const { label: formatLabel, style: formatStyle } = this.getLabel(LoggerLevel[level], lineStyle);
            groupType(`%c${formatLabel}`, formatStyle, title);
            if (isNotNil(pipeline)) {
                const result = pipeline(logger);
                this.close();
                pipeLineResult = result;
            }
        }
        else {
            this.executePipesGroup = false;
        }
        return pipeLineResult;
    }
    getLabel(level, style) {
        return this.options.format(level, style);
    }
}
/** @nocollapse */ GroupFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: GroupFactory, deps: [{ token: ConsoleService }, { token: CssFactory }, { token: LOGGER_OPTIONS }], target: i0.ɵɵFactoryTarget.Injectable });
/** @nocollapse */ GroupFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: GroupFactory });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: GroupFactory, decorators: [{
            type: Injectable
        }], ctorParameters: function () {
        return [{ type: ConsoleService }, { type: CssFactory }, { type: LoggerOptionsImpl, decorators: [{
                        type: Inject,
                        args: [LOGGER_OPTIONS]
                    }] }];
    } });

class LoggerFactory {
    // eslint-disable-next-line max-params
    constructor(options, console, cssFactory, groupFactory) {
        this.options = options;
        this.console = console;
        this.cssFactory = cssFactory;
        this.groupFactory = groupFactory;
    }
    createLogger(level, logger) {
        const args = this.getArgumentsByType(level);
        const methodName = DEFAULT_METHODS[level];
        const operation = this.console.minLevel <= level
            ? this.console.instance[methodName].bind(...args)
            : this.console.noop;
        const pipeOperation = this.options.useLevelGroup
            ? this.defineLevelGroups(level, operation, logger)
            : operation;
        return pipeOperation;
    }
    defineLevelGroups(level, operation, logger) {
        Object.defineProperties(operation, {
            ["group" /* GROUP */]: this.setGroupMethod("group" /* GROUP */, level, logger),
            ["groupCollapsed" /* GROUP_COLLAPSED */]: this.setGroupMethod("groupCollapsed" /* GROUP_COLLAPSED */, level, logger)
        });
        return operation;
    }
    setGroupMethod(methodName, level, logger) {
        return {
            enumerable: true,
            configurable: true,
            value: (label, pipeLine) => {
                const groupMethod = this.groupFactory[methodName].bind(this.groupFactory);
                groupMethod(label, pipeLine, logger, level);
                return logger;
            }
        };
    }
    // eslint-disable-next-line max-lines-per-function
    getArgumentsByType(level) {
        const styleLabel = this.cssFactory.getStyleLabel(level);
        const lineStyle = this.cssFactory.style;
        const args = [this.console.instance];
        const withLabel = level !== LoggerLevel.LOG;
        if (withLabel) {
            const { label: formatLabel, style } = this.options.format(this.options.labelNames[level], styleLabel);
            if (lineStyle) {
                const label = this.console.getFormatTemplateLabel(formatLabel);
                args.push(label, style, lineStyle);
            }
            else {
                const label = this.console.getTemplateLabel(formatLabel);
                args.push(label, style);
            }
        }
        else if (lineStyle) {
            args.push(this.console.getTemplateWithoutLabel(), lineStyle);
        }
        return args;
    }
}
/** @nocollapse */ LoggerFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: LoggerFactory, deps: [{ token: LOGGER_OPTIONS }, { token: ConsoleService }, { token: CssFactory }, { token: GroupFactory }], target: i0.ɵɵFactoryTarget.Injectable });
/** @nocollapse */ LoggerFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: LoggerFactory });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: LoggerFactory, decorators: [{
            type: Injectable
        }], ctorParameters: function () {
        return [{ type: LoggerOptionsImpl, decorators: [{
                        type: Inject,
                        args: [LOGGER_OPTIONS]
                    }] }, { type: ConsoleService }, { type: CssFactory }, { type: GroupFactory }];
    } });

class JsonFactory {
    constructor() {
        this._string = 'color:green';
        this._number = 'color:darkorange';
        this._boolean = 'color:blue';
        this._null = 'color:magenta';
        this._key = 'color:red';
        this.lexerTypeFinder = LEXER_JSON;
    }
    // eslint-disable-next-line max-lines-per-function
    colorsJSON(json) {
        let resultJson = json;
        const arr = [];
        resultJson = resultJson.replace(this.lexerTypeFinder, (match) => {
            let style = this._number;
            if (/^"/.test(match)) {
                if (/:$/.test(match)) {
                    style = this._key;
                }
                else {
                    style = this._string;
                }
            }
            else if (/true|false/.test(match)) {
                style = this._boolean;
            }
            else if (/null/.test(match)) {
                style = this._null;
            }
            arr.push(style, '');
            return `%c${match}%c`;
        });
        arr.unshift(resultJson);
        return arr;
    }
}
/** @nocollapse */ JsonFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: JsonFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
/** @nocollapse */ JsonFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: JsonFactory });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: JsonFactory, decorators: [{
            type: Injectable
        }] });

class TimerFactory {
    constructor(console) {
        this.console = console;
        this.DIGITS_TO_FIX = 4;
        this.SECONDS = 1000;
    }
    startTime(title, level) {
        let result = null;
        // eslint-disable-next-line sonarjs/no-inverted-boolean-check
        const canExecute = !(this.console.minLevel > level);
        if (canExecute) {
            result = { startTime: performance.now(), title };
        }
        return result;
    }
    // eslint-disable-next-line max-params-no-constructor/max-params-no-constructor
    endTime(info, level, isMillisecond, logger) {
        // eslint-disable-next-line sonarjs/no-inverted-boolean-check
        const canExecute = !(this.console.minLevel > level);
        if (canExecute) {
            const methodName = DEFAULT_METHODS[level];
            const time = this.ensureTime(info, isMillisecond);
            const logMethod = logger[methodName];
            logMethod(`TimerLog: ${info.title}`, `took ${time} to execute`);
        }
    }
    ensureTime(info, isMillisecond) {
        const msTime = parseFloat((performance.now() - info.startTime).toFixed(this.DIGITS_TO_FIX));
        return isMillisecond ? `${msTime}ms` : `${Math.floor(msTime / this.SECONDS)}s`;
    }
}
/** @nocollapse */ TimerFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: TimerFactory, deps: [{ token: ConsoleService }], target: i0.ɵɵFactoryTarget.Injectable });
/** @nocollapse */ TimerFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: TimerFactory });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: TimerFactory, decorators: [{
            type: Injectable
        }], ctorParameters: function () { return [{ type: ConsoleService }]; } });

let LoggerService = class LoggerService {
    // eslint-disable-next-line max-params
    constructor(cssFactory, console, factory, groupFactory, jsonFactory, timerFactory, options) {
        this.cssFactory = cssFactory;
        this.console = console;
        this.factory = factory;
        this.groupFactory = groupFactory;
        this.jsonFactory = jsonFactory;
        this.timerFactory = timerFactory;
        this.options = options;
        this.DEFAULT_DEPTH = 2;
    }
    get clear() {
        return this.console.instance.clear.bind(this.console.instance);
    }
    get table() {
        return this.console.instance.table.bind(this.console.instance);
    }
    get log() {
        return this.factory.createLogger(LoggerLevel.LOG, this);
    }
    get trace() {
        return this.factory.createLogger(LoggerLevel.TRACE, this);
    }
    get assert() {
        return this.console.instance.assert.bind(this.console.instance);
    }
    get debug() {
        return this.factory.createLogger(LoggerLevel.DEBUG, this);
    }
    get info() {
        return this.factory.createLogger(LoggerLevel.INFO, this);
    }
    get warn() {
        return this.factory.createLogger(LoggerLevel.WARN, this);
    }
    get error() {
        return this.factory.createLogger(LoggerLevel.ERROR, this);
    }
    get level() {
        return this.console.minLevel;
    }
    set level(level) {
        this.console.minLevel = level;
    }
    getCurrentLineStyle() {
        return this.cssFactory.style;
    }
    clearCssCurrentLine() {
        this.cssFactory.style = '';
    }
    setLabels(labels) {
        this.options.labelNames = Object.assign(Object.assign({}, this.options.labelNames), labels);
    }
    setColors(colors) {
        this.options.labelColors = Object.assign(Object.assign({}, this.options.labelColors), colors);
    }
    pipe(...pipelines) {
        if (this.groupFactory.executePipesGroup) {
            for (const pipeline of pipelines) {
                pipeline(this);
            }
        }
        return this;
    }
    groupCollapsed(title, pipeline) {
        this.groupFactory.groupCollapsed(title, pipeline, this, LoggerLevel.INFO);
        return this;
    }
    close() {
        this.groupFactory.close();
        return this;
    }
    closeAll() {
        this.groupFactory.closeAll();
        return this;
    }
    group(title, pipeline) {
        this.groupFactory.group(title, pipeline, this, LoggerLevel.INFO);
        return this;
    }
    css(style) {
        this.cssFactory.style = style;
        return this;
    }
    prettyJSON(json) {
        return this.jsonFactory.colorsJSON(JSON.stringify(json, null, this.DEFAULT_DEPTH));
    }
    cssClass(cssClassName) {
        this.cssFactory.setClass(cssClassName);
        return this;
    }
    startTime(title, level = LoggerLevel.DEBUG) {
        return this.timerFactory.startTime(title, level);
    }
    endTime(info, level = LoggerLevel.DEBUG, isMillisecond = true) {
        if (isNotNil(info)) {
            this.timerFactory.endTime(info, level, isMillisecond, this);
        }
    }
};
/** @nocollapse */ LoggerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: LoggerService, deps: [{ token: CssFactory }, { token: ConsoleService }, { token: LoggerFactory }, { token: GroupFactory }, { token: JsonFactory }, { token: TimerFactory }, { token: LOGGER_OPTIONS }], target: i0.ɵɵFactoryTarget.Injectable });
/** @nocollapse */ LoggerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: LoggerService });
LoggerService = __decorate([
    BoundClass,
    __metadata("design:paramtypes", [CssFactory,
        ConsoleService,
        LoggerFactory,
        GroupFactory,
        JsonFactory,
        TimerFactory,
        LoggerOptionsImpl])
], LoggerService);
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: LoggerService, decorators: [{
            type: Injectable
        }], ctorParameters: function () {
        return [{ type: CssFactory }, { type: ConsoleService }, { type: LoggerFactory }, { type: GroupFactory }, { type: JsonFactory }, { type: TimerFactory }, { type: LoggerOptionsImpl, decorators: [{
                        type: Inject,
                        args: [LOGGER_OPTIONS]
                    }] }];
    } });

function DebugLog() {
    return function (target, propertyName) {
        Object.defineProperty(target, propertyName, {
            configurable: false,
            get() {
                return LoggerInjector.getInjector().get(LoggerService).debug;
            }
        });
    };
}

function ErrorLog() {
    return (target, propertyName) => {
        Object.defineProperty(target, propertyName, {
            configurable: false,
            get() {
                return LoggerInjector.getInjector().get(LoggerService).error;
            }
        });
    };
}

// eslint-disable-next-line max-params-no-constructor/max-params-no-constructor
function groupDecoratorFactory(level, groupType, method, title, args, target) {
    const logger = LoggerInjector.getInjector().get(LoggerService);
    const groupFactory = LoggerInjector.getInjector().get(GroupFactory);
    const groupMethod = groupFactory[groupType].bind(groupFactory);
    const label = isString(title) ? title : title(...args);
    groupMethod(label, null, logger, level);
    const result = method.apply(target, args);
    if (logger.level <= level) {
        logger.close();
    }
    return result;
}

function Group(title, level = LoggerLevel.INFO) {
    return function (_target, _key, descriptor) {
        const method = descriptor.value;
        descriptor.value = function (...args) {
            return groupDecoratorFactory(level, "group" /* GROUP */, method, title, args, this);
        };
        return descriptor;
    };
}

function GroupCollapsed(title, level = LoggerLevel.INFO) {
    return function (_target, _key, descriptor) {
        const method = descriptor.value;
        descriptor.value = function (...args) {
            return groupDecoratorFactory(level, "groupCollapsed" /* GROUP_COLLAPSED */, method, title, args, this);
        };
        return descriptor;
    };
}

function InfoLog() {
    return (target, propertyName) => {
        Object.defineProperty(target, propertyName, {
            configurable: false,
            get() {
                return LoggerInjector.getInjector().get(LoggerService).info;
            }
        });
    };
}

function Log() {
    return (target, propertyName) => {
        Object.defineProperty(target, propertyName, {
            configurable: false,
            get() {
                return LoggerInjector.getInjector().get(LoggerService).log;
            }
        });
    };
}

function Logger() {
    return (target, propertyName) => {
        Object.defineProperty(target, propertyName, {
            configurable: false,
            get() {
                return LoggerInjector.getInjector().get(LoggerService);
            }
        });
    };
}

// eslint-disable-next-line max-lines-per-function
function TimerLog(title, level = LoggerLevel.DEBUG, isMillisecond = true) {
    return function (_target, _key, descriptor) {
        let result;
        const method = descriptor.value;
        descriptor.value = function (...args) {
            const info = LoggerInjector.getInjector()
                .get(LoggerService)
                .startTime(title, level);
            result = method.apply(this, args);
            LoggerInjector.getInjector().get(LoggerService).endTime(info, level, isMillisecond);
            return result;
        };
        return descriptor;
    };
}

function TraceLog() {
    return (target, propertyName) => {
        Object.defineProperty(target, propertyName, {
            configurable: false,
            get() {
                return LoggerInjector.getInjector().get(LoggerService).trace;
            }
        });
    };
}

function WarnLog() {
    return (target, propertyName) => {
        Object.defineProperty(target, propertyName, {
            configurable: false,
            get() {
                return LoggerInjector.getInjector().get(LoggerService).warn;
            }
        });
    };
}

class LoggerModule {
    constructor(loggerInjector) {
        this.loggerInjector = loggerInjector;
    }
    static forRoot(config = {}) {
        return {
            ngModule: LoggerModule,
            providers: [
                {
                    provide: LoggerModule.ROOT_OPTIONS,
                    useValue: config
                },
                {
                    provide: LOGGER_OPTIONS,
                    useFactory: LoggerModule.loggerConfigFactory,
                    deps: [LoggerModule.ROOT_OPTIONS]
                }
            ]
        };
    }
    static loggerConfigFactory(config) {
        return Object.assign(new LoggerOptionsImpl(), config);
    }
}
LoggerModule.ROOT_OPTIONS = new InjectionToken('ROOT_OPTIONS');
/** @nocollapse */ LoggerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: LoggerModule, deps: [{ token: LoggerInjector, self: true }], target: i0.ɵɵFactoryTarget.NgModule });
/** @nocollapse */ LoggerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: LoggerModule });
/** @nocollapse */ LoggerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: LoggerModule, providers: [
        ConsoleService,
        CssFactory,
        GroupFactory,
        JsonFactory,
        LoggerFactory,
        LoggerInjector,
        LoggerService,
        TimerFactory
    ] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: LoggerModule, decorators: [{
            type: NgModule,
            args: [{
                    providers: [
                        ConsoleService,
                        CssFactory,
                        GroupFactory,
                        JsonFactory,
                        LoggerFactory,
                        LoggerInjector,
                        LoggerService,
                        TimerFactory
                    ]
                }]
        }], ctorParameters: function () {
        return [{ type: LoggerInjector, decorators: [{
                        type: Self
                    }] }];
    } });

/**
 * Generated bundle index. Do not edit.
 */

export { COLORS, ConsoleService, DEFAULT_METHODS, DebugLog, ErrorLog, Group, GroupCollapsed, GroupLevel, InfoLog, LABELS, LEXER_JSON, LOGGER_OPTIONS, Log, Logger, LoggerInjector, LoggerLevel, LoggerModule, LoggerService, TimerLog, TraceLog, WarnLog };
//# sourceMappingURL=angular-ru-cdk-logger.mjs.map
