"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.decidePublicPath = decidePublicPath;
exports.modifiedServerOptions = modifiedServerOptions;

var _getServerURL = require("../../../server/getServerURL");

var _httpsOptions = require("../../../server/httpsOptions");

function decidePublicPath(serverExtras) {
  return serverExtras.isHttps ? serverExtras.httpsUrl : serverExtras.httpUrl;
}

function modifiedServerOptions(options) {
  const {
    server
  } = options;
  const {
    port
  } = server;
  const httpsOptions = (0, _httpsOptions.httpsOptionsWithUserFriendlyError)(options);
  const machineDomain = (0, _getServerURL.getServerDomain)(server);
  const httpPort = port + 1;
  return {
    httpsOptions,
    machineDomain,
    httpsPort: port,
    httpPort,
    httpsUrl: (0, _getServerURL.getServerUrl)({
      domain: machineDomain,
      port,
      protocol: 'https'
    }),
    httpUrl: (0, _getServerURL.getServerUrl)({
      domain: machineDomain,
      port: httpPort,
      protocol: 'http'
    }),
    isHttps: !!httpsOptions
  };
}