import { useSyncExternalStore } from 'react';

function useMedia(query) {
  return useSyncExternalStore(onStoreChange => {
    const mediaQueryList = window.matchMedia(query);
    mediaQueryList.addEventListener('change', onStoreChange);
    return () => {
      mediaQueryList.removeEventListener('change', onStoreChange);
    };
  }, () => typeof window !== 'undefined' ? window.matchMedia(query).matches : undefined, () => undefined);
}

export { useMedia };
//# sourceMappingURL=useMedia.mjs.map
