"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCriticalCompiler = void 0;
const getCriticalCompiler = (critical, compiler) => {
    const lock = (func) => __awaiter(void 0, void 0, void 0, function* () {
        yield critical.acquire();
        try {
            return yield func();
        }
        finally {
            yield critical.release();
        }
    });
    return {
        prisma: {
            compile: (props) => lock(() => compiler.prisma.compile(props)),
            validate: (app) => lock(() => compiler.prisma.validate(app)),
            write: (app, dmbs) => lock(() => compiler.prisma.write(app, dmbs)),
        },
        interface: {
            write: (doc) => lock(() => compiler.interface.write(doc)),
            transform: (doc) => lock(() => compiler.interface.transform(doc)),
            invert: (doc) => lock(() => compiler.interface.invert(doc)),
            getTemplate: () => lock(() => compiler.interface.getTemplate()),
        },
        typescript: {
            compile: (props) => lock(() => compiler.typescript.compile(props)),
            getExternal: (location) => lock(() => compiler.typescript.getExternal(location)),
            beautify: (code) => lock(() => compiler.typescript.beautify(code)),
        },
        test: {
            compile: (props) => lock(() => compiler.test.compile(props)),
            validate: (props) => lock(() => compiler.test.validate(props)),
            write: (props) => lock(() => compiler.test.write(props)),
            getExternal: () => lock(() => compiler.test.getExternal()),
            getTemplate: () => lock(() => compiler.test.getTemplate()),
        },
        realize: {
            controller: (props) => lock(() => compiler.realize.controller(props)),
            test: (props) => lock(() => compiler.realize.test(props)),
            getTemplate: (options) => lock(() => compiler.realize.getTemplate(options)),
        },
    };
};
exports.getCriticalCompiler = getCriticalCompiler;
//# sourceMappingURL=getCriticalCompiler.js.map