{"version":3,"file":"useRouter.cjs","names":[],"sources":["../../src/useRouter.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { routerContext } from './routerContext'\nimport type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'\n\n/**\n * Access the current TanStack Router instance from React context.\n * Must be used within a `RouterProvider`.\n *\n * Options:\n * - `warn`: Log a warning if no router context is found (default: true).\n *\n * @returns The registered router instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/useRouterHook\n */\nexport function useRouter<TRouter extends AnyRouter = RegisteredRouter>(opts?: {\n  warn?: boolean\n}): TRouter {\n  const value = React.useContext(routerContext)\n  if (!value) {\n    warnMissingRouter(opts)\n  }\n  return value as any\n}\n\n// Kept out of the hook body: this dev-only branch runs for every Link and\n// route hook, and on the server each `process.env` read is a native call.\nfunction warnMissingRouter(opts?: { warn?: boolean }) {\n  if (process.env.NODE_ENV !== 'production' && (opts?.warn ?? true)) {\n    console.warn(\n      'Warning: useRouter must be used inside a <RouterProvider> component!',\n    )\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAgB,UAAwD,MAE5D;CACV,MAAM,QAAQ,MAAM,WAAW,sBAAA,aAAa;CAC5C,IAAI,CAAC,OACH,kBAAkB,IAAI;CAExB,OAAO;AACT;AAIA,SAAS,kBAAkB,MAA2B;CACpD,IAAA,QAAA,IAAA,aAA6B,iBAAiB,MAAM,QAAQ,OAC1D,QAAQ,KACN,sEACF;AAEJ"}