(function(){/*

 Copyright The Closure Library Authors.
 SPDX-License-Identifier: Apache-2.0
*/
'use strict';var k,l="function"==typeof Object.create?Object.create:function(a){function b(){}b.prototype=a;return new b},m;if("function"==typeof Object.setPrototypeOf)m=Object.setPrototypeOf;else{var n;a:{var p={a:!0},q={};try{q.__proto__=p;n=q.a;break a}catch(a){}n=!1}m=n?function(a,b){a.__proto__=b;if(a.__proto__!==b)throw new TypeError(a+" is not extensible");return a}:null}var r=m,t=this||self;function u(a,b,c){c=void 0===c?null:c;var d=document.createEvent("CustomEvent");d.initCustomEvent(a,!0,!0,c);b.dispatchEvent(d);return d}function v(a){a=a.timeStamp;return 5E12>a?a:a/1E3};var w=["auto","none","pan-x","pan-y"],x=2,y=null,z=!1,A=null,B=null,C=[];function D(a,b){var c=b.changedTouches[0];null==y&&(y=c.identifier,A=c.clientX,B=c.clientY,z=!1);E(b);F(a,"pointerover",b);F(a,"pointerdown",b)}function G(a,b,c){if(!z){var d;if(d=1!=a&&null!=A){var e=c.touches[0];d=Math.abs(e.clientX-A);e=Math.abs(e.clientY-B);d=2==a?d>e:e>d}d?(F(b,"pointercancel",c),z=!0,y=null):(F(b,"pointermove",c),c.preventDefault());B=A=null}}
function H(a,b){z||(E(b),I(b),F(a,"pointerup",b),F(a,"pointerout",b))}function I(a){null!=y&&J(a,function(b){y==b.identifier&&(B=A=y=null)})}function E(a){a=a.changedTouches[0];y==a.identifier&&(a={B:a.clientX,C:a.clientY,I:a.screenX,J:a.screenY},C.push(a),setTimeout(function(b){b=C.indexOf(b);-1<b&&C.splice(b,1)}.bind(null,a),2500))}function K(a,b,c,d){b=Math.abs(b-d);return 25>=Math.abs(a-c)&&25>=b}
function L(a,b,c,d){var e=document.createEvent("Event");e.initEvent(a,!0,!0);e.clientX=c.clientX;e.clientY=c.clientY;e.pointerId=b;e.isPrimary=d;return e}var M={};function N(a,b,c){c.preventDefault();var d;a:{for(d=0;d<C.length;d++)if(K(c.clientX,c.clientY,C[d].B,C[d].C)||K(c.screenX,c.screenY,C[d].I,C[d].J)){d=!0;break a}d=!1}d||a.dispatchEvent(L(b,1,c,!0))}function O(a,b,c){a.dispatchEvent(L(b,c.pointerId,c,c.isPrimary))}
function F(a,b,c){J(c,function(d){var e=a.dispatchEvent,f=String(d.identifier);M[f]||(M[f]=x++);e.call(a,L(b,M[f],d,y==d.identifier))})}function J(a,b){a=a.changedTouches;for(var c=0;c<a.length;c++)b(a[c])};function P(a,b,c,d){return Q(a,c,d,c-b.downX,d-b.downY,c-b.lastX,d-b.lastY)}function Q(a,b,c,d,e,f,h){var g=document.createEvent("Event");g.initEvent(a,!0,!0);g.clientX=b;g.clientY=c;g.dx=d;g.dy=e;g.ddx=f;g.ddy=h;return g};function R(a,b){b=Math.sqrt(a*a+b*b);return 0==b?!1:.92<Math.abs(a/b)}function S(a,b){return Math.abs(a)>=Math.abs(b)?0<a?"swiperight":"swipeleft":0<b?"swipedown":"swipeup"};function T(){var a=HTMLElement.call(this)||this;a.g={};a.h=!1;a.v=u.bind(null,"hover",a);a.m=a.F.bind(a);a.s=a.G.bind(a);a.A=a.K.bind(a);a.u=a.H.bind(a);a.j=a.D.bind(a);a.i=.5;a.l=.1;a.o=!1;return a}var U=HTMLElement;T.prototype=l(U.prototype);T.prototype.constructor=T;if(r)r(T,U);else for(var V in U)if("prototype"!=V)if(Object.defineProperties){var W=Object.getOwnPropertyDescriptor(U,V);W&&Object.defineProperty(T,V,W)}else T[V]=U[V];k=T.prototype;
k.connectedCallback=function(){if(!this.o){var a=1;switch(this.getAttribute("touch-action")){case "auto":a=0;break;case "pan-x":a=2;break;case "pan-y":a=3}a=void 0===a?0:a;var b=w[a];this.setAttribute("touch-action",b);this.style.touchAction=b;this.style.msTouchAction=b;void 0===t.PointerEvent&&(t.navigator.msPointerEnabled?(this.addEventListener("MSPointerOver",O.bind(null,this,"pointerover"),!1),this.addEventListener("MSPointerDown",O.bind(null,this,"pointerdown"),!1),this.addEventListener("MSPointerMove",
O.bind(null,this,"pointermove"),!1),this.addEventListener("MSPointerUp",O.bind(null,this,"pointerup"),!1),this.addEventListener("MSPointerOut",O.bind(null,this,"pointerout"),!1),this.addEventListener("MSPointerCancel",O.bind(null,this,"pointercancel"),!1)):(this.addEventListener("mouseover",N.bind(null,this,"pointerover"),!1),this.addEventListener("mousedown",N.bind(null,this,"pointerdown"),!1),this.addEventListener("mousemove",N.bind(null,this,"pointermove"),!1),this.addEventListener("mouseup",N.bind(null,
this,"pointerup"),!1),this.addEventListener("mouseout",N.bind(null,this,"pointerout"),!1),void 0!==t.ontouchstart&&(this.addEventListener("touchstart",D.bind(null,this),!1),0!=a&&this.addEventListener("touchmove",G.bind(null,a,this),!1),this.addEventListener("touchend",H.bind(null,this),!1))));this.o=!0}this.hasAttribute("swipe-velocity")&&(this.i=parseFloat(this.getAttribute("swipe-velocity")));this.hasAttribute("swipe-distance")&&(this.l=parseFloat(this.getAttribute("swipe-distance")));this.addEventListener("pointerover",
this.v,!1);this.addEventListener("pointerdown",this.m,!1);this.addEventListener("pointermove",this.s,!1);this.addEventListener("pointerup",this.A,!1);this.addEventListener("pointerout",this.u,!1);this.addEventListener("pointercancel",this.j,!1)};
k.disconnectedCallback=function(){this.removeEventListener("pointerover",this.v,!1);this.removeEventListener("pointerdown",this.m,!1);this.removeEventListener("pointermove",this.s,!1);this.removeEventListener("pointerup",this.A,!1);this.removeEventListener("pointerout",this.u,!1);this.removeEventListener("pointercancel",this.j,!1)};
k.F=function(a){if(a.isPrimary){var b=String(a.pointerId);this.g[b]||(this.g[b]={downX:a.clientX,downY:a.clientY,downTime:v(a),lastX:a.clientX,lastY:a.clientY,tracking:!1});this.h=!1}};
k.G=function(a){a.preventDefault();var b=this.g[String(a.pointerId)];if(b){if(10<Math.abs(b.downX-a.clientX)||10<Math.abs(b.downY-a.clientY))this.h=!0;b.tracking||(this.dispatchEvent(Q("trackstart",b.downX,b.downY,0,0,0,0)),b.tracking=!0);this.dispatchEvent(P("track",b,a.clientX,a.clientY));b.lastX=a.clientX;b.lastY=a.clientY}};
k.K=function(a){if(X(this,a)&&!this.h){var b=this.dispatchEvent,c=a.clientX;a=a.clientY;var d=document.createEvent("MouseEvent");d.initMouseEvent("tap",!0,!0,window,0,c,a,c,a,!1,!1,!1,!1,0,null);b.call(this,d)}};k.H=function(a){X(this,a);u("hoverend",this)};
function X(a,b){var c=a.g[String(b.pointerId)];if(c){if(c.tracking){a.dispatchEvent(P("trackend",c,b.clientX,b.clientY));var d=b.clientX-c.downX,e=b.clientY-c.downY;a:{var f=v(b)-c.downTime;var h=a.l;var g=d/f;f=e/f;if(Math.abs(Math.sqrt(g*g+f*f))<a.i)h=!1;else switch(S(d,e)){case "swipeup":case "swipedown":h=R(e,d)&&Math.abs(e)>=a.clientHeight*h;break a;case "swipeleft":case "swiperight":h=R(d,e)&&Math.abs(d)>=a.clientWidth*h;break a;default:h=!1}}h&&u(S(d,e),a)}Y(a,b)}return c}
k.D=function(a){Y(this,a);this.h=!0};function Y(a,b){b=String(b.pointerId);a.g[b]&&delete a.g[b]}customElements.define("gwd-gesture",T);}).call(this);
