import has_default from "../../../../../../lodash-es/has.js";
import { timer } from "../../../../../../@chevrotain/utils/lib/src/timer.js";
import { DEFAULT_PARSER_CONFIG } from "../parser.js";
var PerformanceTracer = class {
	initPerformanceTracer(t) {
		if (has_default(t, "traceInitPerf")) {
			let e = t.traceInitPerf, n = typeof e == "number";
			this.traceInitMaxIdent = n ? e : Infinity, this.traceInitPerf = n ? e > 0 : e;
		} else this.traceInitMaxIdent = 0, this.traceInitPerf = DEFAULT_PARSER_CONFIG.traceInitPerf;
		this.traceInitIndent = -1;
	}
	TRACE_INIT(e, n) {
		if (this.traceInitPerf === !0) {
			this.traceInitIndent++;
			let r = Array(this.traceInitIndent + 1).join("	");
			this.traceInitIndent < this.traceInitMaxIdent && console.log(`${r}--> <${e}>`);
			let { time: i, value: a } = timer(n), o = i > 10 ? console.warn : console.log;
			return this.traceInitIndent < this.traceInitMaxIdent && o(`${r}<-- <${e}> time: ${i}ms`), this.traceInitIndent--, a;
		} else return n();
	}
};
export { PerformanceTracer };
