{"version":3,"file":"account-api-context-CrShCYnN.cjs","names":[],"sources":["../../core/src/account-api-context.ts"],"sourcesContent":["import { createContext, use } from \"react\";\nimport type { AccountApi } from \"./account-api\";\n\nconst AccountApiContext = createContext<AccountApi | null>(null);\n\nexport const AccountApiProvider = AccountApiContext.Provider;\n\nexport function useAccountApi(): AccountApi {\n  const api = use(AccountApiContext);\n  if (!api) {\n    throw new Error(\"useAccountApi must be used within an AccountApiProvider\");\n  }\n  return api;\n}\n\n/**\n * Non-throwing variant, mirroring useOptionalStoreApi. Widgets mounted outside\n * the portal shell — the screen-builder palette and drag preview — have no\n * AccountApiProvider, and a widget that merely wants to know whether the viewer\n * may see rep-only data should degrade rather than crash the palette.\n *\n * Returns null instead of throwing. Callers must treat null as \"viewer unknown\",\n * which the volume policy resolves to \"not entitled\".\n */\nexport function useOptionalAccountApi(): AccountApi | null {\n  return use(AccountApiContext);\n}\n"],"mappings":";;;AAGA,MAAM,qBAAA,GAAA,MAAA,eAAqD,KAAK;AAEhE,MAAa,qBAAqB,kBAAkB;AAEpD,SAAgB,gBAA4B;CAC1C,MAAM,OAAA,GAAA,MAAA,KAAU,kBAAkB;AAClC,KAAI,CAAC,IACH,OAAM,IAAI,MAAM,0DAA0D;AAE5E,QAAO;;;;;;;;;;;AAYT,SAAgB,wBAA2C;AACzD,SAAA,GAAA,MAAA,KAAW,kBAAkB"}