{"version":3,"file":"useRouter.cjs","names":["ROUTER_REACT_CONTEXT","getContext","ROUTER_CONTEXT_KEY"],"sources":["../../../src/router/useRouter/useRouter.ts"],"sourcesContent":["import { useContext } from 'react';\nimport { ROUTER_CONTEXT_KEY } from '@pastweb/tools';\nimport { getContext } from '../../GlobalContext';\nimport { ROUTER_REACT_CONTEXT } from '../constants';\nimport type { ViewRouter } from '@pastweb/tools';\n\n/**\n * Reads the installed tools `ViewRouter`.\n *\n * @returns The router installed with {@link installRouter}.\n *\n * @throws When the router context has not been installed.\n *\n * @example\n * ```tsx\n * const router = useRouter();\n *\n * await router.navigate('/home');\n * ```\n */\nexport function useRouter(): ViewRouter {\n  const providerRouter = useContext(ROUTER_REACT_CONTEXT);\n  const globalRouter = getContext<ViewRouter>(ROUTER_CONTEXT_KEY);\n\n  return providerRouter ?? globalRouter;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,YAAwB;CACtC,MAAM,kBAAA,GAAA,MAAA,WAAA,CAA4BA,yBAAAA,oBAAoB;CACtD,MAAM,eAAeC,iCAAAA,WAAuBC,eAAAA,kBAAkB;CAE9D,OAAO,kBAAkB;AAC3B"}