exports.id = 672;
exports.ids = [672];
exports.modules = {

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

"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());
    });
};
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 __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
var pool_1 = __importDefault(__webpack_require__(541808));
var misc_1 = __webpack_require__(854006);
var uuid_1 = __webpack_require__(282185);
var compute_images_1 = __webpack_require__(533888);
function createProject(_a) {
    var account_id = _a.account_id, title = _a.title, description = _a.description, image = _a.image, license = _a.license;
    return __awaiter(this, void 0, void 0, function () {
        var project_id, pool, users, site_license, x;
        var _b;
        return __generator(this, function (_c) {
            switch (_c.label) {
                case 0:
                    if (!(0, misc_1.is_valid_uuid_string)(account_id)) {
                        throw Error("account_id must be a valid uuid");
                    }
                    project_id = (0, uuid_1.v4)();
                    pool = (0, pool_1.default)();
                    users = (_b = {}, _b[account_id] = { group: "owner" }, _b);
                    if (license) {
                        site_license = {};
                        for (x in license.split(",")) {
                            site_license[x] = {};
                        }
                    }
                    else {
                        site_license = undefined;
                    }
                    return [4 /*yield*/, pool.query("INSERT INTO projects (project_id, title, description, users, site_license, compute_image, created, last_edited) VALUES($1, $2, $3, $4, $5, $6, NOW(), NOW())", [
                            project_id,
                            title,
                            description,
                            JSON.stringify(users),
                            site_license != null ? JSON.stringify(site_license) : undefined,
                            image !== null && image !== void 0 ? image : compute_images_1.DEFAULT_COMPUTE_IMAGE,
                        ])];
                case 1:
                    _c.sent();
                    return [2 /*return*/, project_id];
            }
        });
    });
}
exports["default"] = createProject;
//# sourceMappingURL=create.js.map

/***/ }),

/***/ 630900:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {

var crypto = __webpack_require__(706113);

var rn = function(max) {
  var rnBytes = crypto.randomBytes(2);
  var randomNum = rnBytes.readUInt8(0) * 256 + rnBytes.readUInt8(1);
  return randomNum % max;
}

var digits = '0123456789'
var base62 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'
var base30 = '0123456789ABCDFHKLMNPQRSTUVWXYZ'  // 1-9, A-Z exclude(E, G, I, J, O) for human read

exports.generate = function(len, chars) {
  len = len || 16;
  chars = chars || base62;
  var key = '';
  var charsLen = chars.length;
  for (var i=0; i<len; i++) {
    key += chars[rn(charsLen)];
  }
  return key;
};

exports.generateDigits = function(len) {
  len = len || 16;
  return exports.generate(len, digits)
};

exports.generateBase30 = function(len) {
  len = len || 16;
  return exports.generate(len, base30)
}


/***/ }),

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

"use strict";

/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.is_valid = exports.get_compute_images = exports.COMPUTE_IMAGES = exports.GROUPS = exports.FALLBACK_COMPUTE_IMAGE = exports.DEFAULT_COMPUTE_IMAGE = void 0;
// this is tied to the back-end setup of cocalc.com
var misc_1 = __webpack_require__(854006);
var schema = __importStar(__webpack_require__(98416));
exports.DEFAULT_COMPUTE_IMAGE = schema.DEFAULT_COMPUTE_IMAGE;
exports.FALLBACK_COMPUTE_IMAGE = schema.FALLBACK_COMPUTE_IMAGE;
// this defines their ordering
exports.GROUPS = [
    "Main",
    "Ubuntu 20.04",
    "Ubuntu 18.04",
    "Ubuntu 16.04",
];
exports.COMPUTE_IMAGES = {
    // "default" or "undefined" is what was used for "ubuntu1804" until summer 2020
    // nowdays, DEFAULT_COMPUTE_IMAGE is "ubuntu2004"
    default: {
        order: 1,
        title: "Ubuntu 18.04 (Deprecated)",
        short: "Ubuntu 18.04 (Deprecated)",
        descr: "Ubuntu 18.04 reached end of life in August 2020",
        group: "Main",
        hidden: true,
    },
    ubuntu1804: {
        // a synonym of "default", but with a specific functionality!
        // we use it as a marker: if a "default" project (before the 20.04 upgrade) is set to stay at 18.04, this image is selected.
        order: 1,
        title: "Ubuntu 18.04 (EndOfLife)",
        short: "Ubuntu 18.04 (EndOfLife)",
        descr: "Ubuntu 18.04 reached end of life in August 2020",
        group: "Main",
    },
    ubuntu2004: {
        order: 0,
        title: "Ubuntu 20.04 (Default)",
        short: "Ubuntu 20.04 (Default)",
        descr: "Regular updates, well tested",
        group: "Main",
    },
    "ubuntu2004-previous": {
        title: "Ubuntu 20.04 (Previous)",
        short: "Previous",
        descr: "Slightly behind 20.04 (Default)",
        group: "Ubuntu 20.04",
    },
    "ubuntu2004-dev": {
        title: "Ubuntu 20.04 (Experimental)",
        short: "Experimental",
        descr: "Cutting-edge software updates (could be broken)",
        group: "Ubuntu 20.04",
    },
    "ubuntu2004-2020-10-28": {
        title: "Ubuntu 20.04 (2020-10-28)",
        short: "2020-10-28",
        group: "Ubuntu 20.04",
        descr: "Frozen on 2020-10-28 and no longer updated",
    },
    "ubuntu2004-2020-12-09": {
        title: "Ubuntu 20.04 (2020-12-09)",
        short: "2020-12-09",
        group: "Ubuntu 20.04",
        descr: "Frozen on 2020-12-09 and no longer updated",
    },
    "ubuntu2004-2021-02-01": {
        title: "Ubuntu 20.04 (2021-02-01)",
        short: "2021-02-01",
        group: "Ubuntu 20.04",
        descr: "Frozen on 2021-02-01 and no longer updated",
    },
    "ubuntu2004-2021-05-31": {
        title: "Ubuntu 20.04 (2021-05-31)",
        short: "2021-05-31",
        group: "Ubuntu 20.04",
        descr: "Frozen on 2021-05-31 and no longer updated",
    },
    "ubuntu2004-2021-08-13": {
        title: "Ubuntu 20.04 (2021-08-13)",
        short: "2021-08-13",
        group: "Ubuntu 20.04",
        descr: "Frozen on 2021-08-13 and no longer updated",
    },
    "ubuntu2004-2021-10-10": {
        title: "Ubuntu 20.04 (2021-10-10)",
        short: "2021-10-10",
        group: "Ubuntu 20.04",
        descr: "Frozen on 2021-10-10 and no longer updated",
    },
    "ubuntu2004-2022-04-19": {
        title: "Ubuntu 20.04 (2022-04-19)",
        short: "2022-04-19",
        group: "Ubuntu 20.04",
        descr: "Frozen on 2022-04-19 and no longer updated",
    },
    previous: {
        order: -2,
        title: "Ubuntu 18.04 (Previous)",
        short: "Previous",
        descr: "Ubuntu 18.04 Reached end of life in August 2020",
        group: "Ubuntu 18.04",
        hidden: true,
    },
    exp: {
        order: -1,
        title: "Ubuntu 18.04 (Experimental)",
        short: "Experimental",
        descr: "Reached end of life in August 2020",
        group: "Ubuntu 18.04",
        hidden: true,
    },
    "stable-2018-08-27": {
        title: "Ubuntu 18.04 @ 2018-08-27",
        short: "2018-08-27",
        descr: "Frozen on 2018-08-27 and no longer updated",
        group: "Ubuntu 18.04",
    },
    "stable-2019-01-12": {
        title: "Ubuntu 18.04 @ 2019-01-12",
        short: "2019-01-12",
        descr: "Frozen on 2019-01-12 and no longer updated",
        group: "Ubuntu 18.04",
    },
    "stable-2019-07-15": {
        title: "Ubuntu 18.04 @ 2019-07-15",
        short: "2019-07-15",
        descr: "Frozen on 2019-07-15 and no longer updated",
        group: "Ubuntu 18.04",
    },
    "stable-2019-10-25_ro": {
        title: "Ubuntu 18.04 @ 2019-10-25",
        short: "2019-10-25",
        descr: "Frozen on 2019-10-25 and no longer updated",
        group: "Ubuntu 18.04",
    },
    "stable-2019-12-15_ro": {
        title: "Ubuntu 18.04 @ 2019-12-15",
        short: "2019-12-15",
        descr: "Frozen on 2019-12-15 and no longer updated",
        group: "Ubuntu 18.04",
    },
    "stable-2020-01-26_ro": {
        title: "Ubuntu 18.04 @ 2020-01-26",
        short: "2020-01-26",
        descr: "Frozen on 2020-01-26 and no longer updated",
        group: "Ubuntu 18.04",
    },
    "stable-2020-07-31": {
        title: "Ubuntu 18.04 @ 2020-07-31",
        short: "2020-07-31",
        descr: "Frozen on 2020-07-31 and no longer updated",
        group: "Ubuntu 18.04",
    },
    old: {
        order: 10,
        title: "Old Ubuntu 16.04",
        short: "Old software image",
        descr: "In use until Summer 2018. No longer maintained!",
        group: "Ubuntu 16.04",
    },
};
function get_compute_images(opts) {
    opts = (0, misc_1.defaults)(opts, { cb: misc_1.required });
    opts.cb(undefined, exports.COMPUTE_IMAGES);
}
exports.get_compute_images = get_compute_images;
var is_valid = function (name) { return exports.COMPUTE_IMAGES[name] != null; };
exports.is_valid = is_valid;
//# sourceMappingURL=compute-images.js.map

/***/ })

};
;