/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */
class t{constructor(){this.gestureId=0;this.requestedStart=new Map;this.disabledGestures=new Map;this.disabledScroll=new Set}createGesture(t){return new e(this,this.newID(),t.name,t.priority||0,!!t.disableScroll)}createBlocker(t={}){return new s(this,this.newID(),t.disable,!!t.disableScroll)}start(t,e,s){if(!this.canStart(t)){this.requestedStart.delete(e);return false}this.requestedStart.set(e,s);return true}capture(t,e,s){if(!this.start(t,e,s)){return false}const n=this.requestedStart;let i=-1e4;n.forEach((t=>{i=Math.max(i,t)}));if(i===s){this.capturedId=e;n.clear();const s=new CustomEvent("ionGestureCaptured",{detail:{gestureName:t}});document.dispatchEvent(s);return true}n.delete(e);return false}release(t){this.requestedStart.delete(t);if(this.capturedId===t){this.capturedId=undefined}}disableGesture(t,e){let s=this.disabledGestures.get(t);if(s===undefined){s=new Set;this.disabledGestures.set(t,s)}s.add(e)}enableGesture(t,e){const s=this.disabledGestures.get(t);if(s!==undefined){s.delete(e)}}disableScroll(t){this.disabledScroll.add(t);if(this.disabledScroll.size===1){document.body.classList.add(n)}}enableScroll(t){this.disabledScroll.delete(t);if(this.disabledScroll.size===0){document.body.classList.remove(n)}}canStart(t){if(this.capturedId!==undefined){return false}if(this.isDisabled(t)){return false}return true}isCaptured(){return this.capturedId!==undefined}isScrollDisabled(){return this.disabledScroll.size>0}isDisabled(t){const e=this.disabledGestures.get(t);if(e&&e.size>0){return true}return false}newID(){this.gestureId++;return this.gestureId}}class e{constructor(t,e,s,n,i){this.id=e;this.name=s;this.disableScroll=i;this.priority=n*1e6+e;this.ctrl=t}canStart(){if(!this.ctrl){return false}return this.ctrl.canStart(this.name)}start(){if(!this.ctrl){return false}return this.ctrl.start(this.name,this.id,this.priority)}capture(){if(!this.ctrl){return false}const t=this.ctrl.capture(this.name,this.id,this.priority);if(t&&this.disableScroll){this.ctrl.disableScroll(this.id)}return t}release(){if(this.ctrl){this.ctrl.release(this.id);if(this.disableScroll){this.ctrl.enableScroll(this.id)}}}destroy(){this.release();this.ctrl=undefined}}class s{constructor(t,e,s,n){this.id=e;this.disable=s;this.disableScroll=n;this.ctrl=t}block(){if(!this.ctrl){return}if(this.disable){for(const t of this.disable){this.ctrl.disableGesture(t,this.id)}}if(this.disableScroll){this.ctrl.disableScroll(this.id)}}unblock(){if(!this.ctrl){return}if(this.disable){for(const t of this.disable){this.ctrl.enableGesture(t,this.id)}}if(this.disableScroll){this.ctrl.enableScroll(this.id)}}destroy(){this.unblock();this.ctrl=undefined}}const n="backdrop-no-scroll";const i=new t;
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const r=(t,e,s,n)=>{const i=o(t)?{capture:!!n.capture,passive:!!n.passive}:!!n.capture;let r;let f;if(t["__zone_symbol__addEventListener"]){r="__zone_symbol__addEventListener";f="__zone_symbol__removeEventListener"}else{r="addEventListener";f="removeEventListener"}t[r](e,s,i);return()=>{t[f](e,s,i)}};const o=t=>{if(f===undefined){try{const e=Object.defineProperty({},"passive",{get:()=>{f=true}});t.addEventListener("optsTest",(()=>{}),e)}catch(t){f=false}}return!!f};let f;
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const c=2e3;const u=(t,e,s,n,i)=>{let o;let f;let u;let a;let h;let d;let m;let p=0;const v=n=>{p=Date.now()+c;if(!e(n)){return}if(!f&&s){f=r(t,"touchmove",s,i)}if(!u){u=r(n.target,"touchend",y,i)}if(!a){a=r(n.target,"touchcancel",y,i)}};const b=n=>{if(p>Date.now()){return}if(!e(n)){return}if(!d&&s){d=r(l(t),"mousemove",s,i)}if(!m){m=r(l(t),"mouseup",w,i)}};const y=t=>{_();if(n){n(t)}};const w=t=>{S();if(n){n(t)}};const _=()=>{if(f){f()}if(u){u()}if(a){a()}f=u=a=undefined};const S=()=>{if(d){d()}if(m){m()}d=m=undefined};const D=()=>{_();S()};const M=(e=true)=>{if(!e){if(o){o()}if(h){h()}o=h=undefined;D()}else{if(!o){o=r(t,"touchstart",v,i)}if(!h){h=r(t,"mousedown",b,i)}}};const g=()=>{M(false);n=s=e=undefined};return{enable:M,stop:D,destroy:g}};const l=t=>t instanceof Document?t:t.ownerDocument;
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const a=(t,e,s)=>{const n=s*(Math.PI/180);const i=t==="x";const r=Math.cos(n);const o=e*e;let f=0;let c=0;let u=false;let l=0;return{start(t,e){f=t;c=e;l=0;u=true},detect(t,e){if(!u){return false}const s=t-f;const n=e-c;const a=s*s+n*n;if(a<o){return false}const h=Math.sqrt(a);const d=(i?s:n)/h;if(d>r){l=1}else if(d<-r){l=-1}else{l=0}u=false;return true},isGesture(){return l!==0},getDirection(){return l}}};
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */const h=t=>{let e=false;let s=false;let n=true;let r=false;const o=Object.assign({disableScroll:false,direction:"x",gesturePriority:0,passive:true,maxAngle:40,threshold:10},t);const f=o.canStart;const c=o.onWillStart;const l=o.onStart;const h=o.onEnd;const v=o.notCaptured;const b=o.onMove;const y=o.threshold;const w=o.passive;const _=o.blurOnStart;const S={type:"pan",startX:0,startY:0,startTime:0,currentX:0,currentY:0,velocityX:0,velocityY:0,deltaX:0,deltaY:0,currentTime:0,event:undefined,data:undefined};const D=a(o.direction,o.threshold,o.maxAngle);const M=i.createGesture({name:t.gestureName,priority:t.gesturePriority,disableScroll:t.disableScroll});const g=t=>{const e=p(t);if(s||!n){return false}m(t,S);S.startX=S.currentX;S.startY=S.currentY;S.startTime=S.currentTime=e;S.velocityX=S.velocityY=S.deltaX=S.deltaY=0;S.event=t;if(f&&f(S)===false){return false}M.release();if(!M.start()){return false}s=true;if(y===0){return k()}D.start(S.startX,S.startY);return true};const E=t=>{if(e){if(!r&&n){r=true;d(S,t);requestAnimationFrame(G)}return}d(S,t);if(D.detect(S.currentX,S.currentY)){if(!D.isGesture()||!k()){T()}}};const G=()=>{if(!e){return}r=false;if(b){b(S)}};const k=()=>{if(M&&!M.capture()){return false}e=true;n=false;S.startX=S.currentX;S.startY=S.currentY;S.startTime=S.currentTime;if(c){c(S).then(L)}else{L()}return true};const x=()=>{if(typeof document!=="undefined"){const t=document.activeElement;if(t===null||t===void 0?void 0:t.blur){t.blur()}}};const L=()=>{if(_){x()}if(l){l(S)}n=true};const X=()=>{e=false;s=false;r=false;n=true;M.release()};const Y=t=>{const s=e;const i=n;X();if(!i){return}d(S,t);if(s){if(h){h(S)}return}if(v){v(S)}};const C=u(o.el,g,E,Y,{capture:false,passive:w});const T=()=>{X();C.stop();if(v){v(S)}};return{enable(t=true){if(!t){if(e){Y(undefined)}X()}C.enable(t)},destroy(){M.destroy();C.destroy()}}};const d=(t,e)=>{if(!e){return}const s=t.currentX;const n=t.currentY;const i=t.currentTime;m(e,t);const r=t.currentX;const o=t.currentY;const f=t.currentTime=p(e);const c=f-i;if(c>0&&c<100){const e=(r-s)/c;const i=(o-n)/c;t.velocityX=e*.7+t.velocityX*.3;t.velocityY=i*.7+t.velocityY*.3}t.deltaX=r-t.startX;t.deltaY=o-t.startY;t.event=e};const m=(t,e)=>{let s=0;let n=0;if(t){const e=t.changedTouches;if(e&&e.length>0){const t=e[0];s=t.clientX;n=t.clientY}else if(t.pageX!==undefined){s=t.pageX;n=t.pageY}}e.currentX=s;e.currentY=n};const p=t=>t.timeStamp||Date.now();export{i as GESTURE_CONTROLLER,h as createGesture};
//# sourceMappingURL=p-31f845ed.js.map