text: "use strict";
  
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  
  exports.__esModule = true;
  exports.onRenderBody = void 0;
  
  var _react = _interopRequireDefault(require("react"));
  
  var _utils = require("./utils");
  
  var onRenderBody = function onRenderBody(_ref, pluginOptions) {
    var setHeadComponents = _ref.setHeadComponents;
    var domainList = pluginOptions.domains;
  
    if (!pluginOptions || !domainList) {
      throw new Error('gatsby-plugin-preconnect: Missing `options.domains`');
    }
  
    if (!Array.isArray(domainList)) {
      throw new Error('gatsby-plugin-preconnect: `options.domains` is not an array');
    }
  
    var parsedDomains = (0, _utils.removeDuplicates)((0, _utils.parseOptions)(domainList));
    setHeadComponents(parsedDomains.map(function (_ref2) {
      var domain = _ref2.domain,
          crossOrigin = _ref2.crossOrigin;
      return _react.default.createElement('link', {
        crossOrigin: crossOrigin,
        href: domain,
        key: domain + "-" + crossOrigin,
        rel: 'preconnect'
      });
    }));
  };
  
  exports.onRenderBody = onRenderBody;