"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getServerSideProps = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
/*
 *  This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
const icon_1 = require("@cocalc/frontend/components/icon");
const site_license_1 = require("@cocalc/util/consts/site-license");
const compute_cost_1 = require("@cocalc/util/licenses/purchase/compute-cost");
const consts_1 = require("@cocalc/util/licenses/purchase/consts");
const utils_1 = require("@cocalc/util/licenses/purchase/utils");
const theme_1 = require("@cocalc/util/theme");
const antd_1 = require("antd");
const footer_1 = __importDefault(require("components/landing/footer"));
const head_1 = __importDefault(require("components/landing/head"));
const header_1 = __importDefault(require("components/landing/header"));
const pricing_item_1 = __importStar(require("components/landing/pricing-item"));
const A_1 = __importDefault(require("components/misc/A"));
const link_1 = require("components/store/link");
const quota_query_params_1 = require("components/store/quota-query-params");
const config_1 = require("lib/config");
const customize_1 = require("lib/customize");
const with_customize_1 = __importDefault(require("lib/with-customize"));
const pricing_1 = require("components/share/pricing");
const training = (() => {
    const students = 10;
    const days = 5;
    const conf = {
        run_limit: students + 1,
        user: "business",
        days,
        ram: 5,
        disk: 5,
        cpu: 1,
        uptime: "medium",
        start: new Date(),
        end: new Date(new Date().getTime() + days * 24 * 60 * 60 * 1000),
    };
    const profPrice = (0, compute_cost_1.compute_cost)({
        type: "quota",
        user: conf.user,
        upgrade: "custom",
        quantity: conf.run_limit,
        subscription: "no",
        start: conf.start,
        end: conf.end,
        custom_ram: conf.ram,
        custom_cpu: conf.cpu,
        custom_disk: conf.disk,
        custom_member: true,
        custom_dedicated_ram: 0,
        custom_dedicated_cpu: 0,
        custom_uptime: conf.uptime,
    });
    return {
        title: `${conf.days} Day Professional Training`,
        icon: "battery-quarter",
        teachers: 1,
        students,
        duration: `${conf.days} days`,
        disk: conf.disk,
        uptime: site_license_1.LicenseIdleTimeouts[conf.uptime].labelShort,
        shared_ram: conf.ram,
        dedicated_ram: 0,
        shared_cores: conf.cpu,
        dedicated_cores: 0,
        academic: false,
        online: profPrice.discounted_cost,
        conf,
    };
})();
const courseSmall = (() => {
    const students = 10;
    const days = 30;
    const conf = {
        run_limit: students + 1,
        days,
        ram: 2,
        disk: 3,
        cpu: 1,
        uptime: "short",
        user: "academic",
        start: new Date(),
        end: new Date(new Date().getTime() + days * 24 * 60 * 60 * 1000),
    };
    const price = (0, compute_cost_1.compute_cost)({
        type: "quota",
        user: conf.user,
        upgrade: "custom",
        quantity: conf.run_limit,
        subscription: "no",
        start: conf.start,
        end: conf.end,
        custom_ram: conf.ram,
        custom_cpu: conf.cpu,
        custom_disk: conf.disk,
        custom_member: true,
        custom_dedicated_ram: 0,
        custom_dedicated_cpu: 0,
        custom_uptime: conf.uptime,
    });
    return {
        title: `${students} students for ${conf.days} days`,
        icon: "battery-half",
        teachers: 1,
        students,
        duration: `${conf.days} days`,
        disk: conf.disk,
        uptime: site_license_1.LicenseIdleTimeouts[conf.uptime].labelShort,
        shared_ram: conf.ram,
        shared_cores: conf.cpu,
        academic: true,
        retail: price.cost,
        online: price.discounted_cost,
        conf,
    };
})();
const courseLarge = (() => {
    const students = 150;
    const months = 4;
    const days = months * 30;
    const conf = {
        run_limit: students + 1,
        days,
        user: "academic",
        ram: 2,
        disk: 3,
        cpu: 1,
        uptime: "short",
        start: new Date(),
        end: new Date(new Date().getTime() + days * 24 * 60 * 60 * 1000),
    };
    const price = (0, compute_cost_1.compute_cost)({
        type: "quota",
        user: conf.user,
        upgrade: "custom",
        quantity: conf.run_limit,
        subscription: "no",
        start: conf.start,
        end: conf.end,
        custom_ram: conf.ram,
        custom_cpu: conf.cpu,
        custom_disk: conf.disk,
        custom_member: true,
        custom_dedicated_ram: 0,
        custom_dedicated_cpu: 0,
        custom_uptime: conf.uptime,
    });
    return {
        title: `${students} Students for ${months} Months`,
        icon: "battery-full",
        teachers: 1,
        students,
        duration: `${days} days`,
        disk: conf.disk,
        uptime: site_license_1.LicenseIdleTimeouts[conf.uptime].labelShort,
        shared_ram: conf.ram,
        shared_cores: conf.cpu,
        academic: true,
        retail: price.cost,
        online: price.discounted_cost,
        conf,
    };
})();
const data = [training, courseSmall, courseLarge];
function Courses({ customize }) {
    return ((0, jsx_runtime_1.jsxs)(customize_1.Customize, { value: customize, children: [(0, jsx_runtime_1.jsx)(head_1.default, { title: "Course licenses" }), (0, jsx_runtime_1.jsxs)(antd_1.Layout, { children: [(0, jsx_runtime_1.jsx)(header_1.default, { page: "pricing", subPage: "courses" }), (0, jsx_runtime_1.jsxs)(antd_1.Layout.Content, { style: {
                            backgroundColor: "white",
                        }, children: [(0, jsx_runtime_1.jsx)(Body, {}), (0, jsx_runtime_1.jsx)(footer_1.default, {})] })] })] }));
}
exports.default = Courses;
function Body() {
    return ((0, jsx_runtime_1.jsxs)("div", { style: {
            maxWidth: config_1.MAX_WIDTH,
            margin: "15px auto",
            padding: "15px",
            backgroundColor: "white",
        }, children: [(0, jsx_runtime_1.jsx)("div", { style: { textAlign: "center", color: "#444" }, children: (0, jsx_runtime_1.jsxs)("h1", { style: { fontSize: "28pt" }, children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { name: "graduation-cap", style: { marginRight: "30px" } }), "CoCalc - Course licenses"] }) }), (0, jsx_runtime_1.jsxs)("div", { style: { fontSize: "12pt" }, children: [(0, jsx_runtime_1.jsxs)("p", { children: ["You", " ", (0, jsx_runtime_1.jsx)(A_1.default, { href: "https://doc.cocalc.com/teaching-instructors.html", children: "teach a course" }), " ", "on ", (0, jsx_runtime_1.jsx)("span", { children: "CoCalc" }), " by creating one project for each student, sending your students assignments and handouts, then guiding their progress using collaboration and chat. You can then collect, grade, comment on, and return their work."] }), (0, jsx_runtime_1.jsx)("p", { children: "You will need to purchase an appropriate license for your course, or have the students pay the one-time $14 fee, since CoCalc is not funded by advertisers or other intrusive methods." }), (0, jsx_runtime_1.jsx)("h2", { children: "How to get started?" }), (0, jsx_runtime_1.jsxs)("p", { children: ["You can", " ", (0, jsx_runtime_1.jsx)(A_1.default, { href: "/store/site-license", external: true, children: "purchase a license for your course" }), " ", "in the", " ", (0, jsx_runtime_1.jsx)(A_1.default, { href: "/store", external: true, children: "store" }), "."] }), (0, jsx_runtime_1.jsxs)("p", { children: ["Minimal upgrades might be okay for beginner courses, but we find that many data and computational science courses run better with additional RAM and CPU. ", (0, jsx_runtime_1.jsx)(A_1.default, { href: "mailto:help@cocalc.com", children: "Contact us" }), " if you have questions or need a trial license to test out different possibilities."] }), (0, jsx_runtime_1.jsxs)("p", { children: ["Once you obtain a license key,", " ", (0, jsx_runtime_1.jsx)(A_1.default, { href: "https://doc.cocalc.com/teaching-upgrade-course.html", children: "apply it to all your student projects" }), "."] }), (0, jsx_runtime_1.jsx)("p", { children: "You can acquire several licenses, e.g., to partition a semester into smaller parts with different requirements, or to keep upgrades separate between certain groups of courses or instructors." }), (0, jsx_runtime_1.jsx)("h2", { children: "Payment options" }), (0, jsx_runtime_1.jsxs)("ul", { style: { paddingLeft: "20px" }, children: [(0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("b", { children: (0, jsx_runtime_1.jsx)(A_1.default, { href: "https://doc.cocalc.com/teaching-upgrade-course.html#teacher-or-institution-pays-for-upgrades", children: "You or your institution pays" }) }), " ", "for one or more license upgrades. You distribute the license upgrades to all projects of the course via the course configuration tab of the course management interface."] }), (0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("b", { children: (0, jsx_runtime_1.jsx)(A_1.default, { href: "https://doc.cocalc.com/teaching-upgrade-course.html#students-pay-for-upgrades", children: "Students pay a one-time fee." }) }), " ", "In the configuration frame of the course management file, you opt to require all students to pay a one-time $14 fee to upgrade their own projects."] })] }), (0, jsx_runtime_1.jsx)("h2", { children: "Examples" }), (0, jsx_runtime_1.jsxs)("p", { children: ["Here are three typical configurations, which you can", " ", (0, jsx_runtime_1.jsx)(A_1.default, { href: "/store/site-license", external: true, children: "modify and purchase here" }), ". All parameters can be adjusted to fit your needs. Listed upgrades are for each project. Exact prices may vary. Only self-service online purchases are available below $100."] }), (0, jsx_runtime_1.jsx)(antd_1.List, { grid: { gutter: 16, column: 3, xs: 1, sm: 1 }, dataSource: data, renderItem: (item) => {
                            const conf = {
                                ...item.conf,
                                period: "range",
                                range: (0, quota_query_params_1.encodeRange)([item.conf.start, item.conf.end]),
                            };
                            return ((0, jsx_runtime_1.jsxs)(pricing_item_1.default, { title: item.title, icon: item.icon, children: [(0, jsx_runtime_1.jsx)(pricing_item_1.Line, { amount: item.teachers, desc: "Teacher" }), (0, jsx_runtime_1.jsx)(pricing_item_1.Line, { amount: item.students, desc: "Students" }), (0, jsx_runtime_1.jsx)(pricing_item_1.Line, { amount: item.duration, desc: "Duration" }), (0, jsx_runtime_1.jsx)(pricing_item_1.Line, { amount: item.uptime, desc: "Idle timeout" }), (0, jsx_runtime_1.jsx)(pricing_item_1.Line, { amount: item.shared_ram, desc: "Shared RAM" }), (0, jsx_runtime_1.jsx)(pricing_item_1.Line, { amount: item.shared_cores, desc: "Shared CPU" }), (0, jsx_runtime_1.jsx)(pricing_item_1.Line, { amount: item.disk, desc: "Disk space" }), item.academic && ((0, jsx_runtime_1.jsx)(pricing_item_1.Line, { amount: `${consts_1.discount_pct}%`, desc: "Academic discount" })), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { style: {
                                                    fontWeight: "bold",
                                                    fontSize: "18pt",
                                                    color: theme_1.COLORS.GRAY_DD,
                                                }, children: (0, utils_1.money)(item.online, true) }), " "] }), item.retail ? ((0, jsx_runtime_1.jsxs)("div", { style: { color: theme_1.COLORS.GRAY }, children: ["(", (0, jsx_runtime_1.jsx)("span", { style: {
                                                    fontWeight: "bold",
                                                    fontSize: "14pt",
                                                }, children: (0, utils_1.money)(item.retail, true) }), " ", "via purchase order)"] })) : ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("span", { style: { fontSize: "14pt" }, children: "\u00A0" }) })), (0, jsx_runtime_1.jsx)(link_1.LinkToStore, { conf: conf })] }));
                        } }), (0, pricing_1.listedPrices)(), (0, jsx_runtime_1.jsx)("h2", { children: "Contact us" }), (0, jsx_runtime_1.jsxs)("p", { children: ["To learn more about your teaching options, email us at", " ", (0, jsx_runtime_1.jsx)(A_1.default, { href: "mailto:help@cocalc.com", children: "help@cocalc.com" }), " with a description of your specific requirements."] })] })] }));
}
async function getServerSideProps(context) {
    return await (0, with_customize_1.default)({ context });
}
exports.getServerSideProps = getServerSideProps;
//# sourceMappingURL=courses.js.map