"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 __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 __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 __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
var site_defaults_1 = __webpack_require__(889188);
var get_strategies_1 = __importDefault(__webpack_require__(728351));
var server_settings_1 = __webpack_require__(526177);
var site_url_1 = __importDefault(__webpack_require__(661348));
var fallback = function (a, b) {
    return typeof a == "string" && a.length > 0 ? a : "".concat(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.
*/
var cachedSettings = undefined;
var cachedCustomize = undefined;
function getCustomize() {
    return __awaiter(this, void 0, void 0, function () {
        var _a, settings, strategies;
        var _b;
        return __generator(this, function (_c) {
            switch (_c.label) {
                case 0: return [4 /*yield*/, Promise.all([(0, server_settings_1.getServerSettings)(), (0, get_strategies_1.default)()])];
                case 1:
                    _a = __read.apply(void 0, [_c.sent(), 2]), settings = _a[0], strategies = _a[1];
                    if (settings === cachedSettings && cachedCustomize != null) {
                        return [2 /*return*/, cachedCustomize];
                    }
                    cachedSettings = settings;
                    _b = {
                        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,
                        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
                    };
                    return [4 /*yield*/, (0, site_url_1.default)(settings.dns)];
                case 2:
                    cachedCustomize = (
                    // 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.
                    _b.siteURL = _c.sent(),
                        _b.zendesk = settings.zendesk_token &&
                            settings.zendesk_username &&
                            settings.zendesk_uri,
                        // obviously only the public key here!
                        _b.stripePublishableKey = settings.stripe_publishable_key,
                        // obviously only the public key here too!
                        _b.reCaptchaKey = settings.re_captcha_v3_publishable_key,
                        // a sandbox project
                        _b.sandboxProjectId = settings.sandbox_project_id,
                        // GitHub proxy project
                        _b.githubProjectId = settings.github_project_id,
                        // public info about SSO strategies
                        _b.strategies = strategies,
                        _b);
                    return [2 /*return*/, cachedCustomize];
            }
        });
    });
}
exports["default"] = getCustomize;
//# sourceMappingURL=customize.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,1808,9738,8312,8416,4181,5016,6177,8351,1348], () => (__webpack_exec__(457077)));
module.exports = __webpack_exports__;

})();