(function(e,t,n,o){"use strict";var i,r,c=!1,u={};function s(e,t,n,o,i){o=o||0,i=i||0,this.identifier=t,this.target=e,this.clientX=n.clientX+o,this.clientY=n.clientY+i,this.screenX=n.screenX+o,this.screenY=n.screenY+i,this.pageX=n.pageX+o,this.pageY=n.pageY+i}function a(){var e=[];return e.item=function(e){return this[e]||null},e.identifiedTouch=function(e){return this[e+1]||null},e}function d(){for(var n=[e,t.documentElement],i=["ontouchstart","ontouchmove","ontouchcancel","ontouchend"],r=0;r<n.length;r++)for(var c=0;c<i.length;c++)n[r]&&n[r][i[c]]==o&&(n[r][i[c]]=null)}function h(){return"ontouchstart"in e||e.Modernizr&&e.Modernizr.touch||(navigator.msMaxTouchPoints||navigator.maxTouchPoints)>2}function f(e){}function l(e){return function(t){f(t),1===t.which&&(("mousedown"==t.type||!r||r&&!r.dispatchEvent)&&(r=t.target),c&&!t.shiftKey&&(p("touchend",t),c=!1),p(e,t),!c&&t.shiftKey&&(c=!0,i={pageX:t.pageX,pageY:t.pageY,clientX:t.clientX,clientY:t.clientY,screenX:t.screenX,screenY:t.screenY},p("touchstart",t)),"mouseup"==t.type&&(i=null,c=!1,r=null))}}function p(e,n){var o=t.createEvent("Event");o.initEvent(e,!0,!0),o.altKey=n.altKey,o.ctrlKey=n.ctrlKey,o.metaKey=n.metaKey,o.shiftKey=n.shiftKey,o.touches=v(n,e),o.targetTouches=v(n,e),o.changedTouches=g(n,e),r.dispatchEvent(o)}function m(e){var t=new a;if(c){var n=E.multiTouchOffset,o=i.pageX-e.pageX,u=i.pageY-e.pageY;t.push(new s(r,1,i,-1*o-n,-1*u+n)),t.push(new s(r,2,i,o+n,u-n))}else t.push(new s(r,1,e,0,0));return t}function v(e,t){if("mouseup"==e.type)return new a;var n=m(e);return c&&"mouseup"!=e.type&&"touchend"==t&&n.splice(1,1),n}function g(e,t){var n=m(e);return!c||"mouseup"==e.type||"touchstart"!=t&&"touchend"!=t||n.splice(0,1),n}function y(e){var n,o,i,r;for(o=0;o<e.touches.length;o++)for(var c in n=e.touches[o],i=u[n.identifier],i||(i=u[n.identifier]=t.createElement("div"),t.body.appendChild(i)),r=E.template(n),r)i.style[c]=r[c];if("touchend"==e.type||"touchcancel"==e.type)for(o=0;o<e.changedTouches.length;o++)n=e.changedTouches[o],i=u[n.identifier],i&&(i.parentNode.removeChild(i),delete u[n.identifier])}function E(){h()||(d(),e.addEventListener("mousedown",l("touchstart"),!0),e.addEventListener("mousemove",l("touchmove"),!0),e.addEventListener("mouseup",l("touchend"),!0),e.addEventListener("mouseenter",f,!0),e.addEventListener("mouseleave",f,!0),e.addEventListener("mouseout",f,!0),e.addEventListener("mouseover",f,!0),e.addEventListener("touchstart",y,!0),e.addEventListener("touchmove",y,!0),e.addEventListener("touchend",y,!0),e.addEventListener("touchcancel",y,!0))}t.createTouch||(t.createTouch=function(t,n,i,r,c,u,a,d,h){return d!=o&&h!=o||(d=r-e.pageXOffset,h=c-e.pageYOffset),new s(n,i,{pageX:r,pageY:c,screenX:u,screenY:a,clientX:d,clientY:h})}),t.createTouchList||(t.createTouchList=function(){for(var e=new a,t=0;t<arguments.length;t++)e[t]=arguments[t];return e.length=arguments.length,e}),E.multiTouchOffset=75,E.template=function(e){var t=0,n="translate("+(e.clientX-t/2)+"px, "+(e.clientY-t/2)+"px)";return{position:"fixed",left:0,top:0,background:"#fff",border:"solid 1px #999",opacity:.6,borderRadius:"100%",height:t+"px",width:t+"px",padding:0,margin:0,display:"block",overflow:"hidden",pointerEvents:"none",webkitUserSelect:"none",mozUserSelect:"none",userSelect:"none",webkitTransform:n,mozTransform:n,transform:n,zIndex:100}},"function"==typeof define&&define.amd?define((function(){return E})):"undefined"!=typeof module&&module.exports?module.exports=E:e[n]=E})(window,document,"TouchEmulator");