{"version":3,"sources":["/home/runner/work/openframe-oss-lib/openframe-oss-lib/openframe-frontend-core/dist/contexts/index.cjs","../../src/contexts/use-outer-or-default.ts"],"names":[],"mappings":"AAAA,yLAAY;AACZ;AACE;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACA;ACkBA,8BAAkD;AAE3C,SAAS,iBAAA,CACd,OAAA,EACA,OAAA,EACA,KAAA,EAA+B,CAAC,CAAA,EAC7B;AACH,EAAA,MAAM,MAAA,EAAQ,+BAAA,OAAkB,CAAA;AAGhC,EAAA,MAAM,SAAA,EAAW,4BAAA,OAAQ,EAAS,IAAI,CAAA;AACtC,EAAA,wBAAO,KAAA,UAAS,UAAA;AAClB;ADvBA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,8dAAC","file":"/home/runner/work/openframe-oss-lib/openframe-oss-lib/openframe-frontend-core/dist/contexts/index.cjs","sourcesContent":[null,"'use client'\n\n/**\n * Outer-forward provider helper — used by hub + embedder providers\n * that supply default runtime values while allowing OUTER providers\n * to override.\n *\n * When an embedder mounts an outer `<ChatRuntimeContext.Provider>`\n * (or `<EndpointsRuntimeContext.Provider>`) ABOVE the hub provider,\n * the outer value wins. When no outer is mounted, the hub provider\n * supplies its `factory()` default. Tree shape stays constant —\n * same provider element at the same position regardless of outer\n * presence — so consumers below never remount when an embedder\n * toggles their providers at runtime.\n *\n * `deps` controls factory memoization:\n *   - Empty `[]` (default) → factory runs ONCE per mount; safe ONLY\n *     when factory closes over module-scope/constant values.\n *   - Non-empty → factory re-runs when deps change. Use when the\n *     factory closes over callbacks or other reactive values\n *     (e.g. hub's ChatRuntime which includes `navigate` +\n *     `decideNewTab` callbacks that depend on router + docNav).\n *\n * Returning the SAME reference across renders is critical for\n * downstream `useMemo` consumers. With empty deps, identity is\n * trivially stable. With reactive deps, the caller must memoize\n * the deps themselves (typically via `useCallback`).\n */\n\nimport { useContext, useMemo, type Context } from 'react'\n\nexport function useOuterOrDefault<T>(\n  context: Context<T | null>,\n  factory: () => T,\n  deps: ReadonlyArray<unknown> = [],\n): T {\n  const outer = useContext(context)\n  // eslint-disable-next-line react-hooks/exhaustive-deps -- deps are the contract;\n  // factory identity is intentionally ignored (caller controls re-creation via deps).\n  const fallback = useMemo(factory, deps)\n  return outer ?? fallback\n}\n"]}