"use strict";
(() => {
var exports = {};
exports.id = 4349;
exports.ids = [4349];
exports.modules = {

/***/ 439491:
/***/ ((module) => {

module.exports = require("assert");

/***/ }),

/***/ 714300:
/***/ ((module) => {

module.exports = require("buffer");

/***/ }),

/***/ 706113:
/***/ ((module) => {

module.exports = require("crypto");

/***/ }),

/***/ 809523:
/***/ ((module) => {

module.exports = require("dns");

/***/ }),

/***/ 582361:
/***/ ((module) => {

module.exports = require("events");

/***/ }),

/***/ 657147:
/***/ ((module) => {

module.exports = require("fs");

/***/ }),

/***/ 241808:
/***/ ((module) => {

module.exports = require("net");

/***/ }),

/***/ 822037:
/***/ ((module) => {

module.exports = require("os");

/***/ }),

/***/ 371017:
/***/ ((module) => {

module.exports = require("path");

/***/ }),

/***/ 677282:
/***/ ((module) => {

module.exports = require("process");

/***/ }),

/***/ 12781:
/***/ ((module) => {

module.exports = require("stream");

/***/ }),

/***/ 371576:
/***/ ((module) => {

module.exports = require("string_decoder");

/***/ }),

/***/ 924404:
/***/ ((module) => {

module.exports = require("tls");

/***/ }),

/***/ 76224:
/***/ ((module) => {

module.exports = require("tty");

/***/ }),

/***/ 257310:
/***/ ((module) => {

module.exports = require("url");

/***/ }),

/***/ 473837:
/***/ ((module) => {

module.exports = require("util");

/***/ }),

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

/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "Z": () => (/* binding */ getParams)
/* harmony export */ });
function getParams(req) {
    if (req?.method == "POST") {
        return new Proxy({}, {
            get (_, key) {
                return req.body?.[key];
            }
        });
    /*
    // Disabled, since this could lead to a sneaky click on a link attack.
    // Should only be enabled for dev purposes.
    } else if (req?.method == "GET") {
    return new Proxy(
      {},
      {
        get(_, key) {
          if (typeof key != "string") {
            return undefined;
          }
          return req.query?.[key];
        },
      }
    );
*/ } else {
        // only support params for POST requests.
        return {};
    }
}


/***/ }),

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

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (/* binding */ handle)
/* harmony export */ });
/* harmony import */ var _cocalc_server_settings_customize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(223832);
/* harmony import */ var _cocalc_server_settings_customize__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_cocalc_server_settings_customize__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _cocalc_util_misc__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(854006);
/* harmony import */ var _cocalc_util_misc__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_cocalc_util_misc__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var lib_api_get_params__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(26438);
/*
Return the entire customize object for the site, or
a subset of fields (to cut down on bandwidth).

This calls something that is LRU cached on the server for a few seconds.
*/ 


async function handle(req, res) {
    const { fields  } = (0,lib_api_get_params__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z)(req);
    try {
        const customize = await _cocalc_server_settings_customize__WEBPACK_IMPORTED_MODULE_0___default()();
        let result = fields ? (0,_cocalc_util_misc__WEBPACK_IMPORTED_MODULE_1__.copy_with)(customize, fields) : customize;
        res.json(result);
    } catch (err) {
        res.json({
            error: `${err.message}`
        });
    }
}


/***/ }),

/***/ 223832:
/***/ (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 __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const site_defaults_1 = __webpack_require__(889188);
const get_strategies_1 = __importDefault(__webpack_require__(728351));
const server_settings_1 = __webpack_require__(526177);
const site_url_1 = __importDefault(__webpack_require__(661348));
const fallback = (a, b) => typeof a == "string" && a.length > 0 ? a : `${b}`;
/*
Create a Javascript object that describes properties of the server.
This is used on the next.js server landing pages and the share server
to customize their look and behavior.

This function is cached via the parameters in ./server-settings, i.e.,
for a few seconds.
*/
let cachedSettings = undefined;
let cachedCustomize = undefined;
async function getCustomize() {
    const [settings, strategies] = await Promise.all([(0, server_settings_1.getServerSettings)(), (0, get_strategies_1.default)()]);
    if (settings === cachedSettings && cachedCustomize != null) {
        return cachedCustomize;
    }
    cachedSettings = settings;
    cachedCustomize = {
        siteName: fallback(settings.site_name, "On Premises CoCalc"),
        siteDescription: fallback(settings.site_description, "Collaborative Calculation using Python, Sage, R, Julia, and more."),
        organizationName: settings.organization_name,
        organizationEmail: settings.organization_email,
        organizationURL: settings.organization_url,
        termsOfServiceURL: settings.terms_of_service_url,
        helpEmail: settings.help_email,
        contactEmail: fallback(settings.organization_email, settings.help_email),
        isCommercial: settings.commercial,
        kucalc: settings.kucalc,
        sshGateway: settings.ssh_gateway,
        sshGatewayDNS: settings.ssh_gateway_dns,
        anonymousSignup: settings.anonymous_signup,
        emailSignup: settings.email_signup,
        accountCreationInstructions: settings.account_creation_email_instructions,
        logoSquareURL: settings.logo_square,
        logoRectangularURL: settings.logo_rectangular,
        splashImage: settings.splash_image,
        shareServer: !!settings.share_server,
        // additionally restrict showing landing pages only in cocalc.com-mode
        landingPages: !!settings.landing_pages && settings.kucalc === site_defaults_1.KUCALC_COCALC_COM,
        googleAnalytics: settings.google_analytics,
        indexInfo: settings.index_info_html,
        imprint: settings.imprint,
        policies: settings.policies,
        // Is important for invite emails, password reset, etc. (e.g., so we can construct a url to our site).
        // This *can* start with http:// to explicitly use http instead of https, and can end
        // in something like :3594 to indicate a port.
        dns: settings.dns,
        // siteURL is derived from settings.dns and the basePath -- it combines the dns, https://
        // and the basePath.  It never ends in a slash.  This is used in practice for
        // things like invite emails, password reset, etc.
        siteURL: await (0, site_url_1.default)(settings.dns),
        zendesk: settings.zendesk_token &&
            settings.zendesk_username &&
            settings.zendesk_uri,
        // obviously only the public key here!
        stripePublishableKey: settings.stripe_publishable_key,
        // obviously only the public key here too!
        reCaptchaKey: settings.re_captcha_v3_publishable_key,
        // a sandbox project
        sandboxProjectId: settings.sandbox_project_id,
        // GitHub proxy project
        githubProjectId: settings.github_project_id,
        // public info about SSO strategies
        strategies,
    };
    return cachedCustomize;
}
exports["default"] = getCustomize;
//# sourceMappingURL=customize.js.map

/***/ }),

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


var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const server_settings_1 = __webpack_require__(526177);
const base_path_1 = __importDefault(__webpack_require__(8312));
// Returns url of this site in terms of the base path (determined
// by an env variable when server starts) and the "Domain name"
// setting of site settings.  This URL does NOT end in a /
async function siteURL(dns) {
    if (!dns) {
        dns = (await (0, server_settings_1.getServerSettings)()).dns?.toLowerCase();
    }
    if (!dns) {
        dns = "localhost";
    }
    if (!dns.startsWith("http")) {
        dns = "https://" + dns;
    }
    return `${dns}${base_path_1.default == "/" ? "" : base_path_1.default}`;
}
exports["default"] = siteURL;
//# sourceMappingURL=site-url.js.map

/***/ })

};
;

// load runtime
var __webpack_require__ = require("../../../webpack-api-runtime.js");
__webpack_require__.C(exports);
var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
var __webpack_exports__ = __webpack_require__.X(0, [8180,2921,6652,6942,5517,1808,4006,8312,4181,4557,7896,6177,8351], () => (__webpack_exec__(457077)));
module.exports = __webpack_exports__;

})();