{"version":3,"file":"useDevicePixelRatio.mjs","names":["useState","useEffect","useDevicePixelRatio","$","_c","devicePixelRatio","updateDevicePixelRatio","window","t0","t1","mm","matchMedia","handler","addListener","removeListener"],"sources":["../../src/utilities/useDevicePixelRatio.ts"],"sourcesContent":["import { useState, useEffect } from 'react';\n\n/**\n * React hook that returns the device's current pixel ratio according to `window.devicePixelRatio`\n *\n * This hook will automatically re-render a component if `window.devicePixelRatio` changes (due to monitor preference changes or moving windows between monitors).\n */\nexport default function useDevicePixelRatio(): number {\n  const [devicePixelRatio, updateDevicePixelRatio] = useState(\n    window.devicePixelRatio\n  );\n\n  // Effect that listens for changes to the devicePixelRatio and updates the state if it changes\n  useEffect(() => {\n    const mm = matchMedia(`(resolution: ${devicePixelRatio}dppx)`);\n\n    const handler = () => {\n      updateDevicePixelRatio(window.devicePixelRatio);\n    };\n\n    mm.addListener(handler);\n    return () => mm.removeListener(handler);\n  }, [devicePixelRatio]);\n\n  return devicePixelRatio;\n}\n"],"mappings":";;;;;;;;AAOA,SAAeE,sBAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CACb,MAAA,CAAAC,kBAAAC,0BAAmDN,SACjDO,OAAMF,iBACP;CAAC,IAAAG;CAAA,IAAAC;AAAA,KAAAN,EAAA,OAAAE,kBAAA;AAGQG,aAAA;GACR,MAAAE,KAAWC,WAAW,gBAAgBN,iBAAgB,OAAQ;GAE9D,MAAAO,gBAAgB;AACdN,2BAAuBC,OAAMF,iBAAkB;;AAGjDK,MAAEG,YAAaD,QAAQ;AAAA,gBACVF,GAAEI,eAAgBF,QAAQ;;AACtCH,OAAA,CAACJ,iBAAiB;AAAAF,IAAA,KAAAE;AAAAF,IAAA,KAAAK;AAAAL,IAAA,KAAAM;QAAA;AAAAD,OAAAL,EAAA;AAAAM,OAAAN,EAAA;;AATrBF,WAAUO,IASPC,GAAmB;AAAA,QAEfJ"}