{"version":3,"file":"index-node20.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":["createDocumentInitialProps","getMoreStyles","ctx","page","renderPage","rnwStyle","StyleSheet","getSheet","styles","_jsxs","_Fragment","children","_jsx","dangerouslySetInnerHTML","__html","textContent","id","getServerCookieValue","cookieName","req","res","Error","cookies","Cookies","get"],"mappings":";;;;AAEA;AAeO,SAASA,0BAA0BA,CACxCC,aAAmD,EACT;EAC1C,OAAO,MAAOC,GAAG,IAAK;AACpB,IAAA,MAAMC,IAAI,GAAG,MAAMD,GAAG,CAACE,UAAU,EAAE;;AAEnC;AACA,IAAA,MAAMC,QAAQ,GAAGC,UAAU,CAACC,QAAQ,EAAE;IAEtC,OAAO;AACL,MAAA,GAAGJ,IAAI;MACPK,MAAM,eACJC,IAAA,CAAAC,QAAA,EAAA;AAAAC,QAAAA,QAAA,gBACEC,GAAA,CAAA,OAAA,EAAA;AACEC,UAAAA,uBAAuB,EAAE;YAAEC,MAAM,EAAET,QAAQ,CAACU;WAAc;UAC1DC,EAAE,EAAEX,QAAQ,CAACW;AAAG,SACjB,CAAC,EACDf,aAAa,IAAI;OAClB;KAEL;GACF;AACH;;MChCagB,oBAAoB,GAAGA,CAClCf,GAAgD,EAChDgB,UAAkB,KACA;EAClB,IAAI,CAAChB,GAAG,CAACiB,GAAG,IAAI,CAACjB,GAAG,CAACkB,GAAG,EAAE;AACxB,IAAA,MAAM,IAAIC,KAAK,CACb,+DACF,CAAC;AACH;AAEA,EAAA,MAAMC,OAAO,GAAG,IAAIC,OAAO,CAACrB,GAAG,CAACiB,GAAG,EAAEjB,GAAG,CAACkB,GAAG,CAAC;AAC7C,EAAA,OAAOE,OAAO,CAACE,GAAG,CAACN,UAAU,CAAC,IAAI,IAAI;AACxC;;;;"}