{"version":3,"file":"C4xf6Rln.js","sources":["../../../../composables/useMedia.ts"],"sourcesContent":["type Props = {\r\n query: string;\r\n};\r\n\r\nexport const defaultWindow = typeof window !== 'undefined' ? window : undefined;\r\n\r\nexport const useMedia = ({ query }: Props) => {\r\n const win = defaultWindow;\r\n const isSupported = computed(\r\n () => win && 'matchMedia' in win && typeof win.matchMedia === 'function',\r\n );\r\n\r\n let mediaQuery: MediaQueryList | undefined;\r\n const matches = ref(false);\r\n\r\n const update = () => {\r\n matches.value = !!mediaQuery?.matches;\r\n };\r\n\r\n onMounted(() => {\r\n if (!isSupported) {\r\n return;\r\n }\r\n\r\n mediaQuery = window.matchMedia(toRef(query).value);\r\n\r\n if (!mediaQuery.addEventListener) {\r\n // Safari\r\n mediaQuery.addListener(update);\r\n } else {\r\n mediaQuery.addEventListener('change', update);\r\n }\r\n\r\n update();\r\n });\r\n\r\n onUnmounted(() => {\r\n if (!mediaQuery) {\r\n return;\r\n }\r\n\r\n if (!mediaQuery.removeEventListener) {\r\n mediaQuery.removeListener(update);\r\n } else {\r\n mediaQuery.removeEventListener('change', update);\r\n }\r\n });\r\n\r\n return matches;\r\n};\r\n"],"names":["defaultWindow","useMedia","query","win","isSupported","computed","mediaQuery","matches","ref","update","onMounted","toRef","onUnmounted"],"mappings":"+DAIO,MAAMA,EAAgB,OAAO,OAAW,IAAc,OAAS,OAEzDC,EAAW,CAAC,CAAE,MAAAC,KAAmB,CAC5C,MAAMC,EAAMH,EACNI,EAAcC,EAClB,IAAMF,GAAO,eAAgBA,GAAO,OAAOA,EAAI,YAAe,UAAA,EAG5D,IAAAG,EACE,MAAAC,EAAUC,EAAI,EAAK,EAEnBC,EAAS,IAAM,CACXF,EAAA,MAAQ,CAAC,EAACD,GAAA,MAAAA,EAAY,QAAA,EAGhC,OAAAI,EAAU,IAAM,CACTN,IAILE,EAAa,OAAO,WAAWK,EAAMT,CAAK,EAAE,KAAK,EAE5CI,EAAW,iBAIHA,EAAA,iBAAiB,SAAUG,CAAM,EAF5CH,EAAW,YAAYG,CAAM,EAKxBA,IAAA,CACR,EAEDG,EAAY,IAAM,CACXN,IAIAA,EAAW,oBAGHA,EAAA,oBAAoB,SAAUG,CAAM,EAF/CH,EAAW,eAAeG,CAAM,EAGlC,CACD,EAEMF,CACT"}