{"version":3,"file":"usePortalAnchors.cjs","names":["PORTAL_ANCHORS_REACT_CONTEXT","getContext","PORTAL_ANCHORS_CONTEXT_KEY"],"sources":["../../../src/portals/usePortalAnchors/usePortalAnchors.ts"],"sourcesContent":["import { useContext } from 'react';\nimport { PORTAL_ANCHORS_CONTEXT_KEY } from '@pastweb/tools';\nimport { getContext } from '../../GlobalContext';\nimport { PORTAL_ANCHORS_REACT_CONTEXT } from '../constants';\n\n/**\n * Reads the portal anchor ids installed by {@link installPortals}.\n *\n * @typeParam T - Expected anchor id shape.\n *\n * @returns The current portal anchor ids cast to `T`.\n *\n * @example\n * ```tsx\n * const anchors = usePortalAnchors<{ modal: string }>();\n *\n * return <div id={anchors.modal} />;\n * ```\n */\nexport function usePortalAnchors<T>(): T {\n  const providerAnchors = useContext(PORTAL_ANCHORS_REACT_CONTEXT);\n  const globalAnchors = getContext<T>(PORTAL_ANCHORS_CONTEXT_KEY);\n\n  return (providerAnchors ?? globalAnchors) as T;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,mBAAyB;CACvC,MAAM,mBAAA,GAAA,MAAA,WAAA,CAA6BA,0BAAAA,4BAA4B;CAC/D,MAAM,gBAAgBC,iCAAAA,WAAcC,eAAAA,0BAA0B;CAE9D,OAAQ,mBAAmB;AAC7B"}