{"version":3,"file":"HydrationBoundary.cjs","names":["useDbClient","useRef"],"sources":["../../src/HydrationBoundary.tsx"],"sourcesContent":["'use client'\n\nimport { useRef } from 'react'\nimport { useDbClient } from './DbProvider'\nimport type { DehydratedDbState } from '@tanstack/db'\nimport type { ReactNode } from 'react'\n\nexport type HydrationBoundaryProps = {\n  state: DehydratedDbState\n  children?: ReactNode\n}\n\nexport function HydrationBoundary({ state, children }: HydrationBoundaryProps) {\n  const client = useDbClient()\n  const hydrated = useRef<\n    { client: typeof client; state: DehydratedDbState } | undefined\n  >(undefined)\n\n  if (hydrated.current?.client !== client || hydrated.current.state !== state) {\n    client.hydrate(state)\n    hydrated.current = { client, state }\n  }\n\n  return children\n}\n"],"mappings":";;;;AAYA,SAAgB,kBAAkB,EAAE,OAAO,YAAoC;CAC7E,MAAM,SAASA,mBAAAA,YAAY;CAC3B,MAAM,YAAA,GAAWC,MAAAA,OAAAA,CAEf,KAAA,CAAS;CAEX,IAAI,SAAS,SAAS,WAAW,UAAU,SAAS,QAAQ,UAAU,OAAO;EAC3E,OAAO,QAAQ,KAAK;EACpB,SAAS,UAAU;GAAE;GAAQ;EAAM;CACrC;CAEA,OAAO;AACT"}