{"version":3,"file":"useLocation.cjs","names":["useRouter","useForceUpdate"],"sources":["../../../src/router/useLocation/useLocation.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { effect } from '@pastweb/tools/reactivity';\nimport { useForceUpdate } from '../../useForceUpdate';\nimport { useRouter } from '../useRouter';\nimport type { Location } from '@pastweb/tools';\n\n/**\n * Reads the current router location and re-renders when it changes.\n *\n * @returns The router `Location` object.\n *\n * @example\n * ```tsx\n * const location = useLocation();\n *\n * return <span>{location.pathname}</span>;\n * ```\n */\nexport const useLocation = (): Location => {\n  const router = useRouter();\n  const forceUpdate = useForceUpdate();\n\n  useEffect(() => {\n    effect(forceUpdate, () => router.location.href);\n  }, [forceUpdate, router]);\n\n  return router.location;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,oBAA8B;CACzC,MAAM,SAASA,mCAAAA,UAAU;CACzB,MAAM,cAAcC,sCAAAA,eAAe;CAEnC,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,CAAA,GAAA,0BAAA,OAAA,CAAO,mBAAmB,OAAO,SAAS,IAAI;CAChD,GAAG,CAAC,aAAa,MAAM,CAAC;CAExB,OAAO,OAAO;AAChB"}