{"version":3,"file":"useRouteDepth.cjs","names":["ROUTE_DEPTH_REACT_CONTEXT","getContext","ROUTE_DEPTH_CONTEXT_KEY"],"sources":["../../../src/router/useRouteDepth/useRouteDepth.ts"],"sourcesContent":["import { useContext } from 'react';\nimport { ROUTE_DEPTH_CONTEXT_KEY } from '@pastweb/tools';\nimport { getContext } from '../../GlobalContext';\nimport { ROUTE_DEPTH_REACT_CONTEXT } from '../constants';\n\n/**\n * Reads the current `RouterView` nesting depth.\n *\n * @returns Current route depth. The root provider starts at `-1`.\n *\n * @throws When route depth has not been installed.\n *\n * @example\n * ```tsx\n * const depth = useRouteDepth();\n * ```\n */\nexport function useRouteDepth(): number {\n  const providerDepth = useContext(ROUTE_DEPTH_REACT_CONTEXT);\n  const globalDepth = getContext<number>(ROUTE_DEPTH_CONTEXT_KEY);\n\n  return providerDepth ?? globalDepth;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiBA,SAAgB,gBAAwB;CACtC,MAAM,iBAAA,GAAA,MAAA,WAAA,CAA2BA,yBAAAA,yBAAyB;CAC1D,MAAM,cAAcC,iCAAAA,WAAmBC,eAAAA,uBAAuB;CAE9D,OAAO,iBAAiB;AAC1B"}