"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var common_1 = require("../common");
var PATH = common_1.constants.PATH;
var ElectronSettings = (function () {
    function ElectronSettings(args) {
        var data = args.data, dir = args.dir;
        this.exists = Boolean(data);
        this.dir = dir;
        this.data = data || {};
    }
    Object.defineProperty(ElectronSettings.prototype, "name", {
        get: function () {
            return this.data.name || 'Unnamed';
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElectronSettings.prototype, "port", {
        get: function () {
            return this.data.port || 8888;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElectronSettings.prototype, "entry", {
        get: function () {
            var _a = PATH.ELECTRON, MAIN = _a.MAIN, RENDERER = _a.RENDERER;
            var entry = typeof this.data.entry === 'object' ? this.data.entry : {};
            var main = entry.main || MAIN.DEFAULT_ENTRY;
            var renderer = entry.renderer || RENDERER.DEFAULT_ENTRY;
            return { main: main, renderer: renderer };
        },
        enumerable: true,
        configurable: true
    });
    ElectronSettings.prototype.out = function (prod) {
        var _a = PATH.ELECTRON, MAIN = _a.MAIN, RENDERER = _a.RENDERER;
        var mainDir = MAIN.OUT_DIR;
        var rendererDir = prod ? RENDERER.OUT_DIR.PROD : RENDERER.OUT_DIR.DEV;
        return {
            main: {
                dir: mainDir,
                file: MAIN.OUT_FILE,
                path: common_1.fsPath.join(mainDir, MAIN.OUT_FILE),
            },
            renderer: {
                dir: rendererDir,
                file: RENDERER.OUT_FILE,
                path: common_1.fsPath.join(rendererDir, RENDERER.OUT_FILE),
            },
        };
    };
    Object.defineProperty(ElectronSettings.prototype, "bundlerArgs", {
        get: function () {
            return common_1.toBundlerArgs(this.data.bundle);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElectronSettings.prototype, "builderArgsJson", {
        get: function () {
            var _this = this;
            var load = function () {
                var dir = common_1.fsPath.resolve(_this.dir);
                var path = common_1.fsPath.join(dir, PATH.ELECTRON.BUILDER.CONFIG.FILE_NAME);
                return common_1.file.loadAndParseSync(path, {});
            };
            return this._builderConfig || (this._builderConfig = load());
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElectronSettings.prototype, "builderArgs", {
        get: function () {
            var config = this.builderArgsJson;
            var productName = config.productName, appId = config.appId, directories = config.directories;
            var outputDir = directories ? directories.output : undefined;
            return {
                exists: this.exists,
                productName: productName,
                appId: appId,
                outputDir: outputDir,
            };
        },
        enumerable: true,
        configurable: true
    });
    return ElectronSettings;
}());
exports.ElectronSettings = ElectronSettings;
//# sourceMappingURL=ElectronSettings.js.map