const e="ionKeyboardDidShow",o="ionKeyboardDidHide";let t={},d={},i=!1;const a=()=>{t={},d={},i=!1},n=e=>{h(e),e.visualViewport&&(d=p(e.visualViewport),e.visualViewport.onresize=()=>{D(e),r()||y(e)?s(e):c(e)&&b(e)})},h=e=>{e.addEventListener("keyboardDidShow",(o=>s(e,o))),e.addEventListener("keyboardDidHide",(()=>b(e)))},s=(e,o)=>{f(e,o),i=!0},b=e=>{w(e),i=!1},r=()=>!i&&t.width===d.width&&(t.height-d.height)*d.scale>150,y=e=>i&&!c(e),c=e=>i&&d.height===e.innerHeight,f=(e,o)=>{const t=new CustomEvent("ionKeyboardDidShow",{detail:{keyboardHeight:o?o.keyboardHeight:e.innerHeight-d.height}});e.dispatchEvent(t)},w=e=>{const o=new CustomEvent("ionKeyboardDidHide");e.dispatchEvent(o)},D=e=>{t=Object.assign({},d),d=p(e.visualViewport)},p=e=>({width:Math.round(e.width),height:Math.round(e.height),offsetTop:e.offsetTop,offsetLeft:e.offsetLeft,pageTop:e.pageTop,pageLeft:e.pageLeft,scale:e.scale});export{o as KEYBOARD_DID_CLOSE,e as KEYBOARD_DID_OPEN,p as copyVisualViewport,c as keyboardDidClose,r as keyboardDidOpen,y as keyboardDidResize,a as resetKeyboardAssist,b as setKeyboardClose,s as setKeyboardOpen,n as startKeyboardAssist,D as trackViewportChanges}