"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.Document = void 0;

var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));

var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));

var _react = _interopRequireDefault(require("react"));

var _document = _interopRequireWildcard(require("next/document"));

var _styledComponents = require("styled-components");

var Document = /*#__PURE__*/function (_Maikati) {
  (0, _inheritsLoose2["default"])(Document, _Maikati);

  function Document() {
    return _Maikati.apply(this, arguments) || this;
  }

  Document.getInitialProps = /*#__PURE__*/function () {
    var _getInitialProps = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(ctx) {
      var sheet, originalRenderPage, initialProps;
      return _regenerator["default"].wrap(function _callee$(_context) {
        while (1) {
          switch (_context.prev = _context.next) {
            case 0:
              sheet = new _styledComponents.ServerStyleSheet();
              originalRenderPage = ctx.renderPage;
              _context.prev = 2;

              ctx.renderPage = function () {
                return originalRenderPage({
                  enhanceApp: function enhanceApp(App) {
                    return function (props) {
                      return sheet.collectStyles( /*#__PURE__*/_react["default"].createElement(App, props));
                    };
                  }
                });
              };

              _context.next = 6;
              return _document["default"].getInitialProps(ctx);

            case 6:
              initialProps = _context.sent;
              return _context.abrupt("return", (0, _extends2["default"])({}, initialProps, {
                styles: /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, initialProps.styles, sheet.getStyleElement())
              }));

            case 8:
              _context.prev = 8;
              sheet.seal();
              return _context.finish(8);

            case 11:
            case "end":
              return _context.stop();
          }
        }
      }, _callee, null, [[2,, 8, 11]]);
    }));

    function getInitialProps(_x) {
      return _getInitialProps.apply(this, arguments);
    }

    return getInitialProps;
  }();

  var _proto = Document.prototype;

  _proto.render = function render() {
    return /*#__PURE__*/_react["default"].createElement(_document.Html, null, /*#__PURE__*/_react["default"].createElement(_document.Head, null), /*#__PURE__*/_react["default"].createElement("body", null, /*#__PURE__*/_react["default"].createElement(_document.Main, null), /*#__PURE__*/_react["default"].createElement(_document.NextScript, null)));
  };

  return Document;
}(_document["default"]);

exports.Document = Document;
//# sourceMappingURL=document.component.js.map