function FastClick(n){var i,t=this;if(this.trackingClick=!1,this.trackingClickStart=0,this.targetElement=null,this.lastTouchIdentifier=this.touchStartY=this.touchStartX=0,this.layer=n,!n||!n.nodeType)throw new TypeError("Layer must be a document node");this.onClick=function(){return FastClick.prototype.onClick.apply(t,arguments)};this.onMouse=function(){return FastClick.prototype.onMouse.apply(t,arguments)};this.onTouchStart=function(){return FastClick.prototype.onTouchStart.apply(t,arguments)};this.onTouchEnd=function(){return FastClick.prototype.onTouchEnd.apply(t,arguments)};this.onTouchCancel=function(){return FastClick.prototype.onTouchCancel.apply(t,arguments)};FastClick.notNeeded(n)||(this.deviceIsAndroid&&(n.addEventListener("mouseover",this.onMouse,!0),n.addEventListener("mousedown",this.onMouse,!0),n.addEventListener("mouseup",this.onMouse,!0)),n.addEventListener("click",this.onClick,!0),n.addEventListener("touchstart",this.onTouchStart,!1),n.addEventListener("touchend",this.onTouchEnd,!1),n.addEventListener("touchcancel",this.onTouchCancel,!1),Event.prototype.stopImmediatePropagation||(n.removeEventListener=function(t,i,r){var u=Node.prototype.removeEventListener;"click"===t?u.call(n,t,i.hijacked||i,r):u.call(n,t,i,r)},n.addEventListener=function(t,i,r){var u=Node.prototype.addEventListener;"click"===t?u.call(n,t,i.hijacked||(i.hijacked=function(n){n.propagationStopped||i(n)}),r):u.call(n,t,i,r)}),"function"==typeof n.onclick&&(i=n.onclick,n.addEventListener("click",function(n){i(n)},!1),n.onclick=null))}FastClick.prototype.deviceIsAndroid=0<navigator.userAgent.indexOf("Android");FastClick.prototype.deviceIsIOS=/iP(ad|hone|od)/.test(navigator.userAgent);FastClick.prototype.deviceIsIOS4=FastClick.prototype.deviceIsIOS&&/OS 4_\d(_\d)?/.test(navigator.userAgent);FastClick.prototype.deviceIsIOSWithBadTarget=FastClick.prototype.deviceIsIOS&&/OS ([6-9]|\d{2})_\d/.test(navigator.userAgent);FastClick.prototype.needsClick=function(n){switch(n.nodeName.toLowerCase()){case"button":case"select":case"textarea":if(n.disabled)return!0;break;case"input":if(this.deviceIsIOS&&"file"===n.type||n.disabled)return!0;break;case"label":case"video":return!0}return/\bneedsclick\b/.test(n.className)};FastClick.prototype.needsFocus=function(n){switch(n.nodeName.toLowerCase()){case"textarea":case"select":return!0;case"input":switch(n.type){case"button":case"checkbox":case"file":case"image":case"radio":case"submit":return!1}return!n.disabled&&!n.readOnly;default:return/\bneedsfocus\b/.test(n.className)}};FastClick.prototype.sendClick=function(n,t){var r,i;document.activeElement&&document.activeElement!==n&&document.activeElement.blur();i=t.changedTouches[0];r=document.createEvent("MouseEvents");r.initMouseEvent("click",!0,!0,window,1,i.screenX,i.screenY,i.clientX,i.clientY,!1,!1,!1,!1,0,null);r.forwardedTouchEvent=!0;n.dispatchEvent(r)};FastClick.prototype.focus=function(n){var t;this.deviceIsIOS&&n.setSelectionRange?(t=n.value.length,n.setSelectionRange(t,t)):n.focus()};FastClick.prototype.updateScrollParent=function(n){var i,t;if(i=n.fastClickScrollParent,!i||!i.contains(n)){t=n;do{if(t.scrollHeight>t.offsetHeight){i=t;n.fastClickScrollParent=t;break}t=t.parentElement}while(t)}i&&(i.fastClickLastScrollTop=i.scrollTop)};FastClick.prototype.getTargetElementFromEventTarget=function(n){return n.nodeType===Node.TEXT_NODE?n.parentNode:n};FastClick.prototype.onTouchStart=function(n){var i,t,r;if(1<n.targetTouches.length)return!0;if(i=this.getTargetElementFromEventTarget(n.target),t=n.targetTouches[0],this.deviceIsIOS){if(r=window.getSelection(),r.rangeCount&&!r.isCollapsed)return!0;if(!this.deviceIsIOS4){if(t.identifier===this.lastTouchIdentifier)return n.preventDefault(),!1;this.lastTouchIdentifier=t.identifier;this.updateScrollParent(i)}}return this.trackingClick=!0,this.trackingClickStart=n.timeStamp,this.targetElement=i,this.touchStartX=t.pageX,this.touchStartY=t.pageY,200>n.timeStamp-this.lastClickTime&&n.preventDefault(),!0};FastClick.prototype.touchHasMoved=function(n){return n=n.changedTouches[0],10<Math.abs(n.pageX-this.touchStartX)||10<Math.abs(n.pageY-this.touchStartY)?!0:!1};FastClick.prototype.findControl=function(n){return void 0!==n.control?n.control:n.htmlFor?document.getElementById(n.htmlFor):n.querySelector("button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea")};FastClick.prototype.onTouchEnd=function(n){var i,r,t;if(t=this.targetElement,this.touchHasMoved(n)&&(this.trackingClick=!1,this.targetElement=null),!this.trackingClick)return!0;if(200>n.timeStamp-this.lastClickTime)return this.cancelNextClick=!0;if(this.lastClickTime=n.timeStamp,i=this.trackingClickStart,this.trackingClick=!1,this.trackingClickStart=0,this.deviceIsIOSWithBadTarget&&(t=n.changedTouches[0],t=document.elementFromPoint(t.pageX-window.pageXOffset,t.pageY-window.pageYOffset)),r=t.tagName.toLowerCase(),"label"===r){if(i=this.findControl(t)){if(this.focus(t),this.deviceIsAndroid)return!1;t=i}}else if(this.needsFocus(t))return 100<n.timeStamp-i||this.deviceIsIOS&&window.top!==window&&"input"===r?(this.targetElement=null,!1):(this.focus(t),this.deviceIsIOS4&&"select"===r||(this.targetElement=null,n.preventDefault()),!1);return this.deviceIsIOS&&!this.deviceIsIOS4&&(i=t.fastClickScrollParent)&&i.fastClickLastScrollTop!==i.scrollTop?!0:(this.needsClick(t)||(n.preventDefault(),this.sendClick(t,n)),!1)};FastClick.prototype.onTouchCancel=function(){this.trackingClick=!1;this.targetElement=null};FastClick.prototype.onMouse=function(n){return!this.targetElement||n.forwardedTouchEvent||!n.cancelable?!0:!this.needsClick(this.targetElement)||this.cancelNextClick?(n.stopImmediatePropagation?n.stopImmediatePropagation():n.propagationStopped=!0,n.stopPropagation(),n.preventDefault(),!1):!0};FastClick.prototype.onClick=function(n){return this.trackingClick?(this.targetElement=null,this.trackingClick=!1,!0):"submit"===n.target.type&&0===n.detail?!0:(n=this.onMouse(n),n||(this.targetElement=null),n)};FastClick.prototype.destroy=function(){var n=this.layer;this.deviceIsAndroid&&(n.removeEventListener("mouseover",this.onMouse,!0),n.removeEventListener("mousedown",this.onMouse,!0),n.removeEventListener("mouseup",this.onMouse,!0));n.removeEventListener("click",this.onClick,!0);n.removeEventListener("touchstart",this.onTouchStart,!1);n.removeEventListener("touchend",this.onTouchEnd,!1);n.removeEventListener("touchcancel",this.onTouchCancel,!1)};FastClick.notNeeded=function(n){var t;if("undefined"==typeof window.ontouchstart)return!0;if(/Chrome\/[0-9]+/.test(navigator.userAgent))if(FastClick.prototype.deviceIsAndroid){if((t=document.querySelector("meta[name=viewport]"))&&-1!==t.content.indexOf("user-scalable=no"))return!0}else return!0;return"none"===n.style.msTouchAction?!0:!1};FastClick.attach=function(n){return new FastClick(n)};"undefined"!=typeof define&&define.amd?define(function(){return FastClick}):"undefined"!=typeof module&&module.exports?(module.exports=FastClick.attach,module.exports.FastClick=FastClick):window.FastClick=FastClick