import { jsxs, Fragment, jsx } from "react/jsx-runtime";
import htmlReactParser from "html-react-parser";
function getSSRStyles(html, server) {
  return server.constructStyleTagsFromChunks(server.extractCriticalToChunks(html));
}
function ServerStyles({ html, server }) {
  const styles = getSSRStyles(html, server);
  return /* @__PURE__ */ jsx(Fragment, { children: htmlReactParser(styles) });
}
function createGetInitialProps(NextDocument, server) {
  return async function getInitialProps(ctx) {
    const initialProps = await NextDocument.getInitialProps(ctx);
    return {
      ...initialProps,
      styles: /* @__PURE__ */ jsxs(Fragment, { children: [
        initialProps.styles,
        /* @__PURE__ */ jsx(ServerStyles, { html: initialProps.html, server })
      ] })
    };
  };
}
export {
  ServerStyles,
  createGetInitialProps,
  getSSRStyles
};
