{"ast":null,"code":"import React from \"react\";\nvar __jsx = React.createElement;\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nimport Document, { Head, Html, Main, NextScript } from 'next/document';\nimport { ServerStyleSheet } from '~/utils/style';\nexport default class VDLDocument extends Document {\n  static async getInitialProps(ctx) {\n    // https://github.com/zeit/next.js/blob/canary/examples/with-typescript-styled-components/pages/_document.tsx\n    const sheet = new ServerStyleSheet();\n    const originalRenderPage = ctx.renderPage;\n\n    try {\n      var _ref;\n\n      ctx.renderPage = () => originalRenderPage({\n        enhanceApp: App => props => sheet.collectStyles(__jsx(App, props))\n      });\n\n      const initialProps = await Document.getInitialProps(ctx); // steal from https://github.com/isaachinman/next-i18next/issues/20#issuecomment-558799264\n      // FIXME: https://github.com/i18next/i18next-express-middleware/blob/master/src/index.js#L23-L26\n\n      const additionalProps = _objectSpread({}, ((_ref = ctx.res) === null || _ref === void 0 ? void 0 : _ref.locals) || {});\n\n      return _objectSpread({}, initialProps, {}, additionalProps, {\n        styles: __jsx(React.Fragment, null, initialProps.styles, sheet.getStyleElement())\n      });\n    } finally {\n      sheet.seal();\n    }\n  }\n\n  render() {\n    const {\n      language,\n      languageDir\n    } = this.props;\n    return __jsx(Html, {\n      lang: language,\n      dir: languageDir\n    }, __jsx(Head, null), __jsx(\"body\", null, __jsx(Main, null), __jsx(NextScript, null)));\n  }\n\n}","map":null,"metadata":{},"sourceType":"module"}