{"version":3,"file":"index-node22.mjs","sources":["../src/createDocumentInitialProps.tsx","../src/index.tsx"],"sourcesContent":["import type NextDocument from \"next/document\";\nimport type { ReactElement } from \"react\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { StyleSheet } from \"react-native\";\n\n/**\n *\n * @example\n * ```\n * export { createGetDocumentInitialProps } from 'alp-nextjs';\n *\n * export default class MyDocument extends NextDocument {\n *   static getInitialProps = createGetDocumentInitialProps(() => <style>custom style</style>);\n * }\n * ```\n */\n\nexport function createDocumentInitialProps(\n  getMoreStyles?: () => ReactElement | ReactElement[],\n): (typeof NextDocument)[\"getInitialProps\"] {\n  return async (ctx) => {\n    const page = await ctx.renderPage();\n\n    // @ts-expect-error -- RN doesn't have this type\n    const rnwStyle = StyleSheet.getSheet();\n\n    return {\n      ...page,\n      styles: (\n        <>\n          <style\n            dangerouslySetInnerHTML={{ __html: rnwStyle.textContent }}\n            id={rnwStyle.id}\n          />\n          {getMoreStyles?.()}\n        </>\n      ),\n    };\n  };\n}\n","import Cookies from \"cookies\";\nimport type { GetServerSidePropsContext, NextPageContext } from \"next\";\n\nexport { type NextPageContext, type GetServerSidePropsContext } from \"next\";\n\nexport { createDocumentInitialProps } from \"./createDocumentInitialProps\";\n\nexport const getServerCookieValue = (\n  ctx: GetServerSidePropsContext | NextPageContext,\n  cookieName: string,\n): string | null => {\n  if (!ctx.req || !ctx.res) {\n    throw new Error(\n      \"Missing ctx.req or ctx.res. Make sure getInitialProps is set.\",\n    );\n  }\n\n  const cookies = new Cookies(ctx.req, ctx.res);\n  return cookies.get(cookieName) || null;\n};\n"],"names":[],"mappings":";;;;AAiBO,SAAS,2BACd,aAAA,EAC0C;AAC1C,EAAA,OAAO,OAAO,GAAA,KAAQ;AACpB,IAAA,MAAM,IAAA,GAAO,MAAM,GAAA,CAAI,UAAA,EAAW;AAGlC,IAAA,MAAM,QAAA,GAAW,WAAW,QAAA,EAAS;AAErC,IAAA,OAAO;AAAA,MACL,GAAG,IAAA;AAAA,MACH,wBACE,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,wBAAA,GAAA;AAAA,UAAC,OAAA;AAAA,UAAA;AAAA,YACC,uBAAA,EAAyB,EAAE,MAAA,EAAQ,QAAA,CAAS,WAAA,EAAY;AAAA,YACxD,IAAI,QAAA,CAAS;AAAA;AAAA,SACf;AAAA,QACC,aAAA;AAAgB,OAAA,EACnB;AAAA,KAEJ;AAAA,EACF,CAAA;AACF;;AChCO,MAAM,oBAAA,GAAuB,CAClC,GAAA,EACA,UAAA,KACkB;AAClB,EAAA,IAAI,CAAC,GAAA,CAAI,GAAA,IAAO,CAAC,IAAI,GAAA,EAAK;AACxB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AAEA,EAAA,MAAM,UAAU,IAAI,OAAA,CAAQ,GAAA,CAAI,GAAA,EAAK,IAAI,GAAG,CAAA;AAC5C,EAAA,OAAO,OAAA,CAAQ,GAAA,CAAI,UAAU,CAAA,IAAK,IAAA;AACpC;;;;"}