"use strict";

Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.WebInstallerTarget = undefined;

var _bluebirdLst;

function _load_bluebirdLst() {
    return _bluebirdLst = require("bluebird-lst");
}

var _PublishManager;

function _load_PublishManager() {
    return _PublishManager = require("../../publish/PublishManager");
}

var _nsis;

function _load_nsis() {
    return _nsis = require("./nsis");
}

/** @private */
class WebInstallerTarget extends (_nsis || _load_nsis()).NsisTarget {
    constructor(packager, outDir, targetName, packageHelper) {
        super(packager, outDir, targetName, packageHelper);
        if (this.options.differentialPackage == null) {
            this.options.differentialPackage = true;
        }
    }
    get isWebInstaller() {
        return true;
    }
    configureDefines(oneClick, defines) {
        var _this = this;

        return (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* () {
            //noinspection ES6MissingAwait
            yield (_nsis || _load_nsis()).NsisTarget.prototype.configureDefines.call(_this, oneClick, defines);
            const packager = _this.packager;
            const options = _this.options;
            let appPackageUrl = options.appPackageUrl;
            if (appPackageUrl == null) {
                const publishConfigs = yield (0, (_PublishManager || _load_PublishManager()).getPublishConfigsForUpdateInfo)(packager, (yield (0, (_PublishManager || _load_PublishManager()).getPublishConfigs)(packager, _this.options, null)), null);
                if (publishConfigs == null || publishConfigs.length === 0) {
                    throw new Error("Cannot compute app package download URL");
                }
                appPackageUrl = (0, (_PublishManager || _load_PublishManager()).computeDownloadUrl)(publishConfigs[0], null, packager);
                defines.APP_PACKAGE_URL_IS_INCOMLETE = null;
            }
            defines.APP_PACKAGE_URL = appPackageUrl;
        })();
    }
    get installerFilenamePattern() {
        // tslint:disable:no-invalid-template-strings
        return "${productName} Web Setup ${version}.${ext}";
    }
    generateGitHubInstallerName() {
        const appInfo = this.packager.appInfo;
        const classifier = appInfo.name.toLowerCase() === appInfo.name ? "web-setup" : "WebSetup";
        return `${appInfo.name}-${classifier}-${appInfo.version}.exe`;
    }
}
exports.WebInstallerTarget = WebInstallerTarget; //# sourceMappingURL=WebInstallerTarget.js.map