forked from taye/interact.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interact.min.js
3 lines (3 loc) · 60.6 KB
/
interact.min.js
1
2
3
/* interact.js v1.2.4 | https://raw.github.com/taye/interact.js/master/LICENSE */
!function(t){"use strict";function e(){}function i(t){if(!t||"object"!=typeof t)return!1;var e=b(t)||ue;return/object|function/.test(typeof e.Element)?t instanceof e.Element:1===t.nodeType&&"string"==typeof t.nodeName}function r(t){return!(!t||!t.Window)&&t instanceof t.Window}function s(t){return!!t&&t instanceof ve}function n(t){return o(t)&&void 0!==typeof t.length&&a(t.splice)}function o(t){return!!t&&"object"==typeof t}function a(t){return"function"==typeof t}function h(t){return"number"==typeof t}function p(t){return"boolean"==typeof t}function l(t){return"string"==typeof t}function c(t){return l(t)?(ge.querySelector(t),!0):!1}function d(t,e){for(var i in e)t[i]=e[i];return t}function u(t,e){t.page=t.page||{},t.page.x=e.page.x,t.page.y=e.page.y,t.client=t.client||{},t.client.x=e.client.x,t.client.y=e.client.y,t.timeStamp=e.timeStamp}function g(t,e,i){e||(e=i.pointerIds.length>1?z(i.pointers):i.pointers[0]),f(e,be,i),t.page.x=be.x,t.page.y=be.y,y(e,be,i),t.client.x=be.x,t.client.y=be.y,t.timeStamp=(new Date).getTime()}function v(t,e,i){t.page.x=i.page.x-e.page.x,t.page.y=i.page.y-e.page.y,t.client.x=i.client.x-e.client.x,t.client.y=i.client.y-e.client.y,t.timeStamp=(new Date).getTime()-e.timeStamp;var r=Math.max(t.timeStamp/1e3,.001);t.page.speed=Se(t.page.x,t.page.y)/r,t.page.vx=t.page.x/r,t.page.vy=t.page.y/r,t.client.speed=Se(t.client.x,t.page.y)/r,t.client.vx=t.client.x/r,t.client.vy=t.client.y/r}function m(t,e,i){return i=i||{},t=t||"page",i.x=e[t+"X"],i.y=e[t+"Y"],i}function f(t,e,i){return e=e||{},t instanceof B?/inertiastart/.test(t.type)?(i=i||t.interaction,d(e,i.inertiaStatus.upCoords.page),e.x+=i.inertiaStatus.sx,e.y+=i.inertiaStatus.sy):(e.x=t.pageX,e.y=t.pageY):He?(m("screen",t,e),e.x+=ue.scrollX,e.y+=ue.scrollY):m("page",t,e),e}function y(t,e,i){return e=e||{},t instanceof B?/inertiastart/.test(t.type)?(d(e,i.inertiaStatus.upCoords.client),e.x+=i.inertiaStatus.sx,e.y+=i.inertiaStatus.sy):(e.x=t.clientX,e.y=t.clientY):m(He?"screen":"client",t,e),e}function x(t){return t=t||ue,{x:t.scrollX||t.document.documentElement.scrollLeft,y:t.scrollY||t.document.documentElement.scrollTop}}function E(t){return h(t.pointerId)?t.pointerId:t.identifier}function S(t){return t instanceof ye?t.correspondingUseElement:t}function b(t){if(r(t))return t;var e=t.ownerDocument||t;return e.defaultView||e.parentWindow||ue}function w(t){var e=We?{x:0,y:0}:x(b(t)),i=t instanceof me?t.getBoundingClientRect():t.getClientRects()[0];return i&&{left:i.left+e.x,right:i.right+e.x,top:i.top+e.y,bottom:i.bottom+e.y,width:i.width||i.right-i.left,height:i.heigh||i.bottom-i.top}}function D(t){var e=[];return n(t)?(e[0]=t[0],e[1]=t[1]):"touchend"===t.type?1===t.touches.length?(e[0]=t.touches[0],e[1]=t.changedTouches[0]):0===t.touches.length&&(e[0]=t.changedTouches[0],e[1]=t.changedTouches[1]):(e[0]=t.touches[0],e[1]=t.touches[1]),e}function z(t){var e=D(t);return{pageX:(e[0].pageX+e[1].pageX)/2,pageY:(e[0].pageY+e[1].pageY)/2,clientX:(e[0].clientX+e[1].clientX)/2,clientY:(e[0].clientY+e[1].clientY)/2}}function T(t){if(t.length||t.touches&&t.touches.length>1){var e=D(t),i=Math.min(e[0].pageX,e[1].pageX),r=Math.min(e[0].pageY,e[1].pageY),s=Math.max(e[0].pageX,e[1].pageX),n=Math.max(e[0].pageY,e[1].pageY);return{x:i,y:r,left:i,top:r,width:s-i,height:n-r}}}function C(t,e){e=e||Me.deltaSource;var i=e+"X",r=e+"Y",s=D(t),n=s[0][i]-s[1][i],o=s[0][r]-s[1][r];return Se(n,o)}function M(t,e,i){i=i||Me.deltaSource;var r=i+"X",s=i+"Y",n=D(t),o=n[0][r]-n[1][r],a=n[0][s]-n[1][s],p=180*Math.atan(a/o)/Math.PI;if(h(e)){var l=p-e,c=l%360;c>315?p-=360+p/360|0:c>135?p-=180+p/360|0:-315>c?p+=360+p/360|0:-135>c&&(p+=180+p/360|0)}return p}function P(t,e){var r=t?t.options.origin:Me.origin;return"parent"===r?r=k(e):"self"===r?r=t.getRect(e):c(r)&&(r=Y(e,r)||{x:0,y:0}),a(r)&&(r=r(t&&e)),i(r)&&(r=w(r)),r.x="x"in r?r.x:r.left,r.y="y"in r?r.y:r.top,r}function O(t,e,i,r){var s=1-t;return s*s*e+2*s*t*i+t*t*r}function _(t,e,i,r,s,n,o){return{x:O(o,t,i,s),y:O(o,e,r,n)}}function A(t,e,i,r){return t/=r,-i*t*(t-2)+e}function X(t,e){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function Y(t,e){for(var r=k(t);i(r);){if(pe(r,e))return r;r=k(r)}return null}function k(t){var e=t.parentNode;if(s(e)){for(;(e=e.host)&&s(e););return e}return e}function I(t,e){return t._context===e.ownerDocument||X(t._context,e)}function R(t,e,r){var s=t.options.ignoreFrom;return s&&i(r)?l(s)?le(r,s,e):i(s)?X(s,r):!1:!1}function F(t,e,r){var s=t.options.allowFrom;return s?i(r)?l(s)?le(r,s,e):i(s)?X(s,r):!1:!1:!0}function q(t,e){if(!e)return!1;var i=e.options.drag.axis;return"xy"===t||"xy"===i||i===t}function N(t,e){var i=t.options;return/^resize/.test(e)&&(e="resize"),i[e].snap&&i[e].snap.enabled}function H(t,e){var i=t.options;return/^resize/.test(e)&&(e="resize"),i[e].restrict&&i[e].restrict.enabled}function W(t,e){var i=t.options;return/^resize/.test(e)&&(e="resize"),i[e].autoScroll&&i[e].autoScroll.enabled}function U(t,e,i){for(var r=t.options,s=r[i.name].max,n=r[i.name].maxPerElement,o=0,a=0,h=0,p=0,l=ze.length;l>p;p++){var c=ze[p],d=c.prepared.name,u=c.interacting();if(u){if(o++,o>=ke)return!1;if(c.target===t){if(a+=d===i.name|0,a>=s)return!1;if(c.element===e&&(h++,d!==i.name||h>=n))return!1}}}return ke>0}function V(t){var e,i,r,s,n,o=t[0],a=o?0:-1,h=[],p=[];for(s=1;s<t.length;s++)if(e=t[s],e&&e!==o)if(o){if(e.parentNode!==e.ownerDocument)if(o.parentNode!==e.ownerDocument){if(!h.length)for(i=o;i.parentNode&&i.parentNode!==i.ownerDocument;)h.unshift(i),i=i.parentNode;if(o instanceof xe&&e instanceof me&&!(e instanceof fe)){if(e===o.parentNode)continue;i=e.ownerSVGElement}else i=e;for(p=[];i.parentNode!==i.ownerDocument;)p.unshift(i),i=i.parentNode;for(n=0;p[n]&&p[n]===h[n];)n++;var l=[p[n-1],p[n],h[n]];for(r=l[0].lastChild;r;){if(r===l[1]){o=e,a=s,h=[];break}if(r===l[2])break;r=r.previousSibling}}else o=e,a=s}else o=e,a=s;return a}function $(){if(this.target=null,this.element=null,this.dropTarget=null,this.dropElement=null,this.prevDropTarget=null,this.prevDropElement=null,this.prepared={name:null,axis:null,edges:null},this.matches=[],this.matchElements=[],this.inertiaStatus={active:!1,smoothEnd:!1,startEvent:null,upCoords:{},xe:0,ye:0,sx:0,sy:0,t0:0,vx0:0,vys:0,duration:0,resumeDx:0,resumeDy:0,lambda_v0:0,one_ve_v0:0,i:null},a(Function.prototype.bind))this.boundInertiaFrame=this.inertiaFrame.bind(this),this.boundSmoothEndFrame=this.smoothEndFrame.bind(this);else{var t=this;this.boundInertiaFrame=function(){return t.inertiaFrame()},this.boundSmoothEndFrame=function(){return t.smoothEndFrame()}}this.activeDrops={dropzones:[],elements:[],rects:[]},this.pointers=[],this.pointerIds=[],this.downTargets=[],this.downTimes=[],this.holdTimers=[],this.prevCoords={page:{x:0,y:0},client:{x:0,y:0},timeStamp:0},this.curCoords={page:{x:0,y:0},client:{x:0,y:0},timeStamp:0},this.startCoords={page:{x:0,y:0},client:{x:0,y:0},timeStamp:0},this.pointerDelta={page:{x:0,y:0,vx:0,vy:0,speed:0},client:{x:0,y:0,vx:0,vy:0,speed:0},timeStamp:0},this.downEvent=null,this.downPointer={},this._eventTarget=null,this._curEventTarget=null,this.prevEvent=null,this.tapTime=0,this.prevTap=null,this.startOffset={left:0,right:0,top:0,bottom:0},this.restrictOffset={left:0,right:0,top:0,bottom:0},this.snapOffsets=[],this.gesture={start:{x:0,y:0},startDistance:0,prevDistance:0,distance:0,scale:1,startAngle:0,prevAngle:0},this.snapStatus={x:0,y:0,dx:0,dy:0,realX:0,realY:0,snappedX:0,snappedY:0,targets:[],locked:!1,changed:!1},this.restrictStatus={dx:0,dy:0,restrictedX:0,restrictedY:0,snap:null,restricted:!1,changed:!1},this.restrictStatus.snap=this.snapStatus,this.pointerIsDown=!1,this.pointerWasMoved=!1,this.gesturing=!1,this.dragging=!1,this.resizing=!1,this.resizeAxes="xy",this.mouse=!1,ze.push(this)}function G(t,e,i){var r,s=0,n=ze.length,o=/mouse/i.test(t.pointerType||e)||4===t.pointerType,a=E(t);if(/down|start/i.test(e))for(s=0;n>s;s++){r=ze[s];var h=i;if(r.inertiaStatus.active&&r.target.options[r.prepared.name].inertia.allowResume&&r.mouse===o)for(;h;){if(h===r.element)return r.pointers[0]&&r.removePointer(r.pointers[0]),r.addPointer(t),r;h=k(h)}}if(o||!Oe&&!_e){for(s=0;n>s;s++)if(ze[s].mouse&&!ze[s].inertiaStatus.active)return ze[s];for(s=0;n>s;s++)if(ze[s].mouse&&(!/down/.test(e)||!ze[s].inertiaStatus.active))return r;return r=new $,r.mouse=!0,r}for(s=0;n>s;s++)if(he(ze[s].pointerIds,a))return ze[s];if(/up|end|out/i.test(e))return null;for(s=0;n>s;s++)if(r=ze[s],!(r.prepared.name&&!r.target.options.gesture.enabled||r.interacting()||!o&&r.mouse))return r.addPointer(t),r;return new $}function L(t){return function(e){var i,r,s=S(e.path?e.path[0]:e.target),n=S(e.currentTarget);if(Oe&&/touch/.test(e.type))for(Ye=(new Date).getTime(),r=0;r<e.changedTouches.length;r++){var o=e.changedTouches[r];i=G(o,e.type,s),i&&(i._updateEventTargets(s,n),i[t](o,e,s,n))}else{if(!_e&&/mouse/.test(e.type)){for(r=0;r<ze.length;r++)if(!ze[r].mouse&&ze[r].pointerIsDown)return;if((new Date).getTime()-Ye<500)return}if(i=G(e,e.type,s),!i)return;i._updateEventTargets(s,n),i[t](e,e,s,n)}}}function B(t,e,i,r,s,n){var o,a,h=t.target,p=t.snapStatus,l=t.restrictStatus,c=t.pointers,u=(h&&h.options||Me).deltaSource,g=u+"X",v=u+"Y",m=h?h.options:Me,f=P(h,s),y="start"===r,x="end"===r,E=y?t.startCoords:t.curCoords;s=s||t.element,a=d({},E.page),o=d({},E.client),a.x-=f.x,a.y-=f.y,o.x-=f.x,o.y-=f.y;var S=m[i].snap&&m[i].snap.relativePoints;!N(h,i)||y&&S&&S.length||(this.snap={range:p.range,locked:p.locked,x:p.snappedX,y:p.snappedY,realX:p.realX,realY:p.realY,dx:p.dx,dy:p.dy},p.locked&&(a.x+=p.dx,a.y+=p.dy,o.x+=p.dx,o.y+=p.dy)),!H(h,i)||y&&m[i].restrict.elementRect||!l.restricted||(a.x+=l.dx,a.y+=l.dy,o.x+=l.dx,o.y+=l.dy,this.restrict={dx:l.dx,dy:l.dy}),this.pageX=a.x,this.pageY=a.y,this.clientX=o.x,this.clientY=o.y,this.x0=t.startCoords.page.x,this.y0=t.startCoords.page.y,this.clientX0=t.startCoords.client.x,this.clientY0=t.startCoords.client.y,this.ctrlKey=e.ctrlKey,this.altKey=e.altKey,this.shiftKey=e.shiftKey,this.metaKey=e.metaKey,this.button=e.button,this.target=s,this.t0=t.downTimes[0],this.type=i+(r||""),this.interaction=t,this.interactable=h;var b=t.inertiaStatus;if(b.active&&(this.detail="inertia"),n&&(this.relatedTarget=n),x?"client"===u?(this.dx=o.x-t.startCoords.client.x,this.dy=o.y-t.startCoords.client.y):(this.dx=a.x-t.startCoords.page.x,this.dy=a.y-t.startCoords.page.y):y?(this.dx=0,this.dy=0):"inertiastart"===r?(this.dx=t.prevEvent.dx,this.dy=t.prevEvent.dy):"client"===u?(this.dx=o.x-t.prevEvent.clientX,this.dy=o.y-t.prevEvent.clientY):(this.dx=a.x-t.prevEvent.pageX,this.dy=a.y-t.prevEvent.pageY),t.prevEvent&&"inertia"===t.prevEvent.detail&&!b.active&&m[i].inertia&&m[i].inertia.zeroResumeDelta&&(b.resumeDx+=this.dx,b.resumeDy+=this.dy,this.dx=this.dy=0),"resize"===i&&t.resizeAxes?m.resize.square?("y"===t.resizeAxes?this.dx=this.dy:this.dy=this.dx,this.axes="xy"):(this.axes=t.resizeAxes,"x"===t.resizeAxes?this.dy=0:"y"===t.resizeAxes&&(this.dx=0)):"gesture"===i&&(this.touches=[c[0],c[1]],y?(this.distance=C(c,u),this.box=T(c),this.scale=1,this.ds=0,this.angle=M(c,void 0,u),this.da=0):x||e instanceof B?(this.distance=t.prevEvent.distance,this.box=t.prevEvent.box,this.scale=t.prevEvent.scale,this.ds=this.scale-1,this.angle=t.prevEvent.angle,this.da=this.angle-t.gesture.startAngle):(this.distance=C(c,u),this.box=T(c),this.scale=this.distance/t.gesture.startDistance,this.angle=M(c,t.gesture.prevAngle,u),this.ds=this.scale-t.gesture.prevScale,this.da=this.angle-t.gesture.prevAngle)),y)this.timeStamp=t.downTimes[0],this.dt=0,this.duration=0,this.speed=0,this.velocityX=0,this.velocityY=0;else if("inertiastart"===r)this.timeStamp=t.prevEvent.timeStamp,this.dt=t.prevEvent.dt,this.duration=t.prevEvent.duration,this.speed=t.prevEvent.speed,this.velocityX=t.prevEvent.velocityX,this.velocityY=t.prevEvent.velocityY;else if(this.timeStamp=(new Date).getTime(),this.dt=this.timeStamp-t.prevEvent.timeStamp,this.duration=this.timeStamp-t.downTimes[0],e instanceof B){var w=this[g]-t.prevEvent[g],D=this[v]-t.prevEvent[v],z=this.dt/1e3;this.speed=Se(w,D)/z,this.velocityX=w/z,this.velocityY=D/z}else this.speed=t.pointerDelta[u].speed,this.velocityX=t.pointerDelta[u].vx,this.velocityY=t.pointerDelta[u].vy;if((x||"inertiastart"===r)&&t.prevEvent.speed>600&&this.timeStamp-t.prevEvent.timeStamp<150){var O=180*Math.atan2(t.prevEvent.velocityY,t.prevEvent.velocityX)/Math.PI,_=22.5;0>O&&(O+=360);var A=O>=135-_&&225+_>O,X=O>=225-_&&315+_>O,Y=!A&&(O>=315-_||45+_>O),k=!X&&O>=45-_&&135+_>O;this.swipe={up:X,down:k,left:A,right:Y,angle:O,speed:t.prevEvent.speed,velocity:{x:t.prevEvent.velocityX,y:t.prevEvent.velocityY}}}}function K(){this.originalEvent.preventDefault()}function j(t){var e="";if("drag"===t.name&&(e=Ie.drag),"resize"===t.name)if(t.axis)e=Ie[t.name+t.axis];else if(t.edges){for(var i="resize",r=["top","bottom","left","right"],s=0;4>s;s++)t.edges[r[s]]&&(i+=r[s]);e=Ie[i]}return e}function J(t,e,r,s,n,o){if(!e)return!1;if(e===!0){var a=h(o.width)?o.width:o.right-o.left,p=h(o.height)?o.height:o.bottom-o.top;if(0>a&&("left"===t?t="right":"right"===t&&(t="left")),0>p&&("top"===t?t="bottom":"bottom"===t&&(t="top")),"left"===t)return r.x<(a>=0?o.left:o.right)+Ae;if("top"===t)return r.y<(p>=0?o.top:o.bottom)+Ae;if("right"===t)return r.x>(a>=0?o.right:o.left)-Ae;if("bottom"===t)return r.y>(p>=0?o.bottom:o.top)-Ae}return i(s)?i(e)?e===s:le(s,e,n):!1}function Q(t,e,i){var r,s=this.getRect(i),n=!1,a=null,h=null,p=d({},e.curCoords.page),l=this.options;if(!s)return null;if(Re.resize&&l.resize.enabled){var c=l.resize;if(r={left:!1,right:!1,top:!1,bottom:!1},o(c.edges)){for(var u in r)r[u]=J(u,c.edges[u],p,e._eventTarget,i,s);r.left=r.left&&!r.right,r.top=r.top&&!r.bottom,n=r.left||r.right||r.top||r.bottom}else{var g="y"!==l.resize.axis&&p.x>s.right-Ae,v="x"!==l.resize.axis&&p.y>s.bottom-Ae;n=g||v,h=(g?"x":"")+(v?"y":"")}}return a=n?"resize":Re.drag&&l.drag.enabled?"drag":null,Re.gesture&&e.pointerIds.length>=2&&!e.dragging&&!e.resizing&&(a="gesture"),a?{name:a,axis:h,edges:r}:null}function Z(t,e){if(!o(t))return null;var i=t.name,r=e.options;return("resize"===i&&r.resize.enabled||"drag"===i&&r.drag.enabled||"gesture"===i&&r.gesture.enabled)&&Re[i]?(("resize"===i||"resizeyx"===i)&&(i="resizexy"),t):null}function te(t,e){var r={},s=Ce[t.type],n=S(t.path?t.path[0]:t.target),o=n;e=e?!0:!1;for(var a in t)r[a]=t[a];for(r.originalEvent=t,r.preventDefault=K;i(o);){for(var h=0;h<s.selectors.length;h++){var p=s.selectors[h],l=s.contexts[h];if(pe(o,p)&&X(l,n)&&X(l,o)){var c=s.listeners[h];r.currentTarget=o;for(var d=0;d<c.length;d++)c[d][1]===e&&c[d][0](r)}}o=k(o)}}function ee(t){return te.call(this,t,!0)}function ie(t,e){return De.get(t,e)||new re(t,e)}function re(t,e){this._element=t,this._iEvents=this._iEvents||{};var r;if(c(t)){this.selector=t;var s=e&&e.context;r=s?b(s):ue,s&&(r.Node?s instanceof r.Node:i(s)||s===r.document)&&(this._context=s)}else r=b(t),i(t,r)&&(Ee?(Ge.add(this._element,ce.down,Le.pointerDown),Ge.add(this._element,ce.move,Le.pointerHover)):(Ge.add(this._element,"mousedown",Le.pointerDown),Ge.add(this._element,"mousemove",Le.pointerHover),Ge.add(this._element,"touchstart",Le.pointerDown),Ge.add(this._element,"touchmove",Le.pointerHover)));this._doc=r.document,he(we,this._doc)||oe(this._doc),De.push(this),this.set(e)}function se(t,e){var i=!1;return function(){return i||(ue.console.warn(e),i=!0),t.apply(this,arguments)}}function ne(t){for(var e=0;e<ze.length;e++)ze[e].pointerEnd(t,t)}function oe(t){if(!he(we,t)){var e=t.defaultView||t.parentWindow;for(var i in Ce)Ge.add(t,i,te),Ge.add(t,i,ee,!0);Ee?(ce=Ee===e.MSPointerEvent?{up:"MSPointerUp",down:"MSPointerDown",over:"mouseover",out:"mouseout",move:"MSPointerMove",cancel:"MSPointerCancel"}:{up:"pointerup",down:"pointerdown",over:"pointerover",out:"pointerout",move:"pointermove",cancel:"pointercancel"},Ge.add(t,ce.down,Le.selectorDown),Ge.add(t,ce.move,Le.pointerMove),Ge.add(t,ce.over,Le.pointerOver),Ge.add(t,ce.out,Le.pointerOut),Ge.add(t,ce.up,Le.pointerUp),Ge.add(t,ce.cancel,Le.pointerCancel),Ge.add(t,ce.move,Pe.edgeMove)):(Ge.add(t,"mousedown",Le.selectorDown),Ge.add(t,"mousemove",Le.pointerMove),Ge.add(t,"mouseup",Le.pointerUp),Ge.add(t,"mouseover",Le.pointerOver),Ge.add(t,"mouseout",Le.pointerOut),Ge.add(t,"touchstart",Le.selectorDown),Ge.add(t,"touchmove",Le.pointerMove),Ge.add(t,"touchend",Le.pointerUp),Ge.add(t,"touchcancel",Le.pointerCancel),Ge.add(t,"mousemove",Pe.edgeMove),Ge.add(t,"touchmove",Pe.edgeMove)),Ge.add(e,"blur",ne);try{if(e.frameElement){var r=e.frameElement.ownerDocument,s=r.defaultView;Ge.add(r,"mouseup",Le.pointerEnd),Ge.add(r,"touchend",Le.pointerEnd),Ge.add(r,"touchcancel",Le.pointerEnd),Ge.add(r,"pointerup",Le.pointerEnd),Ge.add(r,"MSPointerUp",Le.pointerEnd),Ge.add(s,"blur",ne)}}catch(n){ie.windowParentError=n}Ge.useAttachEvent&&(Ge.add(t,"selectstart",function(t){var e=ze[0];e.currentAction()&&e.checkAndPreventDefault(t)}),Ge.add(t,"dblclick",L("ie8Dblclick"))),we.push(t)}}function ae(t,e){for(var i=0,r=t.length;r>i;i++)if(t[i]===e)return i;return-1}function he(t,e){return-1!==ae(t,e)}function pe(e,i,r){return de?de(e,i,r):(ue!==t&&(i=i.replace(/\/deep\//g," ")),e[Ue](i))}function le(t,e,r){for(;i(t);){if(pe(t,e))return!0;if(t=k(t),t===r)return pe(t,e)}return!1}var ce,de,ue=function(){var e=t.document.createTextNode("");return e.ownerDocument!==t.document&&"function"==typeof t.wrap&&t.wrap(e)===e?t.wrap(t):t}(),ge=ue.document,ve=ue.DocumentFragment||e,me=ue.SVGElement||e,fe=ue.SVGSVGElement||e,ye=ue.SVGElementInstance||e,xe=ue.HTMLElement||ue.Element,Ee=ue.PointerEvent||ue.MSPointerEvent,Se=Math.hypot||function(t,e){return Math.sqrt(t*t+e*e)},be={},we=[],De=[],ze=[],Te=!1,Ce={},Me={base:{accept:null,actionChecker:null,styleCursor:!0,preventDefault:"auto",origin:{x:0,y:0},deltaSource:"page",allowFrom:null,ignoreFrom:null,_context:ge,dropChecker:null},drag:{enabled:!1,manualStart:!0,max:1/0,maxPerElement:1,snap:null,restrict:null,inertia:null,autoScroll:null,axis:"xy"},drop:{enabled:!1,accept:null,overlap:"pointer"},resize:{enabled:!1,manualStart:!1,max:1/0,maxPerElement:1,snap:null,restrict:null,inertia:null,autoScroll:null,square:!1,axis:"xy",edges:null,invert:"none"},gesture:{manualStart:!1,enabled:!1,max:1/0,maxPerElement:1,restrict:null},perAction:{manualStart:!1,max:1/0,maxPerElement:1,snap:{enabled:!1,endOnly:!1,range:1/0,targets:null,offsets:null,relativePoints:null},restrict:{enabled:!1,endOnly:!1},autoScroll:{enabled:!1,container:null,margin:60,speed:300},inertia:{enabled:!1,resistance:10,minSpeed:100,endSpeed:10,allowResume:!0,zeroResumeDelta:!0,smoothEndDuration:300}},_holdDuration:600},Pe={interaction:null,i:null,x:0,y:0,scroll:function(){var t=Pe.interaction.target.options[Pe.interaction.prepared.name].autoScroll,e=t.container||b(Pe.interaction.element),i=(new Date).getTime(),s=(i-Pe.prevTime)/1e3,n=t.speed*s;n>=1&&(r(e)?e.scrollBy(Pe.x*n,Pe.y*n):e&&(e.scrollLeft+=Pe.x*n,e.scrollTop+=Pe.y*n),Pe.prevTime=i),Pe.isScrolling&&($e(Pe.i),Pe.i=Ve(Pe.scroll))},edgeMove:function(t){for(var e,i,s=!1,n=0;n<ze.length;n++)if(e=ze[n],e.interacting()&&W(e.target,e.prepared.name)){i=e.target,s=!0;break}if(s){var o,a,h,p,l=i.options[e.prepared.name].autoScroll,c=l.container||b(e.element);if(r(c))p=t.clientX<Pe.margin,o=t.clientY<Pe.margin,a=t.clientX>c.innerWidth-Pe.margin,h=t.clientY>c.innerHeight-Pe.margin;else{var d=w(c);p=t.clientX<d.left+Pe.margin,o=t.clientY<d.top+Pe.margin,a=t.clientX>d.right-Pe.margin,h=t.clientY>d.bottom-Pe.margin}Pe.x=a?1:p?-1:0,Pe.y=h?1:o?-1:0,Pe.isScrolling||(Pe.margin=l.margin,Pe.speed=l.speed,Pe.start(e))}},isScrolling:!1,prevTime:0,start:function(t){Pe.isScrolling=!0,$e(Pe.i),Pe.interaction=t,Pe.prevTime=(new Date).getTime(),Pe.i=Ve(Pe.scroll)},stop:function(){Pe.isScrolling=!1,$e(Pe.i)}},Oe="ontouchstart"in ue||ue.DocumentTouch&&ge instanceof ue.DocumentTouch,_e=!!Ee,Ae=Oe||_e?20:10,Xe=1,Ye=0,ke=1/0,Ie=ge.all&&!ue.atob?{drag:"move",resizex:"e-resize",resizey:"s-resize",resizexy:"se-resize",resizetop:"n-resize",resizeleft:"w-resize",resizebottom:"s-resize",resizeright:"e-resize",resizetopleft:"se-resize",resizebottomright:"se-resize",resizetopright:"ne-resize",resizebottomleft:"ne-resize",gesture:""}:{drag:"move",resizex:"ew-resize",resizey:"ns-resize",resizexy:"nwse-resize",resizetop:"ns-resize",resizeleft:"ew-resize",resizebottom:"ns-resize",resizeright:"ew-resize",resizetopleft:"nwse-resize",resizebottomright:"nwse-resize",resizetopright:"nesw-resize",resizebottomleft:"nesw-resize",gesture:""},Re={drag:!0,resize:!0,gesture:!0},Fe="onmousewheel"in ge?"mousewheel":"wheel",qe=["dragstart","dragmove","draginertiastart","dragend","dragenter","dragleave","dropactivate","dropdeactivate","dropmove","drop","resizestart","resizemove","resizeinertiastart","resizeend","gesturestart","gesturemove","gestureinertiastart","gestureend","down","move","up","cancel","tap","doubletap","hold"],Ne={},He="Opera"==navigator.appName&&Oe&&navigator.userAgent.match("Presto"),We=/iP(hone|od|ad)/.test(navigator.platform)&&/OS [1-7][^\d]/.test(navigator.appVersion),Ue="matches"in Element.prototype?"matches":"webkitMatchesSelector"in Element.prototype?"webkitMatchesSelector":"mozMatchesSelector"in Element.prototype?"mozMatchesSelector":"oMatchesSelector"in Element.prototype?"oMatchesSelector":"msMatchesSelector",Ve=t.requestAnimationFrame,$e=t.cancelAnimationFrame,Ge=function(){function t(t,e,a,d){var u=ae(p,t),g=l[u];if(g||(g={events:{},typeCount:0},u=p.push(t)-1,l.push(g),c.push(n?{supplied:[],wrapped:[],useCount:[]}:null)),g.events[e]||(g.events[e]=[],g.typeCount++),!he(g.events[e],a)){var v;if(n){var m=c[u],f=ae(m.supplied,a),y=m.wrapped[f]||function(e){e.immediatePropagationStopped||(e.target=e.srcElement,e.currentTarget=t,e.preventDefault=e.preventDefault||i,e.stopPropagation=e.stopPropagation||r,e.stopImmediatePropagation=e.stopImmediatePropagation||s,/mouse|click/.test(e.type)&&(e.pageX=e.clientX+b(t).document.documentElement.scrollLeft,e.pageY=e.clientY+b(t).document.documentElement.scrollTop),a(e))};v=t[o](h+e,y,Boolean(d)),-1===f?(m.supplied.push(a),m.wrapped.push(y),m.useCount.push(1)):m.useCount[f]++}else v=t[o](e,a,d||!1);return g.events[e].push(a),v}}function e(t,i,r,s){var o,d,u,g=ae(p,t),v=l[g],m=r;if(v&&v.events)if(n&&(d=c[g],u=ae(d.supplied,r),m=d.wrapped[u]),"all"!==i){if(v.events[i]){var f=v.events[i].length;if("all"===r)for(o=0;f>o;o++)e(t,i,v.events[i][o],Boolean(s));else for(o=0;f>o;o++)if(v.events[i][o]===r){t[a](h+i,m,s||!1),v.events[i].splice(o,1),n&&d&&(d.useCount[u]--,0===d.useCount[u]&&(d.supplied.splice(u,1),d.wrapped.splice(u,1),d.useCount.splice(u,1)));break}v.events[i]&&0===v.events[i].length&&(v.events[i]=null,v.typeCount--)}v.typeCount||(l.splice(g),p.splice(g),c.splice(g))}else for(i in v.events)v.events.hasOwnProperty(i)&&e(t,i,"all")}function i(){this.returnValue=!1}function r(){this.cancelBubble=!0}function s(){this.cancelBubble=!0,this.immediatePropagationStopped=!0}var n="attachEvent"in ue&&!("addEventListener"in ue),o=n?"attachEvent":"addEventListener",a=n?"detachEvent":"removeEventListener",h=n?"on":"",p=[],l=[],c=[];return{add:t,remove:e,useAttachEvent:n,_elements:p,_targets:l,_attachedListeners:c}}();$.prototype={getPageXY:function(t,e){return f(t,e,this)},getClientXY:function(t,e){return y(t,e,this)},setEventXY:function(t,e){return g(t,e,this)},pointerOver:function(t,e,i){function r(t,e){t&&I(t,i)&&!R(t,i,i)&&F(t,i,i)&&pe(i,e)&&(s.push(t),n.push(i))}if(!this.prepared.name&&this.mouse){var s=[],n=[],o=this.element;this.addPointer(t),!this.target||!R(this.target,this.element,i)&&F(this.target,this.element,i)||(this.target=null,this.element=null,this.matches=[],this.matchElements=[]);var a=De.get(i),h=a&&!R(a,i,i)&&F(a,i,i)&&Z(a.getAction(t,this,i),a);h&&!U(a,i,h)&&(h=null),h?(this.target=a,this.element=i,this.matches=[],this.matchElements=[]):(De.forEachSelector(r),this.validateSelector(t,s,n)?(this.matches=s,this.matchElements=n,this.pointerHover(t,e,this.matches,this.matchElements),Ge.add(i,Ee?ce.move:"mousemove",Le.pointerHover)):this.target&&(X(o,i)?(this.pointerHover(t,e,this.matches,this.matchElements),Ge.add(this.element,Ee?ce.move:"mousemove",Le.pointerHover)):(this.target=null,this.element=null,this.matches=[],this.matchElements=[])))}},pointerHover:function(t,e,i,r,s,n){var o=this.target;if(!this.prepared.name&&this.mouse){var a;this.setEventXY(this.curCoords,t),s?a=this.validateSelector(t,s,n):o&&(a=Z(o.getAction(this.pointers[0],this,this.element),this.target)),o&&o.options.styleCursor&&(o._doc.documentElement.style.cursor=a?j(a):"")}else this.prepared.name&&this.checkAndPreventDefault(e,o,this.element)},pointerOut:function(t,e,i){this.prepared.name||(De.get(i)||Ge.remove(i,Ee?ce.move:"mousemove",Le.pointerHover),this.target&&this.target.options.styleCursor&&!this.interacting()&&(this.target._doc.documentElement.style.cursor=""))},selectorDown:function(t,e,r,s){function n(t,e,i){var s=de?i.querySelectorAll(e):void 0;I(t,p)&&!R(t,p,r)&&F(t,p,r)&&pe(p,e,s)&&(a.matches.push(t),a.matchElements.push(p))}var o,a=this,h=Ge.useAttachEvent?d({},e):e,p=r,l=this.addPointer(t);if(this.holdTimers[l]=setTimeout(function(){a.pointerHold(Ge.useAttachEvent?h:t,h,r,s)},Me._holdDuration),this.pointerIsDown=!0,this.inertiaStatus.active&&this.target.selector)for(;i(p);){if(p===this.element&&Z(this.target.getAction(t,this,this.element),this.target).name===this.prepared.name)return $e(this.inertiaStatus.i),this.inertiaStatus.active=!1,void this.collectEventTargets(t,e,r,"down");p=k(p)}if(this.interacting())return void this.collectEventTargets(t,e,r,"down");for(this.setEventXY(this.curCoords,t);i(p)&&!o;)this.matches=[],this.matchElements=[],De.forEachSelector(n),o=this.validateSelector(t,this.matches,this.matchElements),p=k(p);return o?(this.prepared.name=o.name,this.prepared.axis=o.axis,this.prepared.edges=o.edges,this.collectEventTargets(t,e,r,"down"),this.pointerDown(t,e,r,s,o)):(this.downTimes[l]=(new Date).getTime(),this.downTargets[l]=r,this.downEvent=e,d(this.downPointer,t),u(this.prevCoords,this.curCoords),this.pointerWasMoved=!1,void this.collectEventTargets(t,e,r,"down"))},pointerDown:function(t,e,i,r,s){if(!s&&!this.inertiaStatus.active&&this.pointerWasMoved&&this.prepared.name)return void this.checkAndPreventDefault(e,this.target,this.element);this.pointerIsDown=!0;var n,o=this.addPointer(t);if(this.pointerIds.length<2&&!this.target||!this.prepared.name){var a=De.get(r);a&&!R(a,r,i)&&F(a,r,i)&&(n=Z(s||a.getAction(t,this,r),a,i))&&U(a,r,n)&&(this.target=a,this.element=r)}var h=this.target,p=h&&h.options;if(h&&!this.interacting()){if(n=n||Z(s||h.getAction(t,this,r),h,this.element),this.setEventXY(this.startCoords),!n)return;p.styleCursor&&(h._doc.documentElement.style.cursor=j(n)),this.resizeAxes="resize"===n.name?n.axis:null,"gesture"===n&&this.pointerIds.length<2&&(n=null),this.prepared.name=n.name,this.prepared.axis=n.axis,this.prepared.edges=n.edges,this.snapStatus.snappedX=this.snapStatus.snappedY=this.restrictStatus.restrictedX=this.restrictStatus.restrictedY=0/0,this.downTimes[o]=(new Date).getTime(),this.downTargets[o]=i,this.downEvent=e,d(this.downPointer,t),this.setEventXY(this.prevCoords),this.pointerWasMoved=!1,this.checkAndPreventDefault(e,h,this.element)}else this.inertiaStatus.active&&r===this.element&&Z(h.getAction(t,this,this.element),h).name===this.prepared.name&&($e(this.inertiaStatus.i),this.inertiaStatus.active=!1,this.checkAndPreventDefault(e,h,this.element))},setModifications:function(t,e){var i=this.target,r=!0,s=N(i,this.prepared.name)&&(!i.options[this.prepared.name].snap.endOnly||e),n=H(i,this.prepared.name)&&(!i.options[this.prepared.name].restrict.endOnly||e);return s?this.setSnapping(t):this.snapStatus.locked=!1,n?this.setRestriction(t):this.restrictStatus.restricted=!1,s&&this.snapStatus.locked&&!this.snapStatus.changed?r=n&&this.restrictStatus.restricted&&this.restrictStatus.changed:n&&this.restrictStatus.restricted&&!this.restrictStatus.changed&&(r=!1),r},setStartOffsets:function(t,e,i){var r,s,n=e.getRect(i),o=P(e,i),a=e.options[this.prepared.name].snap,h=e.options[this.prepared.name].restrict;n?(this.startOffset.left=this.startCoords.page.x-n.left,this.startOffset.top=this.startCoords.page.y-n.top,this.startOffset.right=n.right-this.startCoords.page.x,this.startOffset.bottom=n.bottom-this.startCoords.page.y,r="width"in n?n.width:n.right-n.left,s="height"in n?n.height:n.bottom-n.top):this.startOffset.left=this.startOffset.top=this.startOffset.right=this.startOffset.bottom=0,this.snapOffsets.splice(0);var p=a&&"startCoords"===a.offset?{x:this.startCoords.page.x-o.x,y:this.startCoords.page.y-o.y}:a&&a.offset||{x:0,y:0};if(n&&a&&a.relativePoints&&a.relativePoints.length)for(var l=0;l<a.relativePoints.length;l++)this.snapOffsets.push({x:this.startOffset.left-r*a.relativePoints[l].x+p.x,y:this.startOffset.top-s*a.relativePoints[l].y+p.y});else this.snapOffsets.push(p);n&&h.elementRect?(this.restrictOffset.left=this.startOffset.left-r*h.elementRect.left,this.restrictOffset.top=this.startOffset.top-s*h.elementRect.top,this.restrictOffset.right=this.startOffset.right-r*(1-h.elementRect.right),this.restrictOffset.bottom=this.startOffset.bottom-s*(1-h.elementRect.bottom)):this.restrictOffset.left=this.restrictOffset.top=this.restrictOffset.right=this.restrictOffset.bottom=0},start:function(t,e,i){this.interacting()||!this.pointerIsDown||this.pointerIds.length<("gesture"===t.name?2:1)||(-1===ae(ze,this)&&ze.push(this),this.prepared.name=t.name,this.prepared.axis=t.axis,this.prepared.edges=t.edges,this.target=e,this.element=i,this.setStartOffsets(t.name,e,i),this.setModifications(this.startCoords.page),this.prevEvent=this[this.prepared.name+"Start"](this.downEvent))},pointerMove:function(t,e,r,s,n){this.recordPointer(t),this.setEventXY(this.curCoords,t instanceof B?this.inertiaStatus.startEvent:void 0);var o,a,h=this.curCoords.page.x===this.prevCoords.page.x&&this.curCoords.page.y===this.prevCoords.page.y&&this.curCoords.client.x===this.prevCoords.client.x&&this.curCoords.client.y===this.prevCoords.client.y,p=this.mouse?0:ae(this.pointerIds,E(t));if(this.pointerIsDown&&!this.pointerWasMoved&&(o=this.curCoords.client.x-this.startCoords.client.x,a=this.curCoords.client.y-this.startCoords.client.y,this.pointerWasMoved=Se(o,a)>Xe),h||this.pointerIsDown&&!this.pointerWasMoved||(this.pointerIsDown&&clearTimeout(this.holdTimers[p]),this.collectEventTargets(t,e,r,"move")),this.pointerIsDown){if(h&&this.pointerWasMoved&&!n)return void this.checkAndPreventDefault(e,this.target,this.element);if(v(this.pointerDelta,this.prevCoords,this.curCoords),this.prepared.name){if(this.pointerWasMoved&&(!this.inertiaStatus.active||t instanceof B&&/inertiastart/.test(t.type))){if(!this.interacting()&&(v(this.pointerDelta,this.prevCoords,this.curCoords),"drag"===this.prepared.name)){var l=Math.abs(o),c=Math.abs(a),d=this.target.options.drag.axis,g=l>c?"x":c>l?"y":"xy";if("xy"!==g&&"xy"!==d&&d!==g){this.prepared.name=null;for(var m=r;i(m);){var f=De.get(m);if(f&&f!==this.target&&!f.options.drag.manualStart&&"drag"===f.getAction(this.downPointer,this,m).name&&q(g,f)){this.prepared.name="drag",this.target=f,this.element=m;break}m=k(m)}if(!this.prepared.name){var y=function(t,e,i){var s=de?i.querySelectorAll(e):void 0;if(t!==this.target)return I(t,r)&&!t.options.drag.manualStart&&!R(t,m,r)&&F(t,m,r)&&pe(m,e,s)&&"drag"===t.getAction(this.downPointer,this,m).name&&q(g,t)&&U(t,m,"drag")?t:void 0};for(m=r;i(m);){var x=De.forEachSelector(y);if(x){this.prepared.name="drag",this.target=x,this.element=m;break}m=k(m)}}}}var S=!!this.prepared.name&&!this.interacting();if(S&&(this.target.options[this.prepared.name].manualStart||!U(this.target,this.element,this.prepared)))return void this.stop();if(this.prepared.name&&this.target){S&&this.start(this.prepared,this.target,this.element);var b=this.setModifications(this.curCoords.page,n);(b||S)&&(this.prevEvent=this[this.prepared.name+"Move"](e)),this.checkAndPreventDefault(e,this.target,this.element)}}u(this.prevCoords,this.curCoords),(this.dragging||this.resizing)&&Pe.edgeMove(e)}}},dragStart:function(t){var e=new B(this,t,"drag","start",this.element);
this.dragging=!0,this.target.fire(e),this.activeDrops.dropzones=[],this.activeDrops.elements=[],this.activeDrops.rects=[],this.dynamicDrop||this.setActiveDrops(this.element);var i=this.getDropEvents(t,e);return i.activate&&this.fireActiveDrops(i.activate),e},dragMove:function(t){var e=this.target,i=new B(this,t,"drag","move",this.element),r=this.element,s=this.getDrop(i,r);this.dropTarget=s.dropzone,this.dropElement=s.element;var n=this.getDropEvents(t,i);return e.fire(i),n.leave&&this.prevDropTarget.fire(n.leave),n.enter&&this.dropTarget.fire(n.enter),n.move&&this.dropTarget.fire(n.move),this.prevDropTarget=this.dropTarget,this.prevDropElement=this.dropElement,i},resizeStart:function(t){var e=new B(this,t,"resize","start",this.element);if(this.prepared.edges){var i=this.target.getRect(this.element);if(this.target.options.resize.square){var r=d({},this.prepared.edges);r.top=r.top||r.left&&!r.bottom,r.left=r.left||r.top&&!r.right,r.bottom=r.bottom||r.right&&!r.top,r.right=r.right||r.bottom&&!r.left,this.prepared._squareEdges=r}else this.prepared._squareEdges=null;this.resizeRects={start:i,current:d({},i),restricted:d({},i),previous:d({},i),delta:{left:0,right:0,width:0,top:0,bottom:0,height:0}},e.rect=this.resizeRects.restricted,e.deltaRect=this.resizeRects.delta}return this.target.fire(e),this.resizing=!0,e},resizeMove:function(t){var e=new B(this,t,"resize","move",this.element),i=this.prepared.edges,r=this.target.options.resize.invert,s="reposition"===r||"negate"===r;if(i){var n=e.dx,o=e.dy,a=this.resizeRects.start,h=this.resizeRects.current,p=this.resizeRects.restricted,l=this.resizeRects.delta,c=d(this.resizeRects.previous,p);if(this.target.options.resize.square){var u=i;i=this.prepared._squareEdges,u.left&&u.bottom||u.right&&u.top?o=-n:u.left||u.right?o=n:(u.top||u.bottom)&&(n=o)}if(i.top&&(h.top+=o),i.bottom&&(h.bottom+=o),i.left&&(h.left+=n),i.right&&(h.right+=n),s){if(d(p,h),"reposition"===r){var g;p.top>p.bottom&&(g=p.top,p.top=p.bottom,p.bottom=g),p.left>p.right&&(g=p.left,p.left=p.right,p.right=g)}}else p.top=Math.min(h.top,a.bottom),p.bottom=Math.max(h.bottom,a.top),p.left=Math.min(h.left,a.right),p.right=Math.max(h.right,a.left);p.width=p.right-p.left,p.height=p.bottom-p.top;for(var v in p)l[v]=p[v]-c[v];e.edges=this.prepared.edges,e.rect=p,e.deltaRect=l}return this.target.fire(e),e},gestureStart:function(t){var e=new B(this,t,"gesture","start",this.element);return e.ds=0,this.gesture.startDistance=this.gesture.prevDistance=e.distance,this.gesture.startAngle=this.gesture.prevAngle=e.angle,this.gesture.scale=1,this.gesturing=!0,this.target.fire(e),e},gestureMove:function(t){if(!this.pointerIds.length)return this.prevEvent;var e;return e=new B(this,t,"gesture","move",this.element),e.ds=e.scale-this.gesture.scale,this.target.fire(e),this.gesture.prevAngle=e.angle,this.gesture.prevDistance=e.distance,1/0===e.scale||null===e.scale||void 0===e.scale||isNaN(e.scale)||(this.gesture.scale=e.scale),e},pointerHold:function(t,e,i){this.collectEventTargets(t,e,i,"hold")},pointerUp:function(t,e,i,r){var s=this.mouse?0:ae(this.pointerIds,E(t));clearTimeout(this.holdTimers[s]),this.collectEventTargets(t,e,i,"up"),this.collectEventTargets(t,e,i,"tap"),this.pointerEnd(t,e,i,r),this.removePointer(t)},pointerCancel:function(t,e,i,r){var s=this.mouse?0:ae(this.pointerIds,E(t));clearTimeout(this.holdTimers[s]),this.collectEventTargets(t,e,i,"cancel"),this.pointerEnd(t,e,i,r),this.removePointer(t)},ie8Dblclick:function(t,e,i){this.prevTap&&e.clientX===this.prevTap.clientX&&e.clientY===this.prevTap.clientY&&i===this.prevTap.target&&(this.downTargets[0]=i,this.downTimes[0]=(new Date).getTime(),this.collectEventTargets(t,e,i,"tap"))},pointerEnd:function(t,e,i,r){var s,n=this.target,o=n&&n.options,a=o&&this.prepared.name&&o[this.prepared.name].inertia,h=this.inertiaStatus;if(this.interacting()){if(h.active)return;var p,l,c=(new Date).getTime(),g=!1,v=!1,m=!1,f=N(n,this.prepared.name)&&o[this.prepared.name].snap.endOnly,y=H(n,this.prepared.name)&&o[this.prepared.name].restrict.endOnly,x=0,E=0;if(p=this.dragging?"x"===o.drag.axis?Math.abs(this.pointerDelta.client.vx):"y"===o.drag.axis?Math.abs(this.pointerDelta.client.vy):this.pointerDelta.client.speed:this.pointerDelta.client.speed,g=a&&a.enabled&&"gesture"!==this.prepared.name&&e!==h.startEvent,v=g&&c-this.curCoords.timeStamp<50&&p>a.minSpeed&&p>a.endSpeed,g&&!v&&(f||y)){var S={};S.snap=S.restrict=S,f&&(this.setSnapping(this.curCoords.page,S),S.locked&&(x+=S.dx,E+=S.dy)),y&&(this.setRestriction(this.curCoords.page,S),S.restricted&&(x+=S.dx,E+=S.dy)),(x||E)&&(m=!0)}if(v||m){if(u(h.upCoords,this.curCoords),this.pointers[0]=h.startEvent=l=new B(this,e,this.prepared.name,"inertiastart",this.element),h.t0=c,n.fire(h.startEvent),v){h.vx0=this.pointerDelta.client.vx,h.vy0=this.pointerDelta.client.vy,h.v0=p,this.calcInertia(h);var b,w=d({},this.curCoords.page),D=P(n,this.element);if(w.x=w.x+h.xe-D.x,w.y=w.y+h.ye-D.y,b={useStatusXY:!0,x:w.x,y:w.y,dx:0,dy:0,snap:null},b.snap=b,x=E=0,f){var z=this.setSnapping(this.curCoords.page,b);z.locked&&(x+=z.dx,E+=z.dy)}if(y){var T=this.setRestriction(this.curCoords.page,b);T.restricted&&(x+=T.dx,E+=T.dy)}h.modifiedXe+=x,h.modifiedYe+=E,h.i=Ve(this.boundInertiaFrame)}else h.smoothEnd=!0,h.xe=x,h.ye=E,h.sx=h.sy=0,h.i=Ve(this.boundSmoothEndFrame);return void(h.active=!0)}(f||y)&&this.pointerMove(t,e,i,r,!0)}if(this.dragging){s=new B(this,e,"drag","end",this.element);var C=this.element,M=this.getDrop(s,C);this.dropTarget=M.dropzone,this.dropElement=M.element;var O=this.getDropEvents(e,s);O.leave&&this.prevDropTarget.fire(O.leave),O.enter&&this.dropTarget.fire(O.enter),O.drop&&this.dropTarget.fire(O.drop),O.deactivate&&this.fireActiveDrops(O.deactivate),n.fire(s)}else this.resizing?(s=new B(this,e,"resize","end",this.element),n.fire(s)):this.gesturing&&(s=new B(this,e,"gesture","end",this.element),n.fire(s));this.stop(e)},collectDrops:function(t){var e,r=[],s=[];for(t=t||this.element,e=0;e<De.length;e++)if(De[e].options.drop.enabled){var n=De[e],o=n.options.drop.accept;if(!(i(o)&&o!==t||l(o)&&!pe(t,o)))for(var a=n.selector?n._context.querySelectorAll(n.selector):[n._element],h=0,p=a.length;p>h;h++){var c=a[h];c!==t&&(r.push(n),s.push(c))}}return{dropzones:r,elements:s}},fireActiveDrops:function(t){var e,i,r,s;for(e=0;e<this.activeDrops.dropzones.length;e++)i=this.activeDrops.dropzones[e],r=this.activeDrops.elements[e],r!==s&&(t.target=r,i.fire(t)),s=r},setActiveDrops:function(t){var e=this.collectDrops(t,!0);this.activeDrops.dropzones=e.dropzones,this.activeDrops.elements=e.elements,this.activeDrops.rects=[];for(var i=0;i<this.activeDrops.dropzones.length;i++)this.activeDrops.rects[i]=this.activeDrops.dropzones[i].getRect(this.activeDrops.elements[i])},getDrop:function(t,e){var i=[];Te&&this.setActiveDrops(e);for(var r=0;r<this.activeDrops.dropzones.length;r++){var s=this.activeDrops.dropzones[r],n=this.activeDrops.elements[r],o=this.activeDrops.rects[r];i.push(s.dropCheck(this.pointers[0],this.target,e,n,o)?n:null)}var a=V(i),h=this.activeDrops.dropzones[a]||null,p=this.activeDrops.elements[a]||null;return{dropzone:h,element:p}},getDropEvents:function(t,e){var i={enter:null,leave:null,activate:null,deactivate:null,move:null,drop:null};return this.dropElement!==this.prevDropElement&&(this.prevDropTarget&&(i.leave={target:this.prevDropElement,dropzone:this.prevDropTarget,relatedTarget:e.target,draggable:e.interactable,dragEvent:e,interaction:this,timeStamp:e.timeStamp,type:"dragleave"},e.dragLeave=this.prevDropElement,e.prevDropzone=this.prevDropTarget),this.dropTarget&&(i.enter={target:this.dropElement,dropzone:this.dropTarget,relatedTarget:e.target,draggable:e.interactable,dragEvent:e,interaction:this,timeStamp:e.timeStamp,type:"dragenter"},e.dragEnter=this.dropElement,e.dropzone=this.dropTarget)),"dragend"===e.type&&this.dropTarget&&(i.drop={target:this.dropElement,dropzone:this.dropTarget,relatedTarget:e.target,draggable:e.interactable,dragEvent:e,interaction:this,timeStamp:e.timeStamp,type:"drop"}),"dragstart"===e.type&&(i.activate={target:null,dropzone:null,relatedTarget:e.target,draggable:e.interactable,dragEvent:e,interaction:this,timeStamp:e.timeStamp,type:"dropactivate"}),"dragend"===e.type&&(i.deactivate={target:null,dropzone:null,relatedTarget:e.target,draggable:e.interactable,dragEvent:e,interaction:this,timeStamp:e.timeStamp,type:"dropdeactivate"}),"dragmove"===e.type&&this.dropTarget&&(i.move={target:this.dropElement,dropzone:this.dropTarget,relatedTarget:e.target,draggable:e.interactable,dragEvent:e,interaction:this,dragmove:e,timeStamp:e.timeStamp,type:"dropmove"},e.dropzone=this.dropTarget),i},currentAction:function(){return this.dragging&&"drag"||this.resizing&&"resize"||this.gesturing&&"gesture"||null},interacting:function(){return this.dragging||this.resizing||this.gesturing},clearTargets:function(){this.target&&!this.target.selector&&(this.target=this.element=null),this.dropTarget=this.dropElement=this.prevDropTarget=this.prevDropElement=null},stop:function(t){if(this.interacting()){Pe.stop(),this.matches=[],this.matchElements=[];var e=this.target;e.options.styleCursor&&(e._doc.documentElement.style.cursor=""),t&&a(t.preventDefault)&&this.checkAndPreventDefault(t,e,this.element),this.dragging&&(this.activeDrops.dropzones=this.activeDrops.elements=this.activeDrops.rects=null),this.clearTargets()}this.pointerIsDown=this.snapStatus.locked=this.dragging=this.resizing=this.gesturing=!1,this.prepared.name=this.prevEvent=null,this.inertiaStatus.resumeDx=this.inertiaStatus.resumeDy=0;for(var i=0;i<this.pointers.length;i++)-1===ae(this.pointerIds,E(this.pointers[i]))&&this.pointers.splice(i,1);ze.length>1&&ze.splice(ae(ze,this),1)},inertiaFrame:function(){var t=this.inertiaStatus,e=this.target.options[this.prepared.name].inertia,i=e.resistance,r=(new Date).getTime()/1e3-t.t0;if(r<t.te){var s=1-(Math.exp(-i*r)-t.lambda_v0)/t.one_ve_v0;if(t.modifiedXe===t.xe&&t.modifiedYe===t.ye)t.sx=t.xe*s,t.sy=t.ye*s;else{var n=_(0,0,t.xe,t.ye,t.modifiedXe,t.modifiedYe,s);t.sx=n.x,t.sy=n.y}this.pointerMove(t.startEvent,t.startEvent),t.i=Ve(this.boundInertiaFrame)}else t.sx=t.modifiedXe,t.sy=t.modifiedYe,this.pointerMove(t.startEvent,t.startEvent),t.active=!1,this.pointerEnd(t.startEvent,t.startEvent)},smoothEndFrame:function(){var t=this.inertiaStatus,e=(new Date).getTime()-t.t0,i=this.target.options[this.prepared.name].inertia.smoothEndDuration;i>e?(t.sx=A(e,0,t.xe,i),t.sy=A(e,0,t.ye,i),this.pointerMove(t.startEvent,t.startEvent),t.i=Ve(this.boundSmoothEndFrame)):(t.sx=t.xe,t.sy=t.ye,this.pointerMove(t.startEvent,t.startEvent),t.active=!1,t.smoothEnd=!1,this.pointerEnd(t.startEvent,t.startEvent))},addPointer:function(t){var e=E(t),i=this.mouse?0:ae(this.pointerIds,e);return-1===i&&(i=this.pointerIds.length),this.pointerIds[i]=e,this.pointers[i]=t,i},removePointer:function(t){var e=E(t),i=this.mouse?0:ae(this.pointerIds,e);-1!==i&&(this.interacting()||this.pointers.splice(i,1),this.pointerIds.splice(i,1),this.downTargets.splice(i,1),this.downTimes.splice(i,1),this.holdTimers.splice(i,1))},recordPointer:function(t){if(!this.inertiaStatus.active){var e=this.mouse?0:ae(this.pointerIds,E(t));-1!==e&&(this.pointers[e]=t)}},collectEventTargets:function(t,e,r,s){function n(t,e,n){var o=de?n.querySelectorAll(e):void 0;t._iEvents[s]&&i(p)&&I(t,p)&&!R(t,p,r)&&F(t,p,r)&&pe(p,e,o)&&(a.push(t),h.push(p))}var o=this.mouse?0:ae(this.pointerIds,E(t));if("tap"!==s||!this.pointerWasMoved&&this.downTargets[o]&&this.downTargets[o]===r){for(var a=[],h=[],p=r;p;)ie.isSet(p)&&ie(p)._iEvents[s]&&(a.push(ie(p)),h.push(p)),De.forEachSelector(n),p=k(p);(a.length||"tap"===s)&&this.firePointers(t,e,r,a,h,s)}},firePointers:function(t,e,i,r,s,n){var o,a,h,p=this.mouse?0:ae(E(t)),c={};for("doubletap"===n?c=t:(d(c,e),e!==t&&d(c,t),c.preventDefault=K,c.stopPropagation=B.prototype.stopPropagation,c.stopImmediatePropagation=B.prototype.stopImmediatePropagation,c.interaction=this,c.timeStamp=(new Date).getTime(),c.originalEvent=e,c.type=n,c.pointerId=E(t),c.pointerType=this.mouse?"mouse":_e?l(t.pointerType)?t.pointerType:[,,"touch","pen","mouse"][t.pointerType]:"touch"),"tap"===n&&(c.dt=c.timeStamp-this.downTimes[p],a=c.timeStamp-this.tapTime,h=!!(this.prevTap&&"doubletap"!==this.prevTap.type&&this.prevTap.target===c.target&&500>a),c.double=h,this.tapTime=c.timeStamp),o=0;o<r.length&&(c.currentTarget=s[o],c.interactable=r[o],r[o].fire(c),!(c.immediatePropagationStopped||c.propagationStopped&&s[o+1]!==c.currentTarget));o++);if(h){var u={};d(u,c),u.dt=a,u.type="doubletap",this.collectEventTargets(u,e,i,"doubletap"),this.prevTap=u}else"tap"===n&&(this.prevTap=c)},validateSelector:function(t,e,i){for(var r=0,s=e.length;s>r;r++){var n=e[r],o=i[r],a=Z(n.getAction(t,this,o),n);if(a&&U(n,o,a))return this.target=n,this.element=o,a}},setSnapping:function(t,e){var i,r,s,n=this.target.options[this.prepared.name].snap,o=[];if(e=e||this.snapStatus,e.useStatusXY)r={x:e.x,y:e.y};else{var p=P(this.target,this.element);r=d({},t),r.x-=p.x,r.y-=p.y}e.realX=r.x,e.realY=r.y,r.x=r.x-this.inertiaStatus.resumeDx,r.y=r.y-this.inertiaStatus.resumeDy;for(var l=n.targets?n.targets.length:0,c=0;c<this.snapOffsets.length;c++){var u={x:r.x-this.snapOffsets[c].x,y:r.y-this.snapOffsets[c].y};for(s=0;l>s;s++)i=a(n.targets[s])?n.targets[s](u.x,u.y,this):n.targets[s],i&&o.push({x:h(i.x)?i.x+this.snapOffsets[c].x:u.x,y:h(i.y)?i.y+this.snapOffsets[c].y:u.y,range:h(i.range)?i.range:n.range})}var g={target:null,inRange:!1,distance:0,range:0,dx:0,dy:0};for(s=0,l=o.length;l>s;s++){i=o[s];var v=i.range,m=i.x-r.x,f=i.y-r.y,y=Se(m,f),x=v>=y;1/0===v&&g.inRange&&1/0!==g.range&&(x=!1),(!g.target||(x?g.inRange&&1/0!==v?y/v<g.distance/g.range:1/0===v&&1/0!==g.range||y<g.distance:!g.inRange&&y<g.distance))&&(1/0===v&&(x=!0),g.target=i,g.distance=y,g.range=v,g.inRange=x,g.dx=m,g.dy=f,e.range=v)}var E;return g.target?(E=e.snappedX!==g.target.x||e.snappedY!==g.target.y,e.snappedX=g.target.x,e.snappedY=g.target.y):(E=!0,e.snappedX=0/0,e.snappedY=0/0),e.dx=g.dx,e.dy=g.dy,e.changed=E||g.inRange&&!e.locked,e.locked=g.inRange,e},setRestriction:function(t,e){var r,s=this.target,n=s&&s.options[this.prepared.name].restrict,o=n&&n.restriction;if(!o)return e;e=e||this.restrictStatus,r=r=e.useStatusXY?{x:e.x,y:e.y}:d({},t),e.snap&&e.snap.locked&&(r.x+=e.snap.dx||0,r.y+=e.snap.dy||0),r.x-=this.inertiaStatus.resumeDx,r.y-=this.inertiaStatus.resumeDy,e.dx=0,e.dy=0,e.restricted=!1;var h,p,c;return l(o)&&(o="parent"===o?k(this.element):"self"===o?s.getRect(this.element):Y(this.element,o),!o)?e:(a(o)&&(o=o(r.x,r.y,this.element)),i(o)&&(o=w(o)),h=o,o?"x"in o&&"y"in o?(p=Math.max(Math.min(h.x+h.width-this.restrictOffset.right,r.x),h.x+this.restrictOffset.left),c=Math.max(Math.min(h.y+h.height-this.restrictOffset.bottom,r.y),h.y+this.restrictOffset.top)):(p=Math.max(Math.min(h.right-this.restrictOffset.right,r.x),h.left+this.restrictOffset.left),c=Math.max(Math.min(h.bottom-this.restrictOffset.bottom,r.y),h.top+this.restrictOffset.top)):(p=r.x,c=r.y),e.dx=p-r.x,e.dy=c-r.y,e.changed=e.restrictedX!==p||e.restrictedY!==c,e.restricted=!(!e.dx&&!e.dy),e.restrictedX=p,e.restrictedY=c,e)},checkAndPreventDefault:function(t,e,i){if(e=e||this.target){var r=e.options,s=r.preventDefault;if("auto"===s&&i&&!/^input$|^textarea$/i.test(i.nodeName)){if(/down|start/i.test(t.type)&&"drag"===this.prepared.name&&"xy"!==r.drag.axis)return;if(r[this.prepared.name]&&r[this.prepared.name].manualStart&&!this.interacting())return;return void t.preventDefault()}return"always"===s?void t.preventDefault():void 0}},calcInertia:function(t){var e=this.target.options[this.prepared.name].inertia,i=e.resistance,r=-Math.log(e.endSpeed/t.v0)/i;t.x0=this.prevEvent.pageX,t.y0=this.prevEvent.pageY,t.t0=t.startEvent.timeStamp/1e3,t.sx=t.sy=0,t.modifiedXe=t.xe=(t.vx0-r)/i,t.modifiedYe=t.ye=(t.vy0-r)/i,t.te=r,t.lambda_v0=i/t.v0,t.one_ve_v0=1-e.endSpeed/t.v0},_updateEventTargets:function(t,e){this._eventTarget=t,this._curEventTarget=e}},B.prototype={preventDefault:e,stopImmediatePropagation:function(){this.immediatePropagationStopped=this.propagationStopped=!0},stopPropagation:function(){this.propagationStopped=!0}};for(var Le={},Be=["dragStart","dragMove","resizeStart","resizeMove","gestureStart","gestureMove","pointerOver","pointerOut","pointerHover","selectorDown","pointerDown","pointerMove","pointerUp","pointerCancel","pointerEnd","addPointer","removePointer","recordPointer"],Ke=0,je=Be.length;je>Ke;Ke++){var Je=Be[Ke];Le[Je]=L(Je)}De.indexOfElement=function(t,e){e=e||ge;for(var i=0;i<this.length;i++){var r=this[i];if(r.selector===t&&r._context===e||!r.selector&&r._element===t)return i}return-1},De.get=function(t,e){return this[this.indexOfElement(t,e&&e.context)]},De.forEachSelector=function(t){for(var e=0;e<this.length;e++){var i=this[e];if(i.selector){var r=t(i,i.selector,i._context,e,this);if(void 0!==r)return r}}},re.prototype={setOnEvents:function(t,e){return"drop"===t?(a(e.ondrop)&&(this.ondrop=e.ondrop),a(e.ondropactivate)&&(this.ondropactivate=e.ondropactivate),a(e.ondropdeactivate)&&(this.ondropdeactivate=e.ondropdeactivate),a(e.ondragenter)&&(this.ondragenter=e.ondragenter),a(e.ondragleave)&&(this.ondragleave=e.ondragleave),a(e.ondropmove)&&(this.ondropmove=e.ondropmove)):(t="on"+t,a(e.onstart)&&(this[t+"start"]=e.onstart),a(e.onmove)&&(this[t+"move"]=e.onmove),a(e.onend)&&(this[t+"end"]=e.onend),a(e.oninertiastart)&&(this[t+"inertiastart"]=e.oninertiastart)),this},draggable:function(t){return o(t)?(this.options.drag.enabled=t.enabled===!1?!1:!0,this.setPerAction("drag",t),this.setOnEvents("drag",t),/^x$|^y$|^xy$/.test(t.axis)?this.options.drag.axis=t.axis:null===t.axis&&delete this.options.drag.axis,this):p(t)?(this.options.drag.enabled=t,this):this.options.drag},setPerAction:function(t,e){for(var i in e)i in Me[t]&&(o(e[i])?(this.options[t][i]=d(this.options[t][i]||{},e[i]),o(Me.perAction[i])&&"enabled"in Me.perAction[i]&&(this.options[t][i].enabled=e[i].enabled===!1?!1:!0)):p(e[i])&&o(Me.perAction[i])?this.options[t][i].enabled=e[i]:void 0!==e[i]&&(this.options[t][i]=e[i]))},dropzone:function(t){return o(t)?(this.options.drop.enabled=t.enabled===!1?!1:!0,this.setOnEvents("drop",t),this.accept(t.accept),/^(pointer|center)$/.test(t.overlap)?this.options.drop.overlap=t.overlap:h(t.overlap)&&(this.options.drop.overlap=Math.max(Math.min(1,t.overlap),0)),this):p(t)?(this.options.drop.enabled=t,this):this.options.drop},dropCheck:function(t,e,i,r,s){var n=!1;if(!(s=s||this.getRect(r)))return this.options.dropChecker?this.options.dropChecker(t,n,this,r,e,i):!1;var o=this.options.drop.overlap;if("pointer"===o){var a,p,l=f(t),c=P(e,i);l.x+=c.x,l.y+=c.y,a=l.x>s.left&&l.x<s.right,p=l.y>s.top&&l.y<s.bottom,n=a&&p}var d=e.getRect(i);if("center"===o){var u=d.left+d.width/2,g=d.top+d.height/2;n=u>=s.left&&u<=s.right&&g>=s.top&&g<=s.bottom}if(h(o)){var v=Math.max(0,Math.min(s.right,d.right)-Math.max(s.left,d.left))*Math.max(0,Math.min(s.bottom,d.bottom)-Math.max(s.top,d.top)),m=v/(d.width*d.height);n=m>=o}return this.options.dropChecker&&(n=this.options.dropChecker(t,n,this,r,e,i)),n},dropChecker:function(t){return a(t)?(this.options.dropChecker=t,this):null===t?(delete this.options.getRect,this):this.options.dropChecker},accept:function(t){return i(t)?(this.options.drop.accept=t,this):c(t)?(this.options.drop.accept=t,this):null===t?(delete this.options.drop.accept,this):this.options.drop.accept},resizable:function(t){return o(t)?(this.options.resize.enabled=t.enabled===!1?!1:!0,this.setPerAction("resize",t),this.setOnEvents("resize",t),/^x$|^y$|^xy$/.test(t.axis)?this.options.resize.axis=t.axis:null===t.axis&&(this.options.resize.axis=Me.resize.axis),p(t.square)&&(this.options.resize.square=t.square),this):p(t)?(this.options.resize.enabled=t,this):this.options.resize},squareResize:function(t){return p(t)?(this.options.resize.square=t,this):null===t?(delete this.options.resize.square,this):this.options.resize.square},gesturable:function(t){return o(t)?(this.options.gesture.enabled=t.enabled===!1?!1:!0,this.setPerAction("gesture",t),this.setOnEvents("gesture",t),this):p(t)?(this.options.gesture.enabled=t,this):this.options.gesture},autoScroll:function(t){return o(t)?t=d({actions:["drag","resize"]},t):p(t)&&(t={actions:["drag","resize"],enabled:t}),this.setOptions("autoScroll",t)},snap:function(t){var e=this.setOptions("snap",t);return e===this?this:e.drag},setOptions:function(t,e){var i,r=e&&n(e.actions)?e.actions:["drag"];if(o(e)||p(e)){for(i=0;i<r.length;i++){var s=/resize/.test(r[i])?"resize":r[i];if(o(this.options[s])){var a=this.options[s][t];o(e)?(d(a,e),a.enabled=e.enabled===!1?!1:!0,"snap"===t&&("grid"===a.mode?a.targets=[ie.createSnapGrid(d({offset:a.gridOffset||{x:0,y:0}},a.grid||{}))]:"anchor"===a.mode?a.targets=a.anchors:"path"===a.mode&&(a.targets=a.paths),"elementOrigin"in e&&(a.relativePoints=[e.elementOrigin]))):p(e)&&(a.enabled=e)}}return this}var h={},l=["drag","resize","gesture"];for(i=0;i<l.length;i++)t in Me[l[i]]&&(h[l[i]]=this.options[l[i]][t]);return h},inertia:function(t){var e=this.setOptions("inertia",t);return e===this?this:e.drag},getAction:function(t,e,i){var r=this.defaultActionChecker(t,e,i);return this.options.actionChecker?this.options.actionChecker(t,r,this,i,e):r},defaultActionChecker:Q,actionChecker:function(t){return a(t)?(this.options.actionChecker=t,this):null===t?(delete this.options.actionChecker,this):this.options.actionChecker},getRect:function(t){return t=t||this._element,this.selector&&!i(t)&&(t=this._context.querySelector(this.selector)),w(t)},rectChecker:function(t){return a(t)?(this.getRect=t,this):null===t?(delete this.options.getRect,this):this.getRect},styleCursor:function(t){return p(t)?(this.options.styleCursor=t,this):null===t?(delete this.options.styleCursor,this):this.options.styleCursor},preventDefault:function(t){return/^(always|never|auto)$/.test(t)?(this.options.preventDefault=t,this):p(t)?(this.options.preventDefault=t?"always":"never",this):this.options.preventDefault},origin:function(t){return c(t)?(this.options.origin=t,this):o(t)?(this.options.origin=t,this):this.options.origin},deltaSource:function(t){return"page"===t||"client"===t?(this.options.deltaSource=t,this):this.options.deltaSource},restrict:function(t){if(!o(t))return this.setOptions("restrict",t);for(var e,i=["drag","resize","gesture"],r=0;r<i.length;r++){var s=i[r];if(s in t){var n=d({actions:[s],restriction:t[s]},t);e=this.setOptions("restrict",n)}}return e},context:function(){return this._context},_context:ge,ignoreFrom:function(t){return c(t)?(this.options.ignoreFrom=t,this):i(t)?(this.options.ignoreFrom=t,this):this.options.ignoreFrom},allowFrom:function(t){return c(t)?(this.options.allowFrom=t,this):i(t)?(this.options.allowFrom=t,this):this.options.allowFrom},element:function(){return this._element},fire:function(t){if(!t||!t.type||!he(qe,t.type))return this;var e,i,r,s="on"+t.type,n="";if(t.type in this._iEvents)for(e=this._iEvents[t.type],i=0,r=e.length;r>i&&!t.immediatePropagationStopped;i++)n=e[i].name,e[i](t);if(a(this[s])&&(n=this[s].name,this[s](t)),t.type in Ne&&(e=Ne[t.type]))for(i=0,r=e.length;r>i&&!t.immediatePropagationStopped;i++)n=e[i].name,e[i](t);return this},on:function(t,e,i){var r;if(l(t)&&-1!==t.search(" ")&&(t=t.trim().split(/ +/)),n(t)){for(r=0;r<t.length;r++)this.on(t[r],e,i);return this}if(o(t)){for(var s in t)this.on(s,t[s],e);return this}if("wheel"===t&&(t=Fe),i=i?!0:!1,he(qe,t))t in this._iEvents?this._iEvents[t].push(e):this._iEvents[t]=[e];else if(this.selector){if(!Ce[t])for(Ce[t]={selectors:[],contexts:[],listeners:[]},r=0;r<we.length;r++)Ge.add(we[r],t,te),Ge.add(we[r],t,ee,!0);var a,h=Ce[t];for(a=h.selectors.length-1;a>=0&&(h.selectors[a]!==this.selector||h.contexts[a]!==this._context);a--);-1===a&&(a=h.selectors.length,h.selectors.push(this.selector),h.contexts.push(this._context),h.listeners.push([])),h.listeners[a].push([e,i])}else Ge.add(this._element,t,e,i);return this},off:function(t,e,i){var r;if(l(t)&&-1!==t.search(" ")&&(t=t.trim().split(/ +/)),n(t)){for(r=0;r<t.length;r++)this.off(t[r],e,i);return this}if(o(t)){for(var s in t)this.off(s,t[s],e);return this}var a,h=-1;if(i=i?!0:!1,"wheel"===t&&(t=Fe),he(qe,t))a=this._iEvents[t],a&&-1!==(h=ae(a,e))&&this._iEvents[t].splice(h,1);else if(this.selector){var p=Ce[t],c=!1;if(!p)return this;for(h=p.selectors.length-1;h>=0;h--)if(p.selectors[h]===this.selector&&p.contexts[h]===this._context){var d=p.listeners[h];for(r=d.length-1;r>=0;r--){var u=d[r][0],g=d[r][1];if(u===e&&g===i){d.splice(r,1),d.length||(p.selectors.splice(h,1),p.contexts.splice(h,1),p.listeners.splice(h,1),Ge.remove(this._context,t,te),Ge.remove(this._context,t,ee,!0),p.selectors.length||(Ce[t]=null)),c=!0;break}}if(c)break}}else Ge.remove(this._element,t,e,i);return this},set:function(t){o(t)||(t={}),this.options=d({},Me.base);var e,i=["drag","drop","resize","gesture"],r=["draggable","dropzone","resizable","gesturable"],s=d(d({},Me.perAction),t[n]||{});for(e=0;e<i.length;e++){var n=i[e];this.options[n]=d({},Me[n]),this.setPerAction(n,s),this[r[e]](t[n])}var a=["accept","actionChecker","allowFrom","deltaSource","dropChecker","ignoreFrom","origin","preventDefault","rectChecker"];for(e=0,je=a.length;je>e;e++){var h=a[e];this.options[h]=Me.base[h],h in t&&this[h](t[h])}return this},unset:function(){if(Ge.remove(this,"all"),l(this.selector))for(var t in Ce)for(var e=Ce[t],i=0;i<e.selectors.length;i++){e.selectors[i]===this.selector&&e.contexts[i]===this._context&&(e.selectors.splice(i,1),e.contexts.splice(i,1),e.listeners.splice(i,1),e.selectors.length||(Ce[t]=null)),Ge.remove(this._context,t,te),Ge.remove(this._context,t,ee,!0);break}else Ge.remove(this,"all"),this.options.styleCursor&&(this._element.style.cursor="");return this.dropzone(!1),De.splice(ae(De,this),1),ie}},re.prototype.snap=se(re.prototype.snap,"Interactable#snap is deprecated. See the new documentation for snapping at http://interactjs.io/docs/snapping"),re.prototype.restrict=se(re.prototype.restrict,"Interactable#restrict is deprecated. See the new documentation for resticting at http://interactjs.io/docs/restriction"),re.prototype.inertia=se(re.prototype.inertia,"Interactable#inertia is deprecated. See the new documentation for inertia at http://interactjs.io/docs/inertia"),re.prototype.autoScroll=se(re.prototype.autoScroll,"Interactable#autoScroll is deprecated. See the new documentation for autoScroll at http://interactjs.io/docs/#autoscroll"),ie.isSet=function(t,e){return-1!==De.indexOfElement(t,e&&e.context)},ie.on=function(t,e,i){if(l(t)&&-1!==t.search(" ")&&(t=t.trim().split(/ +/)),n(t)){for(var r=0;r<t.length;r++)ie.on(t[r],e,i);return ie}if(o(t)){for(var s in t)ie.on(s,t[s],e);return ie}return he(qe,t)?Ne[t]?Ne[t].push(e):Ne[t]=[e]:Ge.add(ge,t,e,i),ie},ie.off=function(t,e,i){if(l(t)&&-1!==t.search(" ")&&(t=t.trim().split(/ +/)),n(t)){for(var r=0;r<t.length;r++)ie.off(t[r],e,i);return ie}if(o(t)){for(var s in t)ie.off(s,t[s],e);return ie}if(he(qe,t)){var a;t in Ne&&-1!==(a=ae(Ne[t],e))&&Ne[t].splice(a,1)}else Ge.remove(ge,t,e,i);return ie},ie.enableDragging=se(function(t){return null!==t&&void 0!==t?(Re.drag=t,ie):Re.drag},"interact.enableDragging is deprecated and will soon be removed."),ie.enableResizing=se(function(t){return null!==t&&void 0!==t?(Re.resize=t,ie):Re.resize},"interact.enableResizing is deprecated and will soon be removed."),ie.enableGesturing=se(function(t){return null!==t&&void 0!==t?(Re.gesture=t,ie):Re.gesture},"interact.enableGesturing is deprecated and will soon be removed."),ie.eventTypes=qe,ie.debug=function(){var t=ze[0]||new $;return{interactions:ze,target:t.target,dragging:t.dragging,resizing:t.resizing,gesturing:t.gesturing,prepared:t.prepared,matches:t.matches,matchElements:t.matchElements,prevCoords:t.prevCoords,startCoords:t.startCoords,pointerIds:t.pointerIds,pointers:t.pointers,addPointer:Le.addPointer,removePointer:Le.removePointer,recordPointer:Le.recordPointer,snap:t.snapStatus,restrict:t.restrictStatus,inertia:t.inertiaStatus,downTime:t.downTimes[0],downEvent:t.downEvent,downPointer:t.downPointer,prevEvent:t.prevEvent,Interactable:re,interactables:De,pointerIsDown:t.pointerIsDown,defaultOptions:Me,defaultActionChecker:Q,actionCursors:Ie,dragMove:Le.dragMove,resizeMove:Le.resizeMove,gestureMove:Le.gestureMove,pointerUp:Le.pointerUp,pointerDown:Le.pointerDown,pointerMove:Le.pointerMove,pointerHover:Le.pointerHover,events:Ge,globalEvents:Ne,delegatedEvents:Ce}},ie.getTouchAverage=z,ie.getTouchBBox=T,ie.getTouchDistance=C,ie.getTouchAngle=M,ie.getElementRect=w,ie.matchesSelector=pe,ie.closest=Y,ie.margin=function(t){return h(t)?(Ae=t,ie):Ae},ie.supportsTouch=function(){return Oe},ie.supportsPointerEvent=function(){return _e},ie.stop=function(t){for(var e=ze.length-1;e>0;e--)ze[e].stop(t);return ie},ie.dynamicDrop=function(t){return p(t)?(Te=t,ie):Te},ie.pointerMoveTolerance=function(t){return h(t)?(Xe=t,this):Xe},ie.maxInteractions=function(t){return h(t)?(ke=t,this):ke},ie.createSnapGrid=function(t){return function(e,i){var r=0,s=0;o(t.offset)&&(r=t.offset.x,s=t.offset.y);var n=Math.round((e-r)/t.x),a=Math.round((i-s)/t.y),h=n*t.x+r,p=a*t.y+s;return{x:h,y:p,range:t.range}}},oe(ge),Ue in Element.prototype&&a(Element.prototype[Ue])||(de=function(t,e,i){i=i||t.parentNode.querySelectorAll(e);for(var r=0,s=i.length;s>r;r++)if(i[r]===t)return!0;return!1}),function(){for(var e=0,i=["ms","moz","webkit","o"],r=0;r<i.length&&!t.requestAnimationFrame;++r)Ve=t[i[r]+"RequestAnimationFrame"],$e=t[i[r]+"CancelAnimationFrame"]||t[i[r]+"CancelRequestAnimationFrame"];Ve||(Ve=function(t){var i=(new Date).getTime(),r=Math.max(0,16-(i-e)),s=setTimeout(function(){t(i+r)},r);return e=i+r,s}),$e||($e=function(t){clearTimeout(t)})}(),"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=ie),exports.interact=ie):"function"==typeof define&&define.amd?define("interact",function(){return ie}):t.interact=ie}(window);