{"version":3,"sources":["../../src/widget/responsiveUIHandlers.ts"],"sourcesContent":["// In a responsive UI, we need to adjust the body's overflow property\n// to manage scrolling behavior. To ensure we can revert to the\n// previous styling (important for any DApp), we first store the current\n// overflow value in a variable.\nlet previousBodyOverflowProperty: null | string = null\n\nexport type Device = 'desktop' | 'mobile'\n\nexport const DEFAULT_DEVICE: Device = 'desktop'\n\nexport const getResponsiveUIHandlers = () => {\n  const getIsMobileMediaQuery = () => matchMedia('(max-width:600px)')\n\n  const getComputedBodyOverflowProperty = () =>\n    getComputedStyle(document.body).overflow\n\n  const getDeviceType = (): Device =>\n    getIsMobileMediaQuery().matches ? 'mobile' : 'desktop'\n\n  const addDeviceChangeListener = (onChange: (device: Device) => void) =>\n    getIsMobileMediaQuery().addEventListener('change', ({matches}) => {\n      onChange(matches ? 'mobile' : 'desktop')\n    })\n\n  const toggleBodyOverflow = ({hidden}: {hidden: boolean}) => {\n    // only overwrite when when necessary\n    if (hidden) {\n      previousBodyOverflowProperty = getComputedBodyOverflowProperty()\n      document.body.style.overflow = 'hidden'\n    } else if (previousBodyOverflowProperty) {\n      document.body.style.overflow = previousBodyOverflowProperty\n      previousBodyOverflowProperty = null\n    }\n  }\n\n  return {\n    getDeviceType,\n    addDeviceChangeListener,\n    toggleBodyOverflow,\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,IAAI,+BAA8C;AAI3C,IAAM,iBAAyB;AAE/B,IAAM,0BAA0B,MAAM;AAC3C,QAAM,wBAAwB,MAAM,WAAW,mBAAmB;AAElE,QAAM,kCAAkC,MACtC,iBAAiB,SAAS,IAAI,EAAE;AAElC,QAAM,gBAAgB,MACpB,sBAAsB,EAAE,UAAU,WAAW;AAE/C,QAAM,0BAA0B,CAAC,aAC/B,sBAAsB,EAAE,iBAAiB,UAAU,CAAC,EAAC,QAAO,MAAM;AAChE,aAAS,UAAU,WAAW,SAAS;AAAA,EACzC,CAAC;AAEH,QAAM,qBAAqB,CAAC,EAAC,OAAM,MAAyB;AAE1D,QAAI,QAAQ;AACV,qCAA+B,gCAAgC;AAC/D,eAAS,KAAK,MAAM,WAAW;AAAA,IACjC,WAAW,8BAA8B;AACvC,eAAS,KAAK,MAAM,WAAW;AAC/B,qCAA+B;AAAA,IACjC;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}