{
  "version": 3,
  "sources": ["../../../src/lib/hooks/useViewportHeight.ts"],
  "sourcesContent": ["import { useLayoutEffect, useState } from 'react'\nimport { useMaybeEditor } from './useEditor'\n\n/*!\n * BSD License: https://github.com/outline/rich-markdown-editor/blob/main/LICENSE\n * Copyright (c) 2020 General Outline, Inc (https://www.getoutline.com/) and individual contributors.\n *\n * Returns the height of the viewport.\n * This is mainly to account for virtual keyboards on mobile devices.\n *\n * N.B. On iOS, you have to take into account the offsetTop as well so that you get an accurate position\n * while using the virtual keyboard.\n */\n/** @public */\nexport function useViewportHeight(): number {\n\tconst editor = useMaybeEditor()\n\tconst win = editor?.getContainerWindow() ?? window\n\tconst vv = win.visualViewport\n\tconst [height, setHeight] = useState<number>(() =>\n\t\tvv ? vv.height + vv.offsetTop : win.innerHeight\n\t)\n\n\tuseLayoutEffect(() => {\n\t\tconst win = editor?.getContainerWindow() ?? window\n\t\tconst handleResize = () => {\n\t\t\tconst vv = win.visualViewport\n\t\t\tsetHeight(() => (vv ? vv.height + vv.offsetTop : win.innerHeight))\n\t\t}\n\n\t\twin.visualViewport?.addEventListener('resize', handleResize)\n\t\twin.visualViewport?.addEventListener('scroll', handleResize)\n\n\t\treturn () => {\n\t\t\twin.visualViewport?.removeEventListener('resize', handleResize)\n\t\t\twin.visualViewport?.removeEventListener('scroll', handleResize)\n\t\t}\n\t}, [editor])\n\treturn height\n}\n"],
  "mappings": "AAAA,SAAS,iBAAiB,gBAAgB;AAC1C,SAAS,sBAAsB;AAE/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWO,SAAS,oBAA4B;AAC3C,QAAM,SAAS,eAAe;AAC9B,QAAM,MAAM,QAAQ,mBAAmB,KAAK;AAC5C,QAAM,KAAK,IAAI;AACf,QAAM,CAAC,QAAQ,SAAS,IAAI;AAAA,IAAiB,MAC5C,KAAK,GAAG,SAAS,GAAG,YAAY,IAAI;AAAA,EACrC;AAEA,kBAAgB,MAAM;AACrB,UAAMA,OAAM,QAAQ,mBAAmB,KAAK;AAC5C,UAAM,eAAe,MAAM;AAC1B,YAAMC,MAAKD,KAAI;AACf,gBAAU,MAAOC,MAAKA,IAAG,SAASA,IAAG,YAAYD,KAAI,WAAY;AAAA,IAClE;AAEA,IAAAA,KAAI,gBAAgB,iBAAiB,UAAU,YAAY;AAC3D,IAAAA,KAAI,gBAAgB,iBAAiB,UAAU,YAAY;AAE3D,WAAO,MAAM;AACZ,MAAAA,KAAI,gBAAgB,oBAAoB,UAAU,YAAY;AAC9D,MAAAA,KAAI,gBAAgB,oBAAoB,UAAU,YAAY;AAAA,IAC/D;AAAA,EACD,GAAG,CAAC,MAAM,CAAC;AACX,SAAO;AACR;",
  "names": ["win", "vv"]
}
