{"version":3,"file":"PortalsProvider.cjs","names":["currentIdCache","currentPortalsCache","PORTALS_REACT_CONTEXT","PORTAL_ANCHORS_REACT_CONTEXT"],"sources":["../../../src/portals/PortalsProvider/PortalsProvider.tsx"],"sourcesContent":["import { useRef } from 'react';\nimport { anchorsSetup, currentIdCache, currentPortalsCache } from '@pastweb/tools';\nimport { PORTALS_REACT_CONTEXT, PORTAL_ANCHORS_REACT_CONTEXT } from '../constants';\nimport type { PortalsDescriptor } from '../types';\nimport type { PortalsProviderProps } from './types';\n\n/**\n * Provides portal helpers through dedicated React context.\n *\n * Use this component when a subtree needs portals but you do not want to\n * install them through `GlobalContext`. Hooks still support the installer path,\n * and provider values take precedence when both are present.\n *\n * @param props - Portal options plus children.\n * @returns Provider-wrapped React subtree.\n *\n * @example\n * ```tsx\n * <PortalsProvider anchorsIds={anchorsIds} getEntry={getEntry}>\n *   <App />\n * </PortalsProvider>\n * ```\n */\nexport function PortalsProvider(props: PortalsProviderProps) {\n  const {\n    anchorsIds,\n    children,\n    getEntry,\n    idChahe = currentIdCache,\n    portalsCache = currentPortalsCache,\n  } = props;\n  const portals = useRef<PortalsDescriptor | null>(null);\n\n  if (!portals.current) {\n    portals.current = anchorsSetup(getEntry, anchorsIds, idChahe, portalsCache);\n  }\n\n  return (\n    <PORTALS_REACT_CONTEXT.Provider value={portals.current}>\n      <PORTAL_ANCHORS_REACT_CONTEXT.Provider value={anchorsIds}>\n        {children}\n      </PORTAL_ANCHORS_REACT_CONTEXT.Provider>\n    </PORTALS_REACT_CONTEXT.Provider>\n  );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,gBAAgB,OAA6B;CAC3D,MAAM,EACJ,YACA,UACA,UACA,UAAUA,eAAAA,gBACV,eAAeC,eAAAA,wBACb;CACJ,MAAM,WAAA,GAAA,MAAA,OAAA,CAA2C,IAAI;CAErD,IAAI,CAAC,QAAQ,SACX,QAAQ,WAAA,GAAA,eAAA,aAAA,CAAuB,UAAU,YAAY,SAAS,YAAY;CAG5E,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,0BAAAA,sBAAsB,UAAvB;EAAgC,OAAO,QAAQ;YAC7C,iBAAA,GAAA,kBAAA,IAAA,CAACC,0BAAAA,6BAA6B,UAA9B;GAAuC,OAAO;GAC3C;EACoC,CAAA;CACT,CAAA;AAEpC"}