{"version":3,"file":"react.mjs","sources":["../../../src/utils/react.ts"],"sourcesContent":["import * as React from 'react'\n\nimport { assert } from './assert'\n\nexport const getReactVersion = () => {\n  const [major, minor, patch] = React.version.split('.').map(Number)\n  return { major, minor, patch }\n}\n\ntype NonNullableValue = object | number | string | boolean | bigint | symbol\n\ntype NonStrictContextValue = NonNullableValue | undefined\ntype StrictContextValue = NonNullableValue | null\n\n/**\n * A function that makes it easy to use the React `createContext` function.\n * @param defaultValue The default value of the context.\n * @param providerName The name of the provider component.\n * **Required if `defaultValue` is `null`able. (not `undefined`!)** Used to make the error message human-readable if contextValue is `null`.\n */\nexport function createContext<ContextValue extends NonStrictContextValue>(\n  defaultValue: ContextValue\n): [React.Provider<ContextValue>, () => ContextValue]\nexport function createContext<ContextValue extends StrictContextValue>(\n  defaultValue: ContextValue,\n  providerName: string\n): [\n  React.Provider<ContextValue>,\n  (consumerName: string) => NonNullable<ContextValue>,\n]\nexport function createContext<ContextValue extends StrictContextValue>(\n  defaultValue: ContextValue,\n  providerName?: string\n) {\n  const Context = React.createContext<ContextValue>(defaultValue)\n\n  function useContext(consumerName?: any) {\n    const contextValue = React.useContext(Context)\n\n    assert(\n      contextValue !== null,\n      `'${consumerName}' must be used within '${providerName}'`\n    )\n\n    return contextValue\n  }\n\n  return [Context.Provider, useContext] as const\n}\n"],"names":["getReactVersion","major","minor","patch","React","version","split","map","Number","createContext","defaultValue","providerName","Context","useContext","consumerName","contextValue","assert","Provider"],"mappings":";;;AAIaA,MAAAA,eAAe,GAAGA,MAAM;EACnC,MAAM,CAACC,KAAK,EAAEC,KAAK,EAAEC,KAAK,CAAC,GAAGC,KAAK,CAACC,OAAO,CAACC,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAACC,MAAM,CAAC;EAClE,OAAO;IAAEP,KAAK;IAAEC,KAAK;AAAEC,IAAAA;GAAO;AAChC;;AAOA;AACA;AACA;AACA;AACA;AACA;;AAWO,SAASM,aAAaA,CAC3BC,YAA0B,EAC1BC,YAAqB,EACrB;AACA,EAAA,MAAMC,OAAO,gBAAGR,KAAK,CAACK,aAAa,CAAeC,YAAY,CAAC;EAE/D,SAASG,UAAUA,CAACC,YAAkB,EAAE;AACtC,IAAA,MAAMC,YAAY,GAAGX,KAAK,CAACS,UAAU,CAACD,OAAO,CAAC;IAE9CI,MAAM,CACJD,YAAY,KAAK,IAAI,EACrB,IAAID,YAAY,CAAA,uBAAA,EAA0BH,YAAY,CAAA,CAAA,CACxD,CAAC;AAED,IAAA,OAAOI,YAAY;AACrB;AAEA,EAAA,OAAO,CAACH,OAAO,CAACK,QAAQ,EAAEJ,UAAU,CAAC;AACvC;;;;"}