{"version":3,"sources":["../src/theme/client.tsx"],"sourcesContent":["\"use client\";\n\nimport { useSyncExternalStore } from \"react\";\nimport { getFarmThemeServerSnapshot } from \"./bridge\";\nimport { getTheme, setTheme, subscribeTheme, toggleTheme } from \"./runtime\";\nimport type { FarmThemePreference, FarmThemeSnapshot, FarmResolvedTheme } from \"./types\";\n\nexport { getTheme, setTheme, toggleTheme } from \"./runtime\";\n\nfunction getHydrationSnapshot(): FarmThemeSnapshot {\n  if (typeof window !== \"undefined\" && window.__FARM_THEME__?.serverSnapshot) {\n    return window.__FARM_THEME__.serverSnapshot;\n  }\n  return getFarmThemeServerSnapshot();\n}\n\nexport interface UseThemeResult extends FarmThemeSnapshot {\n  setTheme(theme: FarmThemePreference): void;\n  toggleTheme(): FarmResolvedTheme;\n}\n\nexport function useTheme(): UseThemeResult {\n  const snapshot = useSyncExternalStore(subscribeTheme, getTheme, getHydrationSnapshot);\n  return {\n    ...snapshot,\n    setTheme,\n    toggleTheme,\n  };\n}\n"],"mappings":";;;;;;;;;;;;;;AAEA,SAAS,4BAA4B;AAOrC,SAAS,uBAA0C;AACjD,MAAI,OAAO,WAAW,eAAe,OAAO,gBAAgB,gBAAgB;AAC1E,WAAO,OAAO,eAAe;AAAA,EAC/B;AACA,SAAO,2BAA2B;AACpC;AALS;AAYF,SAAS,WAA2B;AACzC,QAAM,WAAW,qBAAqB,gBAAgB,UAAU,oBAAoB;AACpF,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AACF;AAPgB;","names":[]}