{"version":3,"file":"DbProvider.cjs","names":["createContext","useContext"],"sources":["../../src/DbProvider.tsx"],"sourcesContent":["'use client'\n\nimport { createContext, useContext } from 'react'\nimport type { DbClient } from '@tanstack/db'\nimport type { ReactNode } from 'react'\n\nconst DbContext = createContext<DbClient | undefined>(undefined)\n\nexport type DbProviderProps = {\n  client: DbClient\n  children?: ReactNode\n}\n\nexport function DbProvider(props: DbProviderProps) {\n  return (\n    <DbContext.Provider value={props.client}>\n      {props.children}\n    </DbContext.Provider>\n  )\n}\n\nexport function useDbClient(): DbClient {\n  const client = useContext(DbContext)\n  if (!client) {\n    throw new Error(`useDbClient must be used within a DbProvider.`)\n  }\n  return client\n}\n\nexport function useOptionalDbClient(): DbClient | undefined {\n  return useContext(DbContext)\n}\n"],"mappings":";;;;AAMA,IAAM,aAAA,GAAYA,MAAAA,cAAAA,CAAoC,KAAA,CAAS;AAO/D,SAAgB,WAAW,OAAwB;CACjD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAU,UAAX;EAAoB,OAAO,MAAM;EAC9B,UAAA,MAAM;CACW,CAAA;AAExB;AAEA,SAAgB,cAAwB;CACtC,MAAM,UAAA,GAASC,MAAAA,WAAAA,CAAW,SAAS;CACnC,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,+CAA+C;CAEjE,OAAO;AACT;AAEA,SAAgB,sBAA4C;CAC1D,QAAA,GAAOA,MAAAA,WAAAA,CAAW,SAAS;AAC7B"}