!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("whatInput",[],t):"object"==typeof exports?exports.whatInput=t():e.whatInput=t()}(this,function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={exports:{},id:o,loaded:!1};return e[o].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}return n.m=e,n.c=t,n.p="",n(0)}([function(e,t){var n,o,i,r,u,d,a,p,s,c,m,f,w,v,l,h,y;e.exports=(n=document.documentElement,o="initial",i=null,r=["input","select","textarea"],u=[16,17,18,91,93],d={keyup:"keyboard",mousedown:"mouse",mousemove:"mouse",MSPointerDown:"pointer",MSPointerMove:"pointer",pointerdown:"pointer",pointermove:"pointer",touchstart:"touch"},a=[],p=!1,s={2:"touch",3:"touch",4:"mouse"},c=null,m=function(){window.PointerEvent?(n.addEventListener("pointerdown",f),n.addEventListener("pointermove",v)):window.MSPointerEvent?(n.addEventListener("MSPointerDown",f),n.addEventListener("MSPointerMove",v)):(n.addEventListener("mousedown",f),n.addEventListener("mousemove",v),"ontouchstart"in window&&n.addEventListener("touchstart",l)),n.addEventListener(y(),v),n.addEventListener("keydown",f),n.addEventListener("keyup",f)},f=function(e){if(!p){var t=e.which,n=d[e.type];if("pointer"===n&&(n=h(e)),o!==n||i!==n){var a=!(!document.activeElement||-1!==r.indexOf(document.activeElement.nodeName.toLowerCase()));("touch"===n||"mouse"===n&&-1===u.indexOf(t)||"keyboard"===n&&a)&&(o=i=n,w())}}},w=function(){n.setAttribute("data-whatinput",o),n.setAttribute("data-whatintent",o),-1===a.indexOf(o)&&(a.push(o),n.className+=" whatinput-types-"+o)},v=function(e){if(!p){var t=d[e.type];"pointer"===t&&(t=h(e)),i!==t&&(i=t,n.setAttribute("data-whatintent",i))}},l=function(e){window.clearTimeout(c),f(e),p=!0,c=window.setTimeout(function(){p=!1},200)},h=function(e){return"number"==typeof e.pointerType?s[e.pointerType]:"pen"===e.pointerType?"touch":e.pointerType},y=function(){return"onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll"},"addEventListener"in window&&Array.prototype.indexOf&&(d[y()]="mouse",m(),w()),{ask:function(e){return"loose"===e?i:o},types:function(){return a}})}])});