"use strict";
exports.id = 3009;
exports.ids = [3009];
exports.modules = {

/***/ 612134:
/***/ ((__unused_webpack_module, exports) => {


/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.LICENSE_MIN_PRICE = exports.ONE_MONTH_MS = exports.AVG_YEAR_DAYS = exports.AVG_MONTH_DAYS = exports.ONE_DAY_MS = void 0;
exports.ONE_DAY_MS = 24 * 60 * 60 * 1000;
exports.AVG_MONTH_DAYS = 30.5;
exports.AVG_YEAR_DAYS = 12 * exports.AVG_MONTH_DAYS;
exports.ONE_MONTH_MS = exports.AVG_MONTH_DAYS * exports.ONE_DAY_MS;
// throughout the UI, we show this price as the minimum (per month)
exports.LICENSE_MIN_PRICE = "less than $4/month";
//# sourceMappingURL=billing.js.map

/***/ }),

/***/ 473009:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


/*
 *  This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
var __values = (this && this.__values) || function(o) {
    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
    if (m) return m.call(o);
    if (o && typeof o.length === "number") return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var e_1, _a, e_2, _b, e_3, _c;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.PRICES = exports.DEFAULT_DEDICATED_VM_MACHINE = exports.getDedicatedDiskKey = exports.DEFAULT_DEDICATED_DISK_SPEED = exports.DEDICATED_DISK_SPEEDS = exports.DEDICATED_DISK_SIZES = exports.DEFAULT_DEDICATED_DISK_SIZE = exports.DEDICATED_DISK_SIZE_INCREMENT = exports.MAX_DEDICATED_DISK_SIZE = exports.MIN_DEDICATED_DISK_SIZE = exports.VMS = void 0;
var billing_1 = __webpack_require__(612134);
var dedicated_1 = __webpack_require__(451349);
// derive price to charge per day from the base monthly price
function rawPrice2Retail(p, discount) {
    if (discount === void 0) { discount = false; }
    // factor of 2 and an average month
    // discount factor: for VMs, we pass it on a little bit
    var df = discount ? 90 / 100 : 1;
    return (2 * p * df) / billing_1.AVG_MONTH_DAYS;
}
// the "per core" unit of memory you get for n2 machine families
function deriveMemBase(size) {
    switch (size) {
        case "standard":
            return 4;
        case "highmem":
            return 8;
        default:
            throw new Error("deriveMemBase size \"".concat(size, "\" unknown"));
    }
}
function deriveVMSpecs(spec) {
    var _a = __read(spec.split("-"), 3), family = _a[0], size = _a[1], cpu_str = _a[2];
    if (family != "n2")
        throw new Error("machine families beside \"n2\" are not supported -- implement it!");
    var cpu = parseInt(cpu_str);
    if (typeof cpu !== "number" || cpu <= 0)
        throw new Error("core must be 2, 4, 8, ...");
    var mem_base = deriveMemBase(size);
    var mem = cpu * mem_base;
    return { family: family, mem: mem, cpu: cpu };
}
// string is like n2-standard-2 or n2-highmem-4
function deriveQuotas(_a) {
    var mem = _a.mem, cpu = _a.cpu;
    return {
        mem: mem - 2,
        cpu: cpu, // we can safely give all cores to the project
    };
}
// calculate the price proportional to cpu and memory
function getDedicatedVMPrice(_a) {
    var mem = _a.mem, cpu = _a.cpu, family = _a.family;
    switch (family) {
        case "n2":
            // https://cloud.google.com/compute/vm-instance-pricing#general-purpose_machine_type_family
            // N2 machine types: us-east1 and monthly on-demand
            // ATTN: that's with 20% usage discount – we factor it out and discount on our own
            var cpu_montly = 18.46 / 0.8;
            var mem_montly = 2.47 / 0.8;
            var gcp_price = cpu * cpu_montly + mem * mem_montly;
            return rawPrice2Retail(gcp_price, true);
        default:
            throw new Error("family ".concat(family, " not supported"));
    }
}
// ATTN: chagnes here have implications for the stripe product ID
// only append values, do not insert them in the middle or the beginning!
var VM_MEM_SIZES = ["standard", "highmem"];
// this is used below to avoid wrong values and easier adjustments
function getSpecAndQuota(_a) {
    var family = _a.family, memSize = _a.memSize, cpus = _a.cpus;
    var spec = "".concat(family, "-").concat(memSize, "-").concat(cpus);
    var midx = VM_MEM_SIZES.indexOf(memSize);
    var data = deriveVMSpecs(spec);
    var quotas = deriveQuotas(data);
    return {
        title: "".concat(quotas.cpu, " CPU cores, ").concat(quotas.mem, "G RAM"),
        price_day: getDedicatedVMPrice(data),
        spec: quotas,
        quota: { dedicated_vm: spec },
        // "d"edicated "VM", family n2, "m"emory [index] and "c"pu cores number
        stripeID: "dVM".concat(family, "m").concat(midx, "c").concat(cpus), // partial stripe product id
    };
}
// generate all dedicated VM specs we want to offer
function getVMData() {
    var family, VM_MEM_SIZES_1, VM_MEM_SIZES_1_1, memSize, _a, _b, cpus, e_4_1, e_5_1;
    var e_5, _c, e_4, _d;
    return __generator(this, function (_e) {
        switch (_e.label) {
            case 0:
                family = "n2";
                _e.label = 1;
            case 1:
                _e.trys.push([1, 12, 13, 14]);
                VM_MEM_SIZES_1 = __values(VM_MEM_SIZES), VM_MEM_SIZES_1_1 = VM_MEM_SIZES_1.next();
                _e.label = 2;
            case 2:
                if (!!VM_MEM_SIZES_1_1.done) return [3 /*break*/, 11];
                memSize = VM_MEM_SIZES_1_1.value;
                _e.label = 3;
            case 3:
                _e.trys.push([3, 8, 9, 10]);
                _a = (e_4 = void 0, __values([2, 4, 8, 16])), _b = _a.next();
                _e.label = 4;
            case 4:
                if (!!_b.done) return [3 /*break*/, 7];
                cpus = _b.value;
                return [4 /*yield*/, getSpecAndQuota({ family: family, memSize: memSize, cpus: cpus })];
            case 5:
                _e.sent();
                _e.label = 6;
            case 6:
                _b = _a.next();
                return [3 /*break*/, 4];
            case 7: return [3 /*break*/, 10];
            case 8:
                e_4_1 = _e.sent();
                e_4 = { error: e_4_1 };
                return [3 /*break*/, 10];
            case 9:
                try {
                    if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
                }
                finally { if (e_4) throw e_4.error; }
                return [7 /*endfinally*/];
            case 10:
                VM_MEM_SIZES_1_1 = VM_MEM_SIZES_1.next();
                return [3 /*break*/, 2];
            case 11: return [3 /*break*/, 14];
            case 12:
                e_5_1 = _e.sent();
                e_5 = { error: e_5_1 };
                return [3 /*break*/, 14];
            case 13:
                try {
                    if (VM_MEM_SIZES_1_1 && !VM_MEM_SIZES_1_1.done && (_c = VM_MEM_SIZES_1.return)) _c.call(VM_MEM_SIZES_1);
                }
                finally { if (e_5) throw e_5.error; }
                return [7 /*endfinally*/];
            case 14: return [2 /*return*/];
        }
    });
}
exports.VMS = {};
try {
    for (var _d = __values(getVMData()), _e = _d.next(); !_e.done; _e = _d.next()) {
        var vmtype = _e.value;
        exports.VMS[vmtype.quota.dedicated_vm] = vmtype;
    }
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
    try {
        if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
    }
    finally { if (e_1) throw e_1.error; }
}
var DISKS = {};
// we add a bit for snapshot storage
var SNAPSHOT_FACTOR = 1.25;
// price numbers are for 1 month and 1024 gb (more significant digits) and zonal storage
var DISK_MONTHLY_1GB = {
    standard: (SNAPSHOT_FACTOR * 40.96) / 1024,
    balanced: (SNAPSHOT_FACTOR * 102.4) / 1024,
    ssd: (SNAPSHOT_FACTOR * 174.08) / 1024,
};
// https://cloud.google.com/compute/docs/disks/performance#performance_by_disk_size
var IOPS = {
    standard: { read: 0.75, write: 1.5 },
    balanced: { read: 6, write: 6 },
    ssd: { read: 30, write: 30 },
};
// sustained throughput
var MBPS = {
    standard: { read: 0.12, write: 0.12 },
    balanced: { read: 0.28, write: 0.28 },
    ssd: { read: 0.48, write: 0.48 },
};
// below, we define all valid dedicated disk configurations
exports.MIN_DEDICATED_DISK_SIZE = 32;
exports.MAX_DEDICATED_DISK_SIZE = 1024;
exports.DEDICATED_DISK_SIZE_INCREMENT = 32;
exports.DEFAULT_DEDICATED_DISK_SIZE = exports.MIN_DEDICATED_DISK_SIZE + exports.DEDICATED_DISK_SIZE_INCREMENT;
// this must be kept in sync with the numerical slider in next/store/dedicated
// we also make it readonly to avoid accidental changes
exports.DEDICATED_DISK_SIZES = (function () {
    var v = [];
    for (var i = exports.MIN_DEDICATED_DISK_SIZE; i <= exports.MAX_DEDICATED_DISK_SIZE; i += exports.DEDICATED_DISK_SIZE_INCREMENT) {
        v.push(i);
    }
    return v;
})();
// ATTN: do not modify/insert/prepend to this list -- only append
// otherwise you distort the stripe ID!
exports.DEDICATED_DISK_SPEEDS = [
    "standard",
    "balanced",
    "ssd",
];
exports.DEFAULT_DEDICATED_DISK_SPEED = "standard";
function getDedicatedDiskKey(_a) {
    var size_gb = _a.size_gb, speed = _a.speed;
    return "".concat(size_gb, "-").concat(speed);
}
exports.getDedicatedDiskKey = getDedicatedDiskKey;
try {
    for (var DEDICATED_DISK_SIZES_1 = __values(exports.DEDICATED_DISK_SIZES), DEDICATED_DISK_SIZES_1_1 = DEDICATED_DISK_SIZES_1.next(); !DEDICATED_DISK_SIZES_1_1.done; DEDICATED_DISK_SIZES_1_1 = DEDICATED_DISK_SIZES_1.next()) {
        var size_gb = DEDICATED_DISK_SIZES_1_1.value;
        try {
            for (var DEDICATED_DISK_SPEEDS_1 = (e_3 = void 0, __values(exports.DEDICATED_DISK_SPEEDS)), DEDICATED_DISK_SPEEDS_1_1 = DEDICATED_DISK_SPEEDS_1.next(); !DEDICATED_DISK_SPEEDS_1_1.done; DEDICATED_DISK_SPEEDS_1_1 = DEDICATED_DISK_SPEEDS_1.next()) {
                var speed = DEDICATED_DISK_SPEEDS_1_1.value;
                var quota = {
                    dedicated_disk: { size_gb: size_gb, speed: speed },
                };
                var tIdx = exports.DEDICATED_DISK_SPEEDS.indexOf(speed);
                var title = "".concat(size_gb, "G ").concat(dedicated_1.DISK_NAMES[speed]);
                var key = getDedicatedDiskKey({ size_gb: size_gb, speed: speed });
                DISKS[key] = {
                    quota: quota,
                    title: title,
                    price_day: rawPrice2Retail(DISK_MONTHLY_1GB[speed] * size_gb),
                    iops: "".concat(size_gb * IOPS[speed].read, "/").concat(size_gb * IOPS[speed].write),
                    mbps: "".concat(Math.round(size_gb * MBPS[speed].read), "/") +
                        "".concat(Math.round(size_gb * MBPS[speed].write)),
                    // dedicated "D"isk, "t"ype [number] and "s"ize [number]
                    stripeID: "dDt".concat(tIdx, "s").concat(size_gb),
                };
            }
        }
        catch (e_3_1) { e_3 = { error: e_3_1 }; }
        finally {
            try {
                if (DEDICATED_DISK_SPEEDS_1_1 && !DEDICATED_DISK_SPEEDS_1_1.done && (_c = DEDICATED_DISK_SPEEDS_1.return)) _c.call(DEDICATED_DISK_SPEEDS_1);
            }
            finally { if (e_3) throw e_3.error; }
        }
    }
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
    try {
        if (DEDICATED_DISK_SIZES_1_1 && !DEDICATED_DISK_SIZES_1_1.done && (_b = DEDICATED_DISK_SIZES_1.return)) _b.call(DEDICATED_DISK_SIZES_1);
    }
    finally { if (e_2) throw e_2.error; }
}
exports.DEFAULT_DEDICATED_VM_MACHINE = getSpecAndQuota({
    family: "n2",
    memSize: "highmem",
    cpus: 2,
}).quota.dedicated_vm;
exports.PRICES = {
    vms: exports.VMS,
    disks: DISKS,
    disks_monthly: DISK_MONTHLY_1GB,
};
//# sourceMappingURL=dedicated.js.map

/***/ })

};
;