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

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


var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
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;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
var jsx_runtime_1 = __webpack_require__(920997);
var react_1 = __webpack_require__(616689);
var antd_1 = __webpack_require__(533734);
var react_copy_to_clipboard_1 = __webpack_require__(132213);
var icon_1 = __webpack_require__(807772);
var INPUT_STYLE = { display: "inline-block", flex: 1 };
var LABEL_STYLE = {
    marginRight: "15px",
    display: "flex",
    flex: "0 0 auto",
    justifyContent: "center",
    alignContent: "center",
    flexDirection: "column",
};
function CopyToClipBoard(props) {
    var value = props.value, style = props.style, size = props.size, label = props.label, labelStyle = props.labelStyle, inputStyle = props.inputStyle;
    var _a = __read((0, react_1.useState)(false), 2), copied = _a[0], setCopied = _a[1];
    (0, react_1.useEffect)(function () {
        setCopied(false);
    }, [value]);
    var copy = (0, react_1.useMemo)(function () {
        var btn = ((0, jsx_runtime_1.jsx)(react_copy_to_clipboard_1.CopyToClipboard, __assign({ text: value, onCopy: function () { return setCopied(true); } }, { children: (0, jsx_runtime_1.jsx)(antd_1.Button, __assign({ size: size, style: {
                    margin: "-2px -12px" /* hack so doesn't conflict w/ style of Input below*/,
                } }, { children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { name: copied ? "clipboard-check" : "clipboard" }) })) })));
        if (!copied)
            return btn;
        return ((0, jsx_runtime_1.jsx)(antd_1.Tooltip, __assign({ title: "Copied!", defaultVisible: true }, { children: btn })));
    }, [value, copied, size]);
    var input = ((0, jsx_runtime_1.jsx)(antd_1.Input, { size: size, readOnly: true, onFocus: function (e) { return e.target.select(); }, value: value, addonAfter: copy }));
    if (!label)
        return (0, jsx_runtime_1.jsx)("div", __assign({ style: style }, { children: input }));
    return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: __assign({ display: "flex" }, style) }, { children: [(0, jsx_runtime_1.jsx)("div", __assign({ style: __assign(__assign({}, LABEL_STYLE), labelStyle) }, { children: label })), " ", (0, jsx_runtime_1.jsx)("div", __assign({ style: __assign(__assign({}, INPUT_STYLE), inputStyle) }, { children: input }))] })));
}
exports["default"] = CopyToClipBoard;
//# sourceMappingURL=copy-to-clipboard.js.map

/***/ }),

/***/ 34873:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "M": () => (/* binding */ EditableTitle),
/* harmony export */   "q": () => (/* binding */ EditableDescription)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(920997);
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(545725);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(antd__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(616689);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var lib_api_post__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(194184);
/* harmony import */ var _cocalc_util_misc__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(477389);
/* harmony import */ var _cocalc_util_misc__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_cocalc_util_misc__WEBPACK_IMPORTED_MODULE_4__);





function EditableTitle({ license_id , title , onChange  }) {
    return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(EditableTextField, {
        license_id: license_id,
        field: "title",
        value: title,
        onChange: onChange
    });
}
function EditableDescription({ license_id , description , onChange  }) {
    return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(EditableTextField, {
        license_id: license_id,
        field: "description",
        value: description,
        rows: 3,
        onChange: onChange
    });
}
function EditableTextField({ license_id , field , value , rows , onChange  }) {
    const { 0: edit , 1: setEdit  } = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(false);
    const { 0: value2 , 1: setValue  } = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(value ?? "");
    const { 0: error , 1: setError  } = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)("");
    (0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(()=>{
        setValue(value ?? "");
        setEdit(false);
        setError("");
    }, [
        value
    ]);
    async function save(value) {
        setEdit(false);
        setError("");
        const query = {
            manager_site_licenses: {
                id: license_id,
                [field]: value
            }
        };
        try {
            await (0,lib_api_post__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z)("/user-query", {
                query
            });
            onChange?.();
        } catch (err) {
            setError(err.message);
        }
    }
    return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
        style: {
            cursor: "pointer"
        },
        onClick: ()=>setEdit(true),
        children: [
            error && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(antd__WEBPACK_IMPORTED_MODULE_1__.Alert, {
                type: "error",
                message: `Error saving ${field} - ${error}`
            }),
            (0,_cocalc_util_misc__WEBPACK_IMPORTED_MODULE_4__.capitalize)(field),
            ":",
            " ",
            edit && (rows ? /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(antd__WEBPACK_IMPORTED_MODULE_1__.Input.TextArea, {
                autoFocus: true,
                value: value2,
                onChange: (e)=>setValue(e.target.value),
                onBlur: ()=>save(value2),
                rows: rows
            }) : /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(antd__WEBPACK_IMPORTED_MODULE_1__.Input, {
                autoFocus: true,
                value: value2,
                onChange: (e)=>setValue(e.target.value),
                onBlur: ()=>save(value2),
                onPressEnter: ()=>save(value2)
            })),
            !edit && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
                children: value2.trim() ? value2 : `(set ${field}...)`
            })
        ]
    });
}


/***/ }),

/***/ 776527:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "C0": () => (/* binding */ DateRange),
/* harmony export */   "PO": () => (/* binding */ Details),
/* harmony export */   "ZP": () => (/* binding */ License),
/* harmony export */   "cF": () => (/* binding */ Quota)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(920997);
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _cocalc_util_licenses_describe_quota__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(21969);
/* harmony import */ var _cocalc_util_licenses_describe_quota__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_cocalc_util_licenses_describe_quota__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _cocalc_util_misc__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(477389);
/* harmony import */ var _cocalc_util_misc__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_cocalc_util_misc__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(545725);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(antd__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var components_misc_A__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(940981);
/* harmony import */ var components_misc_copyable__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(393884);
/* harmony import */ var components_misc_timestamp__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(749414);
/* harmony import */ var components_share_loading__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(976087);
/* harmony import */ var lib_hooks_api__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(375698);
/* harmony import */ var _editable_license__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(34873);










function License({ license_id , style  }) {
    // TODO: do something with contrib
    return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(antd__WEBPACK_IMPORTED_MODULE_3__.Popover, {
        content: ()=>/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(Details, {
                license_id: license_id
            }),
        title: license_id,
        mouseEnterDelay: 0.5,
        children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(components_misc_A__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
            style: {
                cursor: "pointer",
                fontFamily: "monospace",
                ...style
            },
            href: `/licenses/how-used?license_id=${license_id}`,
            children: license_id
        })
    });
};
/*
{
  "id": "cad2fe88-29d7-4f4e-987c-a3ae6143a25b",
  "title": "different business license for specific time",
  "description": "",
  "expires": 1642799517638,
  "activates": 1640121117638,
  "last_used": null,
  "managers": [
    "93620c6e-324a-4217-a60e-2ac436953174"
  ],
  "upgrades": null,
  "quota": {
    "cpu": 1,
    "ram": 1,
    "disk": 1,
    "user": "business",
    "member": true,
    "dedicated_cpu": 0,
    "dedicated_ram": 0,
    "always_running": true
  },
  "run_limit": 3,
  is_manager:true,
  number_running:2
}
*/ function Details({ license_id  }) {
    const { result , error  } = (0,lib_hooks_api__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z)("licenses/get-license", {
        license_id
    }, 3); // 3s cache
    if (error) {
        return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(antd__WEBPACK_IMPORTED_MODULE_3__.Alert, {
            type: "error",
            message: error
        });
    }
    if (!result) {
        return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(components_share_loading__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z, {});
    }
    return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
        children: [
            (result.title || result.is_manager) && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                style: {
                    fontWeight: "bold",
                    fontSize: "13pt"
                },
                children: result.is_manager ? /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_editable_license__WEBPACK_IMPORTED_MODULE_9__/* .EditableTitle */ .M, {
                    license_id: license_id,
                    title: result.title
                }) : "Title: " + result.title
            }),
            (result.description || result.is_manager) && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                children: result.is_manager ? /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_editable_license__WEBPACK_IMPORTED_MODULE_9__/* .EditableDescription */ .q, {
                    license_id: license_id,
                    description: result.description
                }) : "Description: " + result.description
            }),
            result.managers != null && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                children: "You are a manager of this license."
            }),
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
                children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(DateRange, {
                    ...result
                })
            }),
            result.last_used != null && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                children: [
                    "Last used: ",
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(components_misc_timestamp__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z, {
                        epoch: result.last_used
                    })
                ]
            }),
            /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                children: [
                    "Quota: ",
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(Quota, {
                        quota: result.quota,
                        upgrades: result.upgrades
                    })
                ]
            }),
            result.run_limit != null && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
                style: {
                    width: "100%",
                    display: "flex"
                },
                children: [
                    "Run limit: ",
                    result.run_limit,
                    result.number_running != null ? `; Currently running: ${result.number_running}` : "",
                    result.run_limit && result.number_running != null && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(antd__WEBPACK_IMPORTED_MODULE_3__.Progress, {
                        style: {
                            marginLeft: "15px",
                            flex: 1
                        },
                        percent: Math.round(result.number_running / result.run_limit * 100)
                    })
                ]
            }),
            result.is_manager && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(components_misc_copyable__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z, {
                label: "ID:",
                value: license_id,
                style: {
                    marginTop: "5px"
                }
            })
        ]
    });
}
function Quota({ quota , upgrades  }) {
    if (quota == null) {
        if (upgrades == null) {
            return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {});
        } else {
            // These are very old, and we just do a little bit to display
            // something valid.
            quota = {
                cpu: upgrades.cores,
                ram: upgrades.memory / 1000
            };
        }
    }
    const info = (0,_cocalc_util_licenses_describe_quota__WEBPACK_IMPORTED_MODULE_1__.describe_quota)(quota, true);
    return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
        children: info
    });
}
function DateRange({ activates , expires , info  }) {
    const isExpired = expires && expires < new Date().valueOf();
    const sub = info?.purchased?.subscription;
    if (sub && sub != "no") {
        return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("span", {
            children: [
                (0,_cocalc_util_misc__WEBPACK_IMPORTED_MODULE_2__.capitalize)(sub),
                " subscription",
                isExpired && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
                    children: [
                        /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("b", {
                            children: " Expired "
                        }),
                        " ",
                        /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(components_misc_timestamp__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z, {
                            epoch: expires,
                            absolute: true,
                            dateOnly: true
                        })
                    ]
                })
            ]
        });
    }
    const dates = /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
        children: [
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(components_misc_timestamp__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z, {
                epoch: activates,
                absolute: true,
                dateOnly: true
            }),
            " –",
            " ",
            /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(components_misc_timestamp__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z, {
                epoch: expires,
                absolute: true,
                dateOnly: true
            })
        ]
    });
    return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
        children: isExpired ? /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
            children: [
                /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("b", {
                    children: "Expired "
                }),
                "(was valid ",
                dates,
                ")"
            ]
        }) : /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
            children: [
                "Valid: ",
                dates
            ]
        })
    });
}


/***/ }),

/***/ 688642:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Z": () => (/* binding */ Anonymous)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(920997);
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var components_misc_A__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(940981);


function Anonymous() {
    return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
        style: {
            margin: "30px auto",
            fontSize: "14pt"
        },
        children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(components_misc_A__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Z, {
            href: "/config",
            children: "You need to sign up for a non-anonymous account..."
        })
    });
};


/***/ }),

/***/ 393884:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _cocalc_frontend_components_copy_to_clipboard__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(185126);
/* harmony import */ var _cocalc_frontend_components_copy_to_clipboard__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_cocalc_frontend_components_copy_to_clipboard__WEBPACK_IMPORTED_MODULE_0__);

/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ((_cocalc_frontend_components_copy_to_clipboard__WEBPACK_IMPORTED_MODULE_0___default()));


/***/ }),

/***/ 749414:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Z": () => (/* binding */ Timestamp)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(920997);
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(545725);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(antd__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var timeago_react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(754788);
/* harmony import */ var timeago_react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(timeago_react__WEBPACK_IMPORTED_MODULE_2__);
/*
 *  This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */ 


function Timestamp(props) {
    const { epoch , style , absolute , dateOnly  } = props;
    let datetime = props.datetime;
    if (epoch && datetime == null) {
        datetime = new Date(epoch);
    }
    if (!datetime) {
        return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
            style: style,
            children: "-"
        });
    }
    if (typeof datetime == "string") {
        datetime = new Date(datetime);
        if (typeof datetime == "string") throw Error("bug");
    }
    const absoluteTimeDateOnly = datetime.toLocaleDateString(undefined, {
        year: "numeric",
        month: "short",
        day: "numeric"
    });
    const absoluteTimeFull = datetime.toLocaleString(undefined, {
        year: "numeric",
        month: "short",
        day: "numeric",
        hour: "numeric",
        minute: "numeric"
    });
    const timeShown = dateOnly ? absoluteTimeDateOnly : absoluteTimeFull;
    if (absolute) {
        return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(antd__WEBPACK_IMPORTED_MODULE_1__.Tooltip, {
            trigger: [
                "hover",
                "click"
            ],
            title: absoluteTimeFull,
            children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
                style: style,
                children: timeShown
            })
        });
    }
    return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(antd__WEBPACK_IMPORTED_MODULE_1__.Tooltip, {
        trigger: [
            "hover",
            "click"
        ],
        title: timeShown,
        children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((timeago_react__WEBPACK_IMPORTED_MODULE_2___default()), {
            style: style,
            datetime: datetime
        })
    });
};


/***/ }),

/***/ 774872:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "d": () => (/* binding */ MAX_WIDTH),
/* harmony export */   "r": () => (/* binding */ SHARE_MAX_WIDTH)
/* harmony export */ });
/*
Constants and other configuration that impact the overall
look of all of the pages.
*/ const MAX_WIDTH = "900px";
const SHARE_MAX_WIDTH = "1100px";


/***/ }),

/***/ 136811:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "P_": () => (/* binding */ OVERVIEW_LARGE_ICON),
/* harmony export */   "dP": () => (/* binding */ OVERVIEW_STYLE),
/* harmony export */   "m2": () => (/* binding */ OverviewRow),
/* harmony export */   "uF": () => (/* binding */ OVERVIEW_LARGE_ICON_MARGIN),
/* harmony export */   "xs": () => (/* binding */ Product)
/* harmony export */ });
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(920997);
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _cocalc_frontend_components_icon__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(807772);
/* harmony import */ var _cocalc_frontend_components_icon__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_cocalc_frontend_components_icon__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _cocalc_util_theme__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(990821);
/* harmony import */ var _cocalc_util_theme__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_cocalc_util_theme__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(545725);
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(antd__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var components_misc_A__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(940981);
/*
 *  This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */ 




const gridProps = {
    sm: 24,
    md: 12
};
const OVERVIEW_STYLE = {
    textAlign: "center",
    width: "75%",
    margin: "0px auto 0px auto"
};
const OVERVIEW_LARGE_ICON = {
    fontSize: "100px",
    color: _cocalc_util_theme__WEBPACK_IMPORTED_MODULE_2__.COLORS.COCALC_BLUE,
    borderRadius: "50%",
    backgroundColor: _cocalc_util_theme__WEBPACK_IMPORTED_MODULE_2__.COLORS.COCALC_ORANGE,
    border: `15px solid ${_cocalc_util_theme__WEBPACK_IMPORTED_MODULE_2__.COLORS.COCALC_BLUE}`,
    padding: "20px 20px 15px 15px",
    display: "inline-block",
    margin: "30px 0px 40px 0px",
    boxShadow: "0px 2px 10px 2px"
};
// variation of the above, since some icons need more margin
const OVERVIEW_LARGE_ICON_MARGIN = {
    ...OVERVIEW_LARGE_ICON,
    padding: "23px 20px 20px 20px",
    fontSize: "80px"
};
function Product({ icon , title , href , children  }) {
    return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(antd__WEBPACK_IMPORTED_MODULE_3__.Col, {
        ...gridProps,
        children: [
            /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(components_misc_A__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
                href: href,
                children: [
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_cocalc_frontend_components_icon__WEBPACK_IMPORTED_MODULE_1__.Icon, {
                        style: {
                            fontSize: "50px",
                            fontWeight: "bold",
                            display: "block"
                        },
                        name: icon
                    }),
                    /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("p", {
                        style: {
                            fontSize: "25px",
                            marginBottom: "15px"
                        },
                        children: title
                    })
                ]
            }),
            children
        ]
    });
}
function OverviewRow({ children  }) {
    return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(antd__WEBPACK_IMPORTED_MODULE_3__.Row, {
        gutter: [
            25,
            50
        ],
        style: {
            marginTop: "30px",
            marginBottom: "60px"
        },
        children: children
    });
}


/***/ }),

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


/*
 *  This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.displaySiteLicense = exports.untangleUptime = exports.requiresMemberhosting = exports.LicenseIdleTimeoutsKeysOrdered = exports.LicenseIdleTimeouts = void 0;
var lodash_1 = __webpack_require__(988593);
// Site Licenses related constants
// the license timeouts combined with the default quota (either hardcoded or the one from the site_settings)
// hence 30 minutes + 30 minutes default result in 30 minutes, and the same for "medium" and "day"
// @see DEFAULT_QUOTAS.mintime in src/packages/util/upgrade-spec.js
// medium and day imply member hosting
exports.LicenseIdleTimeouts = {
    short: {
        mins: 30,
        label: "30 minutes",
        priceFactor: 1,
    },
    medium: { mins: 2 * 60, label: "2 hours", priceFactor: 2 },
    day: {
        mins: 24 * 60,
        label: "1 day",
        priceFactor: 4,
        requireMemberhosting: true,
    },
};
exports.LicenseIdleTimeoutsKeysOrdered = (0, lodash_1.sortBy)(Object.keys(exports.LicenseIdleTimeouts), function (v) { return exports.LicenseIdleTimeouts[v].mins; });
function requiresMemberhosting(key) {
    var _a, _b;
    if (key == null)
        return false;
    if (key == "always_running")
        return true;
    return (_b = (_a = exports.LicenseIdleTimeouts[key]) === null || _a === void 0 ? void 0 : _a.requireMemberhosting) !== null && _b !== void 0 ? _b : false;
}
exports.requiresMemberhosting = requiresMemberhosting;
function untangleUptime(uptime) {
    if (uptime == null) {
        throw new Error("uptime must be defined");
    }
    if (uptime == "always_running") {
        return { always_running: true, idle_timeout: "day" };
    }
    return { always_running: false, idle_timeout: uptime };
}
exports.untangleUptime = untangleUptime;
function displaySiteLicense(uptime) {
    if (uptime == "always_running") {
        return "Always Running";
    }
    else {
        return exports.LicenseIdleTimeouts[uptime].label;
    }
}
exports.displaySiteLicense = displaySiteLicense;
//# sourceMappingURL=site-license.js.map

/***/ }),

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


/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.describe_quota = exports.describeQuotaFromInfo = void 0;
var site_license_1 = __webpack_require__(856343);
var misc_1 = __webpack_require__(477389);
var utils_1 = __webpack_require__(389896);
function describeQuotaFromInfo(info, withName) {
    if (withName === void 0) { withName = true; }
    var type = info.type;
    switch (type) {
        case "quota":
            var _a = (0, site_license_1.untangleUptime)(info.custom_uptime), idle_timeout = _a.idle_timeout, always_running = _a.always_running;
            return describe_quota({
                ram: info.custom_ram,
                cpu: info.custom_cpu,
                disk: info.custom_disk,
                always_running: always_running,
                idle_timeout: idle_timeout,
                member: info.custom_member,
                user: info.user,
                boost: info.boost,
            });
        case "vm":
            if (info.dedicated_vm == null) {
                throw new Error("dedicated_vm must be defined");
            }
            // we make a copy, because we eventually delete a field
            var dedicated_vm = __assign({}, info.dedicated_vm);
            if (!withName)
                dedicated_vm === null || dedicated_vm === void 0 ? true : delete dedicated_vm.name;
            return describe_quota({ dedicated_vm: dedicated_vm });
        case "disk":
            if (info.dedicated_disk == null ||
                typeof info.dedicated_disk === "boolean") {
                throw new Error("dedicated_disk must be defined and not a boolean");
            }
            // we make a copy, because we eventually delete a field
            var dedicated_disk = __assign({}, info.dedicated_disk);
            if (!withName)
                dedicated_disk === null || dedicated_disk === void 0 ? true : delete dedicated_disk.name;
            return describe_quota({ dedicated_disk: dedicated_disk });
        default:
            throw new Error("unkonwn type ".concat(type));
    }
}
exports.describeQuotaFromInfo = describeQuotaFromInfo;
function describe_quota(quota, short) {
    //console.log(`describe_quota (short=${short})`, quota);
    var _a;
    // regarding quota.uptime: it is assumed that all calls already query using the schema defined
    // in SiteLicenseQuota, but if not, we untangle the uptime field.
    if (quota.uptime != null) {
        var _b = (0, site_license_1.untangleUptime)(quota.uptime), always_running = _b.always_running, idle_timeout = _b.idle_timeout;
        quota.always_running = always_running;
        quota.idle_timeout = idle_timeout;
        delete quota.uptime;
    }
    var v = [];
    var intro = "";
    var hideNetwork = false;
    var isBoost = quota.boost === true;
    var booster = isBoost ? " booster" : "";
    if (quota.user) {
        if (short) {
            intro = "".concat((0, misc_1.capitalize)(quota.user)).concat(booster, ",");
        }
        else {
            intro = "".concat((0, misc_1.capitalize)(quota.user), " license").concat(booster, " providing");
        }
    }
    else {
        // dedicated resources do not have a specific user
        intro = short ? "License" : "License providing";
    }
    if (quota.ram) {
        v.push("".concat(quota.ram, "GB RAM"));
    }
    if (quota.cpu) {
        v.push("".concat(quota.cpu, " shared ").concat((0, misc_1.plural)(quota.cpu, "CPU")));
    }
    if (quota.disk) {
        v.push("".concat(quota.disk, "GB disk"));
    }
    if (quota.dedicated_ram) {
        v.push("".concat(quota.dedicated_ram, "GB dedicated RAM"));
    }
    if (quota.dedicated_cpu) {
        v.push("".concat(quota.dedicated_cpu, " dedicated ").concat((0, misc_1.plural)(quota.dedicated_cpu, "CPU")));
    }
    if (typeof quota.dedicated_vm !== "boolean" &&
        typeof ((_a = quota.dedicated_vm) === null || _a === void 0 ? void 0 : _a.machine) === "string") {
        hideNetwork = true;
        v.push("hosting on a Dedicated VM providing ".concat((0, utils_1.dedicatedVmDisplay)(quota.dedicated_vm)));
    }
    else {
        if (quota.member) {
            v.push("member" + (short ? "" : " hosting"));
        }
    }
    if (quota.dedicated_disk != null &&
        typeof quota.dedicated_disk !== "boolean") {
        hideNetwork = true;
        v.push("a Dedicated Disk (".concat((0, utils_1.dedicatedDiskDisplay)(quota.dedicated_disk), ")"));
    }
    if (quota.always_running) {
        v.push("always running");
    }
    else {
        if (quota.idle_timeout != null) {
            var it_1 = site_license_1.LicenseIdleTimeouts[quota.idle_timeout];
            if (it_1 != null) {
                v.push("".concat(it_1.label, " timeout"));
            }
        }
    }
    if (!hideNetwork && !isBoost) {
        v.push("network"); // always provided, because we trust customers.
    }
    return "".concat(intro, " ").concat(v.join(", "));
}
exports.describe_quota = describe_quota;
//# sourceMappingURL=describe-quota.js.map

/***/ }),

/***/ 451349:
/***/ ((__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.isDedicatedDisk = exports.DISK_NAMES = exports.DedicatedDiskSpeedNames = void 0;
exports.DedicatedDiskSpeedNames = ["standard", "balanced", "ssd"];
exports.DISK_NAMES = {
    standard: "slow",
    balanced: "medium",
    ssd: "fast",
};
function isDedicatedDisk(d) {
    return (d != null &&
        typeof d.size_gb === "number" &&
        ["ssd", "standard", "balanced"].includes(d.type));
}
exports.isDedicatedDisk = isDedicatedDisk;
//# sourceMappingURL=dedicated.js.map

/***/ }),

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


/*
 *  This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.dedicatedVmDisplay = exports.dedicatedDiskDisplay = void 0;
var misc_1 = __webpack_require__(477389);
var dedicated_1 = __webpack_require__(451349);
var dedicated_2 = __webpack_require__(473009);
function dedicatedDiskDisplay(disk) {
    var _a;
    if (disk == null)
        throw new Error("dedicated_disk must be defined");
    if (typeof disk === "boolean")
        return "";
    var tokens = [
        "".concat(disk.size_gb, "G size"),
        "".concat((_a = dedicated_1.DISK_NAMES[disk.speed]) !== null && _a !== void 0 ? _a : disk.speed, " speed"),
    ];
    if (disk.name != null) {
        tokens.push("named \"".concat(disk.name, "\""));
    }
    return (0, misc_1.to_human_list)(tokens);
}
exports.dedicatedDiskDisplay = dedicatedDiskDisplay;
function dedicatedVmDisplay(v) {
    if (v == null)
        throw Error("dedicated_vm must be defined");
    var vm = dedicated_2.PRICES.vms[v.machine];
    if (vm == null) {
        return "machine '".concat(v.machine, "'");
    }
    return vm.title;
}
exports.dedicatedVmDisplay = dedicatedVmDisplay;
//# sourceMappingURL=utils.js.map

/***/ })

};
;