{"version":3,"file":"DeviceProvider.cjs","sources":["../../../src/hooks/useDevice/DeviceProvider.tsx"],"sourcesContent":["'use client'\n\nimport { type FC, type ReactNode, useSyncExternalStore } from 'react'\n\nimport { defaultBreakpoint } from '../../themes'\n\nimport { DeviceContext } from './useDevice'\n\nconst mediaQuery = {\n  narrow: `(max-width: ${defaultBreakpoint.SP}px)`,\n}\n\nconst subscribe = (onStoreChange: () => void) => {\n  const matchQueryList = matchMedia(mediaQuery.narrow)\n  matchQueryList.addEventListener('change', onStoreChange)\n\n  return () => {\n    matchQueryList.removeEventListener('change', onStoreChange)\n  }\n}\n\nconst getSnapshot = () => matchMedia(mediaQuery.narrow).matches\n\nconst getServerSnapshot = () => null\n\nexport const DeviceProvider: FC<{ children: ReactNode }> = ({ children }) => {\n  const isNarrowView = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot)\n\n  return <DeviceContext.Provider value={isNarrowView}>{children}</DeviceContext.Provider>\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAQA;AACE;;AAGF;;AAEE;AAEA;AACE;AACF;AACF;AAEA;AAEA;;;;AAMA;;"}