text: /* interact.js v1.0.19 | https://raw.github.com/taye/interact.js/master/LICENSE */
  !function(e){"use strict";function t(){}function n(e){return!!e&&"object"==typeof e&&(/object|function/.test(typeof Element)?e instanceof Element:1===e.nodeType&&"string"==typeof e.nodeName)}function i(e,t){s(t,wt),e.pageX=wt.x,e.pageY=wt.y,a(t,wt),e.clientX=wt.x,e.clientY=wt.y,e.timeStamp=(new Date).getTime()}function r(e,t,n){e.pageX=n.pageX-t.pageX,e.pageY=n.pageY-t.pageY,e.clientX=n.clientX-t.clientX,e.clientY=n.clientY-t.clientY,e.timeStamp=(new Date).getTime()-t.timeStamp;var i=Math.max(e.timeStamp/1e3,.001);e.pageSpeed=ft(e.pageX,e.pageY)/i,e.pageVX=e.pageX/i,e.pageVY=e.pageY/i,e.clientSpeed=ft(e.clientX,e.pageY)/i,e.clientVX=e.clientX/i,e.clientVY=e.clientY/i}function o(e,t,n){var i,r,o;return n=n||{},e=e||"page",/touch/.test(t.type)&&t.touches?(i=t.touches.length?t.touches[0]:t.changedTouches[0],r=i[e+"X"],o=i[e+"Y"]):(r=t[e+"X"],o=t[e+"Y"]),n.x=r,n.y=o,n}function s(t,n){return n=n||{},t instanceof w?/inertiastart/.test(t.type)?(s(Ot.pointerUp,n),n.x+=Ot.sx,n.y+=Ot.sy):(n.x=t.pageX,n.y=t.pageY):ln?(o("screen",t,n),n.x+=e.scrollX,n.y+=e.scrollY):/gesture|inertia/i.test(t.type)?(o("client",t,n),n.x+=st.documentElement.scrollLeft,n.y+=st.documentElement.scrollTop):o("page",t,n),n}function a(e,t){return t=t||{},e instanceof w?/inertiastart/.test(e.type)?(a(Ot.pointerUp,t),t.x+=Ot.sx,t.y+=Ot.sy):(t.x=e.clientX,t.y=e.clientY):o(ln?"screen":"client",e,t),t}function l(){return{x:e.scrollX||st.documentElement.scrollLeft,y:e.scrollY||st.documentElement.scrollTop}}function c(e){var t=/ipad|iphone|ipod/i.test(navigator.userAgent)?{x:0,y:0}:l(),n=e instanceof lt?e.getBoundingClientRect():e.getClientRects()[0];return n&&{left:n.left+t.x,right:n.right+t.x,top:n.top+t.y,bottom:n.bottom+t.y,width:n.width||n.right-n.left,height:n.heigh||n.bottom-n.top}}function p(e){var t=[];return e instanceof Array?(t[0]=e[0],t[1]=e[1]):ht?(t[0]=St[0],t[1]=St[1]):(t[0]=e.touches[0],t[1]="touchend"===e.type&&1===e.touches.length?e.changedTouches[0]:e.touches[1]),t}function d(e){var t=p(e);return{pageX:(t[0].pageX+t[1].pageX)/2,pageY:(t[0].pageY+t[1].pageY)/2,clientX:(t[0].clientX+t[1].clientX)/2,clientY:(t[0].clientY+t[1].clientY)/2}}function u(e){if(e.touches&&e.touches.length||ht&&St.length){var t=p(e),n=Math.min(t[0].pageX,t[1].pageX),i=Math.min(t[0].pageY,t[1].pageY),r=Math.max(t[0].pageX,t[1].pageX),o=Math.max(t[0].pageY,t[1].pageY);return{x:n,y:i,left:n,top:i,width:r-n,height:o-i}}}function h(e){var t=(Pt&&Pt.options||It).deltaSource,n=t+"X",i=t+"Y",r=p(e),o=r[0][n]-r[1][n],s=r[0][i]-r[1][i];return ft(o,s)}function g(e,t){var n=(Pt&&Pt.options||It).deltaSource,i=n+"X",r=n+"Y",o=p(e),s=o[0][i]-o[1][i],a=o[0][r]-o[1][r],l=180*Math.atan(a/s)/Math.PI;if("number"==typeof t){var c=l-t,d=c%360;d>315?l-=360+l/360|0:d>135?l-=180+l/360|0:-315>d?l+=360+l/360|0:-135>d&&(l+=180+l/360|0)}return l}function f(e,t){e=e||Pt;var i=e?e.options.origin:It.origin;return t=t||e._element,"parent"===i?i=t.parentNode:"self"===i&&(i=t),n(i)?(i=c(i),i.x=i.left,i.y=i.top):"function"==typeof i&&(i=i(e&&t)),i}function m(e){for(var t=0,n=e.length;n>t;t++)e[t].rect=e[t].getRect()}function y(){var e=Ot.target.options.inertia,t=e.resistance,n=(new Date).getTime()/1e3-Ot.t0;if(n<Ot.te){var i=1-(Math.exp(-t*n)-Ot.lambda_v0)/Ot.one_ve_v0;if(Ot.modifiedXe===Ot.xe&&Ot.modifiedYe===Ot.ye)Ot.sx=Ot.xe*i,Ot.sy=Ot.ye*i;else{var r=x(0,0,Ot.xe,Ot.ye,Ot.modifiedXe,Ot.modifiedYe,i);Ot.sx=r.x,Ot.sy=r.y}$(Ot.startEvent),Ot.i=pn(y)}else Ot.sx=Ot.modifiedXe,Ot.sy=Ot.modifiedYe,Ot.active=!1,$(Ot.startEvent),K(Ot.startEvent)}function v(e,t,n,i){var r=1-e;return r*r*t+2*r*e*n+e*e*i}function x(e,t,n,i,r,o,s){return{x:v(s,e,n,r),y:v(s,t,i,o)}}function b(e,t){for(;t=t.parentNode;)if(t===e)return!0;return!1}function S(e,t){return e._context===st||b(e._context,t)}function E(e,t){var i=e.options.ignoreFrom;return t&&n(t)?"string"==typeof i?nt(t,i)||E(e,t.parentNode):n(i)?t===i||b(i,t):!1:!1}function z(e,t){if(t){var n=t.options,i=n.preventDefault;if("auto"===i&&!/^input$|^textarea$/i.test(Pt._element.nodeName)){if(/down|start/i.test(e.type)&&"drag"===nn&&"xy"!==n.dragAxis)return;return void e.preventDefault()}return i===!0||"selectstart"===e.type&&/mouse/.test(i)?void e.preventDefault():void 0}}function _(e,t){if(!t)return!1;var n=t.options.dragAxis;return"xy"===e||"xy"===n||n===e}function X(e){if(e.length){var t,n,i,r,o,s=e[0],a=[],l=[];for(r=1;r<e.length;r++)if(t=e[r],s.parentNode!==st){if(t.parentNode!==st){if(!a.length)for(n=s;n.parentNode!==st;)a.unshift(n),n=n.parentNode;if(s instanceof dt&&t instanceof lt&&!(t instanceof ct)){if(t===s.parentNode)continue;n=t.ownerSVGElement}else n=t;for(l=[];n.parentNode!==st;)l.unshift(n),n=n.parentNode;for(o=0;l[o]&&l[o]===a[o];)o++;var c=[l[o-1],l[o],a[o]];for(i=c[0].lastChild;i;){if(i===c[1]){s=t,a=[];break}if(i===c[2])break;i=i.previousSibling}}}else s=t;return{element:s,index:tt(e,s)}}}function Y(e,t){if(Ct.length||Mt.length){var i,r,o,s=[],a=[],l=[],c=[];for(t=t||Pt._element,i=0;i<Ct.length;i++){var p=Ct[i];if(n(p.options.accept)){if(p.options.accept!==t)continue}else if("string"==typeof p.options.accept&&!nt(t,p.options.accept))continue;t!==p._element&&p.dropCheck(e,Pt,t)&&(s.push(p),a.push(p._element))}if(r=X(a),o=r?s[r.index]:null,Mt.length){for(i=0;i<Mt.length;i++)for(var d=Mt[i],u=d._context,h=u.querySelectorAll(d.selector),g=0,f=h.length;f>g;g++){if(d._element=h[g],d.rect=d.getRect(),n(d.options.accept)){if(d.options.accept!==t)continue}else if("string"==typeof d.options.accept&&!nt(t,d.options.accept))continue;d._element!==t&&-1===tt(a,d._element)&&-1===tt(c,d._element)&&d.dropCheck(e,Pt)&&(l.push(d),c.push(d._element))}c.length&&(o&&(l.push(o),c.push(o._element)),r=X(c),r&&(o=l[r.index],o.selector&&(o._element=c[r.index])))}return o?{dropzone:o,element:o._element}:null}}function w(e,t,n,r,o){var l,c,p=(Pt&&Pt.options||It).deltaSource,m=p+"X",y=p+"Y",v=Pt?Pt.options:It,x=f(Pt,r);if(r=r||Pt._element,"gesture"===t){var b=d(e);c={x:b.pageX-x.x,y:b.pageY-x.y},l={x:b.clientX-x.x,y:b.clientY-x.y}}else c=s(e),l=a(e),c.x-=x.x,c.y-=x.y,l.x-=x.x,l.y-=x.y,v.snapEnabled&&-1!==tt(v.snap.actions,t)&&(this.snap={range:Ft.range,locked:Ft.locked,x:Ft.x,y:Ft.y,realX:Ft.realX,realY:Ft.realY,dx:Ft.dx,dy:Ft.dy},Ft.locked&&(c.x+=Ft.dx,c.y+=Ft.dy,l.x+=Ft.dx,l.y+=Ft.dy));if(Pt.options.restrict[t]&&Lt.restricted&&(c.x+=Lt.dx,c.y+=Lt.dy,l.x+=Lt.dx,l.y+=Lt.dy,this.restrict={dx:Lt.dx,dy:Lt.dy}),this.pageX=c.x,this.pageY=c.y,this.clientX=l.x,this.clientY=l.y,"start"!==n||e instanceof w||i(vt,this),this.x0=vt.pageX,this.y0=vt.pageY,this.clientX0=vt.clientX,this.clientY0=vt.clientY,this.ctrlKey=e.ctrlKey,this.altKey=e.altKey,this.shiftKey=e.shiftKey,this.metaKey=e.metaKey,this.button=e.button,this.target=r,this.t0=Et,this.type=t+(n||""),this.interactbale=Pt,Ot.active&&(this.detail="inertia"),o&&(this.relatedTarget=o),_t&&"inertia"===_t.detail&&!Ot.active&&v.inertia.zeroResumeDelta?this.dx=this.dy=0:"end"===n||"drop"===t?"client"===p?(this.dx=l.x-vt.clientX,this.dy=l.y-vt.clientY):(this.dx=c.x-vt.pageX,this.dy=c.y-vt.pageY):"inertiastart"===n?(this.dx=_t.dx,this.dy=_t.dy):"client"===p?(this.dx=l.x-_t.clientX,this.dy=l.y-_t.clientY):(this.dx=c.x-_t.pageX,this.dy=c.y-_t.pageY),"resize"===t?v.squareResize||e.shiftKey?("y"===Zt?this.dx=this.dy:this.dy=this.dx,this.axes="xy"):(this.axes=Zt,"x"===Zt?this.dy=0:"y"===Zt&&(this.dx=0)):"gesture"===t&&(this.touches=ht?[St[0],St[1]]:e.touches,"start"===n?(this.distance=h(e),this.box=u(e),this.scale=1,this.ds=0,this.angle=g(e),this.da=0):"end"===n||e instanceof w?(this.distance=_t.distance,this.box=_t.box,this.scale=_t.scale,this.ds=this.scale-1,this.angle=_t.angle,this.da=this.angle-Tt.startAngle):(this.distance=h(e),this.box=u(e),this.scale=this.distance/Tt.startDistance,this.angle=g(e,Tt.prevAngle),this.ds=this.scale-Tt.prevScale,this.da=this.angle-Tt.prevAngle)),"start"===n)this.timeStamp=Et,this.dt=0,this.duration=0,this.speed=0,this.velocityX=0,this.velocityY=0;else if("inertiastart"===n)this.timeStamp=(new Date).getTime(),this.dt=_t.dt,this.duration=_t.duration,this.speed=_t.speed,this.velocityX=_t.velocityX,this.velocityY=_t.velocityY;else{this.timeStamp=(new Date).getTime(),this.dt=this.timeStamp-_t.timeStamp,this.duration=this.timeStamp-Et;var S,E,z;"end"===n||e instanceof w?(z=Math.max(("end"===n?this.duration:this.dt)/1e3,.001),S=this[m]-_t[m],E=this[y]-_t[y],this.snap&&this.snap.locked&&(S-=this.snap.dx,E-=this.snap.dy),this.restrict&&(S-=this.restrict.dx,E-=this.restrict.dy),_t.snap&&_t.snap.locked&&(S-=_t[m]-_t.snap.dx,E-=_t[y]-_t.snap.dy),_t.restrict&&(S+=_t.restrict.dx,E+=_t.restrict.dy),this.speed=ft(S,E)/z,this.velocityX=S/z,this.velocityY=E/z):(this.speed=xt[p+"Speed"],this.velocityX=xt[p+"VX"],this.velocityY=xt[p+"VY"])}if(("end"===n||"inertiastart"===n)&&_t.speed>600&&this.timeStamp-_t.timeStamp<150){var _=180*Math.atan2(_t.velocityY,_t.velocityX)/Math.PI,X=22.5;0>_&&(_+=360);var Y=_>=135-X&&225+X>_,O=_>=225-X&&315+X>_,T=!Y&&(_>=315-X||45+X>_),A=!O&&_>=45-X&&135+X>_;this.swipe={up:O,down:A,left:Y,right:T,angle:_,speed:_t.speed,velocity:{x:_t.velocityX,y:_t.velocityY}}}}function O(){this.originalEvent.preventDefault()}function T(e,t,n){var i,r,o={};for(i in e)o[i]=e[i];o.preventDefault=O,o.stopPropagation=w.prototype.stopPropagation,o.stopImmediatePropagation=w.prototype.stopImmediatePropagation,o.timeStamp=(new Date).getTime(),o.originalEvent=e,o.dt=o.timeStamp-Et,o.type="tap";var s=o.timeStamp-Xt,a=Yt&&"doubletap"!==Yt.type&&Yt.target===o.target&&500>s;for(Xt=o.timeStamp,r=0;r<t.length;r++){var l=f(t[r],n[r]);if(o.pageX-=l.x,o.pageY-=l.y,o.clientX-=l.x,o.clientY-=l.y,o.currentTarget=n[r],t[r].fire(o),o.immediatePropagationStopped||o.propagationStopped&&t[r+1]!==o.currentTarget)break}if(a){var c={};for(i in o)c[i]=o[i];for(c.dt=s,c.type="doubletap",r=0;r<t.length&&(c.currentTarget=n[r],t[r].fire(c),!(c.immediatePropagationStopped||c.propagationStopped&&t[r+1]!==c.currentTarget));r++);Yt=c}else Yt=o}function A(e){function t(e,t,s){var a=ot?s.querySelectorAll(t):void 0;o!==st&&S(e,o)&&!E(e,r)&&nt(o,t,a)&&(n.push(e),i.push(o))}if(!zt||!Kt&&e instanceof zt.constructor&&zt.target===e.target){for(var n=[],i=[],r=e.target instanceof pt?e.target.correspondingUseElement:e.target,o=r;o;)Q.isSet(o)&&(n.push(Q(o)),i.push(o)),At.forEachSelector(t),o=o.parentNode;n.length&&T(e,n,i)}}function C(e){var t,n,i=this.getRect(),r=null,o=s(e),a=this.options;return i?(tn.resize&&a.resizable&&(t="y"!==a.resizeAxis&&o.x>i.right-Bt,n="x"!==a.resizeAxis&&o.y>i.bottom-Bt),Zt=(t?"x":"")+(n?"y":""),r=Zt?"resize"+Zt:tn.drag&&a.draggable?"drag":null,tn.gesture&&(e.touches&&e.touches.length>=2||ht&&bt.length>=2)&&!Ht&&!Qt&&(r="gesture"),r):null}function M(e,t){if("string"!=typeof e)return null;t=t||Pt;var n=-1!==e.search("resize")?"resize":e,i=(t||Pt).options;return("resize"===n&&i.resizable||"drag"===e&&i.draggable||"gesture"===e&&i.gesturable)&&tn[n]?(("resize"===e||"resizeyx"===e)&&(e="resizexy"),e):null}function D(e){function t(e,t,n){var i=ot?n.querySelectorAll(t):void 0;S(e,o)&&!E(e,r)&&nt(o,t,i)&&(e._element=o,Dt.push(e))}if(nn&&zt&&e.type!==zt.type)return void z(e,Pt);if(!(zt&&"mousedown"===e.type&&"touchstart"===zt.type&&e.timeStamp-zt.timeStamp<300)){var n,r=e.target instanceof pt?e.target.correspondingUseElement:e.target,o=r;if(ht&&j(e),Ot.active&&Pt.selector)for(;o&&o!==st;){if(o===Ot.targetElement&&M(Pt.getAction(e))===nn)return dn(Ot.i),Ot.active=!1,void(ht&&j(e,kt));o=o.parentNode}if(!(Ht||Qt||Wt)){if(Dt.length&&/mousedown|pointerdown/i.test(e.type))n=G(e,Dt);else for(;o&&o!==st&&!n;)Dt=[],At.forEachSelector(t),n=G(e,Dt),o=o.parentNode;return n?(Ut=!0,nn=n,k(e,n)):(Et=(new Date).getTime(),zt=e,i(mt,e),Kt=!1,void 0)}}}function k(e,t){if(!t&&Ut&&zt&&e.type!==zt.type)return void z(e,Pt);if(Ut=!0,ht&&j(e),(e.touches&&e.touches.length<2||bt&&bt.length<2)&&!Pt||!nn){var n=At.get(e.currentTarget);E(n,e.target)||(Pt=n)}var r=Pt&&Pt.options;if(Pt&&!(Ht||Qt||Wt)){var o=M(t||Pt.getAction(e));if(i(vt,e),ht&&e instanceof ht&&(Pt._gesture.target||(Pt._gesture.target=Pt._element),j(e,Pt._gesture)),!o)return e;Kt=!1,r.styleCursor&&(st.documentElement.style.cursor=en[o].cursor),Zt="resizexy"===o?"xy":"resizex"===o?"x":"resizey"===o?"y":"","gesture"===o&&(e.touches&&e.touches.length<2||ht&&bt.length<2)&&(o=null),nn=o,Ft.x=null,Ft.y=null,Et=(new Date).getTime(),zt=e,i(mt,e),Kt=!1,z(e,Pt)}else Ot.active&&e.currentTarget===Ot.targetElement&&Pt===Ot.target&&M(Pt.getAction(e))===nn&&(dn(Ot.i),Ot.active=!1,ht&&(Pt._gesture.target||(Pt._gesture.target=Pt._element),j(e,Pt._gesture)))}function R(e,t){var n,i,r,o,a,l,c,p,d,u,h=Pt.options.snap,g=h.anchors;if(t=t||Ft,t.useStatusXY)n={x:t.x,y:t.y};else{var m=f(Pt);n=s(e),n.x-=m.x,n.y-=m.y}if(t.realX=n.x,t.realY=n.y,h.range<0&&(h.range=1/0),"path"===h.mode)for(g=[],d=0,u=h.paths.length;u>d;d++){var y=h.paths[d];"function"==typeof y&&(y=y(n.x,n.y)),g.push({x:"number"==typeof y.x?y.x:n.x,y:"number"==typeof y.y?y.y:n.y,range:"number"==typeof y.range?y.range:h.range})}if("anchor"!==h.mode&&"path"!==h.mode||!g.length){if("grid"===h.mode){var v=Math.round((n.x-h.gridOffset.x)/h.grid.x),x=Math.round((n.y-h.gridOffset.y)/h.grid.y),b=v*h.grid.x+h.gridOffset.x,S=x*h.grid.y+h.gridOffset.y;l=b-n.x,c=S-n.y,p=ft(l,c),o=p<h.range,a=b!==t.x||S!==t.y,t.x=b,t.y=S,t.dx=l,t.dy=c,t.range=h.range}}else{for(i={anchor:null,distance:0,range:0,dx:0,dy:0},d=0,u=g.length;u>d;d++){var E=g[d];r="number"==typeof E.range?E.range:h.range,l=E.x-n.x,c=E.y-n.y,p=ft(l,c),o=r>p,1/0===r&&i.inRange&&1/0!==i.range&&(o=!1),(!i.anchor||(o?i.inRange&&1/0!==r?p/r<i.distance/i.range:p<i.distance:!i.inRange&&p<i.distance))&&(1/0===r&&(o=!0),i.anchor=E,i.distance=p,i.range=r,i.inRange=o,i.dx=l,i.dy=c,t.range=r)}o=i.inRange,a=i.anchor.x!==t.x||i.anchor.y!==t.y,t.x=i.anchor.x,t.y=i.anchor.y,t.dx=i.dx,t.dy=i.dy}return t.changed=a||o&&!t.locked,t.locked=o,t}function P(e,t){var i,r=Q.currentAction()||nn,o=Pt&&Pt.options.restrict[r];if(t=t||Lt,i=i=t.useStatusXY?{x:t.x,y:t.y}:s(e),t.snap&&t.snap.locked&&(i.x+=t.snap.dx||0,i.y+=t.snap.dy||0),t.dx=0,t.dy=0,t.restricted=!1,!r||!o)return t;var a;return"parent"===o?o=Pt._element.parentNode:"self"===o&&(o=Pt._element),n(o)?a=c(o):("function"==typeof o&&(o=o(i.x,i.y,Pt._element)),a=o,"x"in o&&"y"in o&&(a={left:o.x,top:o.y,right:o.x+o.width,bottom:o.y+o.height})),t.dx=Math.max(Math.min(a.right,i.x),a.left)-i.x,t.dy=Math.max(Math.min(a.bottom,i.y),a.top)-i.y,t.restricted=!0,t}function $(e,t){if(Ut&&(e instanceof w||i(yt,e),nn&&("mousemove"!==e.type||"touchstart"!==zt.type))){var n,o;if(Kt||(n=yt.clientX-vt.clientX,o=yt.clientY-vt.clientY,Kt=ft(n,o)>1),Kt&&(!Ot.active||e instanceof w&&/inertiastart/.test(e.type))){if(!(Ht||Qt||Wt)&&(r(xt,mt,yt),"drag"===nn)){var s=Math.abs(n),a=Math.abs(o),l=Pt.options.dragAxis,c=s>a?"x":a>s?"y":"xy";if("xy"!==c&&"xy"!==l&&l!==c){nn=null;for(var p=e.target instanceof pt?e.target.correspondingUseElement:e.target,d=p;d&&d!==st;){var u=At.get(d);if(u&&u!==Pt&&"drag"===u.getAction(zt)&&_(c,u)){nn="drag",Pt=u;break}d=d.parentNode}if(!nn){var h=function(e,t,n){var i=ot?n.querySelectorAll(t):void 0;if(e!==Pt)return e._element=d,S(e,p)&&!E(e,p)&&nt(d,t,i)&&"drag"===e.getAction(zt)&&_(c,e)?e:void 0};for(d=p;d&&d!==st;){var g=At.forEachSelector(h);if(g){nn="drag",Pt=g;break}d=d.parentNode}}}}if(nn&&Pt){var f=Pt.options.restrictEnabled&&(!Pt.options.restrict.endOnly||t),m=!(Ht||Qt||Wt),y=m?zt:e;m&&(_t=zt),f||(Lt.restricted=!1),!Pt.options.snapEnabled||-1===tt(Pt.options.snap.actions,nn)||Pt.options.snap.endOnly&&!t?(f&&P(e),en[nn].moveListener(e)):(R(y),(Ft.changed||!Ft.locked||f)&&(f&&P(e),en[nn].moveListener(e)))}}e instanceof w||(r(xt,mt,yt),i(mt,e)),(Ht||Qt)&&Gt.edgeMove(e)}}function j(e,t){if(!bt.length||St[0].pointerType===e.pointerType){t&&t.addPointer(e.pointerId);var n=tt(bt,e.pointerId);-1===n?(bt.push(e.pointerId),St[bt.length-1]=e):St[n]=e}}function N(e){var t=tt(bt,e.pointerId);-1!==t&&bt.splice(t,1)}function q(e){var t=tt(bt,e.pointerId);-1!==t&&(/move/i.test(e.type)?St[t]=e:/up|cancel/i.test(e.type)&&(N(e),Wt&&bt.length<2&&Pt._gesture.stop()))}function I(e){z(e,Pt);var t,n,i,r,o;if(!Ht){if(t=new w(zt,"drag","start"),Ht=!0,Pt.fire(t),!Jt){m(Ct);for(var s=0;s<Mt.length;s++){var a=Mt[s],l=a._context;a._elements=l.querySelectorAll(a.selector)}}_t=t,Pt.options.snapEnabled&&!Pt.options.snap.endOnly&&R(e)}t=new w(e,"drag","move");var c=Pt._element,p=Y(t,c);p?(r=p.dropzone,jt=p.element):r=jt=null,Pt._element=c,jt!==qt&&(Nt&&(i=new w(e,"drag","leave",qt,c),t.dragLeave=qt,o=Nt,Nt=qt=null),r&&(n=new w(e,"drag","enter",jt,c),t.dragEnter=r._element,Nt=r,qt=Nt._element)),Pt.fire(t),i&&o.fire(i),n&&r.fire(n),_t=t}function F(e){z(e,Pt);var t;Qt||(t=new w(zt,"resize","start"),Pt.fire(t),Pt.fire(t),Qt=!0,_t=t,Pt.options.snapEnabled&&!Pt.options.snap.endOnly&&R(e)),t=new w(e,"resize","move"),Pt.fire(t),_t=t}function L(e){if(e.touches&&!(e.touches.length<2)||ht){z(e,Pt);var t;Wt||(t=new w(zt,"gesture","start"),t.ds=0,Tt.startDistance=Tt.prevDistance=t.distance,Tt.startAngle=Tt.prevAngle=t.angle,Tt.scale=1,Wt=!0,Pt.fire(t),_t=t,Pt.options.snapEnabled&&!Pt.options.snap.endOnly&&R(e)),t=new w(e,"gesture","move"),t.ds=t.scale-Tt.scale,Pt.fire(t),_t=t,Tt.prevAngle=t.angle,Tt.prevDistance=t.distance,1/0===t.scale||null===t.scale||void 0===t.scale||isNaN(t.scale)||(Tt.scale=t.scale)}}function G(e,t){for(var n=0,i=t.length;i>n;n++){var r=t[n],o=M(r.getAction(e,r),r);if(o)return Pt=r,o}}function V(e){function t(e,t){e&&S(e,r)&&!E(e,r)&&nt(r,t)&&(e._element=r,n.push(e))}if(!(Ut||Ht||Qt||Wt)){var n=[],i=Pt&&Pt._element,r=e.target instanceof pt?e.target.correspondingUseElement:e.target;Pt&&E(Pt,r)&&(Pt=null,Dt=[]);var o=At.get(r),s=o&&!E(o,r)&&M(o.getAction(e),o);if(s)Pt=o,Dt=[];else if(At.forEachSelector(t),G(e,n))Dt=n,U(e,Dt),mn.addToElement(r,"mousemove",U);else if(Pt){var a=i.querySelectorAll("*");if(-1!==tt(a,r)){for(var l=0;l<Dt.length;l++)Dt[l]._element=i;U(e,Dt),mn.addToElement(Pt._element,"mousemove",U)}else Pt=null,Dt=[]}}}function B(e){if(!(Ut||Ht||Qt||Wt)){var t=e.target instanceof pt?e.target.correspondingUseElement:e.target;At.get(t)||mn.removeFromElement(t,U),Pt&&Pt.options.styleCursor&&!(Ht||Qt||Wt)&&(st.documentElement.style.cursor="")}}function U(e,t){if(Ut||Ht||Qt||Wt)nn&&z(e,Pt);else{var n;t?n=G(e,t):Pt&&(n=M(Pt.getAction(e))),Pt&&Pt.options.styleCursor&&(st.documentElement.style.cursor=n?en[n].cursor:"")}}function K(e){if((e instanceof w||ht||!Ut||!zt||e instanceof zt.constructor)&&!(e.touches&&e.touches.length>=2)){if(gt&&e instanceof gt&&/inertiastart/i.test(e.type))return void e.gestureObject.stop();var t,n,i=Pt&&Pt.options.inertia;if(Ht||Qt||Wt){if(Ot.active)return;var r=Pt.options.deltaSource,o=xt[r+"Speed"];if(Pt.options.inertiaEnabled&&"gesture"!==nn&&-1!==tt(i.actions,nn)&&e!==Ot.startEvent&&(new Date).getTime()-yt.timeStamp<50&&o>i.minSpeed&&o>i.endSpeed){var s,a=i.resistance,l=-Math.log(i.endSpeed/o)/a;if(Ot.active=!0,Ot.target=Pt,Ot.targetElement=Pt._element,mn.useAttachEvent)for(n in e)Ot.pointerUp[n]=e[n];else Ot.pointerUp=e;Ot.startEvent=s=new w(e,nn,"inertiastart"),Pt.fire(Ot.startEvent),Ot.vx0=xt[r+"VX"],Ot.vy0=xt[r+"VY"],Ot.v0=o,Ot.x0=_t.pageX,Ot.y0=_t.pageY,Ot.t0=Ot.startEvent.timeStamp/1e3,Ot.sx=Ot.sy=0,Ot.modifiedXe=Ot.xe=(Ot.vx0-l)/a,Ot.modifiedYe=Ot.ye=(Ot.vy0-l)/a,Ot.te=l,Ot.lambda_v0=a/Ot.v0,Ot.one_ve_v0=1-i.endSpeed/Ot.v0;var c,p=s.pageX,d=s.pageY;if(s.snap&&s.snap.locked&&(p-=s.snap.dx,d-=s.snap.dy),s.restrict&&(p-=s.restrict.dx,d-=s.restrict.dy),c={useStatusXY:!0,x:p+Ot.xe,y:d+Ot.ye,dx:0,dy:0,snap:null},c.snap=c,Pt.options.snapEnabled&&Pt.options.snap.endOnly){var u=R(e,c);u.locked&&(Ot.modifiedXe+=u.dx,Ot.modifiedYe+=u.dy)}if(Pt.options.restrictEnabled&&Pt.options.restrict.endOnly){var h=P(e,c);Ot.modifiedXe+=h.dx,Ot.modifiedYe+=h.dy}return dn(Ot.i),void(Ot.i=pn(y))}(Pt.options.snapEnabled&&Pt.options.snap.endOnly||Pt.options.restrictEnabled&&Pt.options.restrict.endOnly)&&$(e,!0)}if(Ht){t=new w(e,"drag","end");var g,f=Pt._element,m=Y(t,f);if(m?($t=m.dropzone,jt=m.element):($t=null,jt=null),Pt._element=f,$t)g=new w(e,"drop",null,jt,f),t.dropzone=jt;else if(Nt){var v=new w(e,"drag","leave",jt,f);Nt.fire(v,f),t.dragLeave=qt}Pt.fire(t),g&&$t.fire(g)}else Qt?(t=new w(e,"resize","end"),Pt.fire(t)):Wt&&(t=new w(e,"gesture","end"),Pt.fire(t));Q.stop()}}function W(e,t){var n={},i=Rt[e.type],r=e.target;t=t?!0:!1;for(var o in e)n[o]=e[o];for(n.originalEvent=e,n.preventDefault=O;r&&r!==st;){for(var s=0;s<i.selectors.length;s++){var a=i.selectors[s],l=i.contexts[s];if(nt(r,a)&&l===e.currentTarget&&b(l,r)){var c=i.listeners[s];n.currentTarget=r;for(var p=0;p<c.length;p++)if(c[p][1]===t)try{c[p][0](n)}catch(d){at.error('Error thrown from delegated listener: "'+a+'" '+e.type+" "+(c[p][0].name?c[p][0].name:"")),at.log(d)}}}r=r.parentNode}}function H(e){return W.call(this,e,!0)}function J(){Pt&&!Pt.selector&&(Pt=null),$t=jt=Nt=qt=null}function Q(e,t){return At.get(e,t)||new et(e,t)}function Z(e){for(var t in It)e.hasOwnProperty(t)&&typeof e[t]==typeof It[t]&&(this[t]=e[t])}function et(t,i){this._element=t,this._iEvents=this._iEvents||{},"string"==typeof t?(st.querySelector(t),this.selector=t,this._gesture=kt,i&&i.context&&(e.Node?i.context instanceof e.Node:n(i.context)||i.context===st)&&(this._context=i.context)):n(t)&&(ht?(mn.add(this,it.down,k),mn.add(this,it.move,U),this._gesture=new ut,this._gesture.target=t):(mn.add(this,"mousedown",k),mn.add(this,"mousemove",U),mn.add(this,"touchstart",k),mn.add(this,"touchmove",U))),At.push(this),this.set(i)}function tt(e,t){for(var n=0,i=e.length;i>n;n++)if(e[n]===t)return n;return-1}function nt(e,t,n){return ot?ot(e,t,n):e[cn](t)}var it,rt,ot,st=e.document,at=e.console,lt=e.SVGElement||t,ct=e.SVGSVGElement||t,pt=e.SVGElementInstance||t,dt=e.HTMLElement||e.Element,ut=e.Gesture||e.MSGesture,ht=ut&&(e.PointerEvent||e.MSPointerEvent),gt=ut&&(e.GestureEvent||e.MSGestureEvent),ft=Math.hypot||function(e,t){return Math.sqrt(e*e+t*t)},mt={pageX:0,pageY:0,clientX:0,clientY:0,timeStamp:0},yt={pageX:0,pageY:0,clientX:0,clientY:0,timeStamp:0},vt={pageX:0,pageY:0,clientX:0,clientY:0,timeStamp:0},xt={pageX:0,pageY:0,clientX:0,clientY:0,timeStamp:0,pageSpeed:0,clientSpeed:0},bt=ht?[]:null,St=ht?[]:null,Et=0,zt=null,_t=null,Xt=0,Yt=null,wt={},Ot={active:!1,target:null,targetElement:null,startEvent:null,pointerUp:{},xe:0,ye:0,duration:0,t0:0,vx0:0,vys:0,lambda_v0:0,one_ve_v0:0,i:null},Tt={start:{x:0,y:0},startDistance:0,prevDistance:0,distance:0,scale:1,startAngle:0,prevAngle:0},At=[],Ct=[],Mt=[],Dt=[],kt=null,Rt={},Pt=null,$t=null,jt=null,Nt=null,qt=null,It={draggable:!1,dragAxis:"xy",dropzone:!1,accept:null,resizable:!1,squareResize:!1,resizeAxis:"xy",gesturable:!1,actionChecker:null,styleCursor:!0,preventDefault:"auto",snap:{mode:"grid",endOnly:!1,actions:["drag"],range:1/0,grid:{x:100,y:100},gridOffset:{x:0,y:0},anchors:[],paths:[],arrayTypes:/^anchors$|^paths$|^actions$/,objectTypes:/^grid$|^gridOffset$/,stringTypes:/^mode$/,numberTypes:/^range$/,boolTypes:/^endOnly$/},snapEnabled:!1,restrict:{drag:null,resize:null,gesture:null,endOnly:!1},restrictEnabled:!0,autoScroll:{container:e,margin:60,speed:300,numberTypes:/^margin$|^speed$/},autoScrollEnabled:!1,inertia:{resistance:10,minSpeed:100,endSpeed:10,actions:["drag","resize"],zeroResumeDelta:!1,numberTypes:/^resistance$|^minSpeed$|^endSpeed$/,arrayTypes:/^actions$/,boolTypes:/^zeroResumeDelta$/},inertiaEnabled:!1,origin:{x:0,y:0},deltaSource:"page",context:st},Ft={locked:!1,x:0,y:0,dx:0,dy:0,realX:0,realY:0,anchors:[],paths:[]},Lt={dx:0,dy:0,snap:Ft,restricted:!1},Gt={target:null,i:null,x:0,y:0,scroll:function(){var t=Gt.target.options.autoScroll,n=t.container,i=(new Date).getTime(),r=(i-Gt.prevTime)/1e3,o=t.speed*r;o>=1&&(n instanceof e.Window?n.scrollBy(Gt.x*o,Gt.y*o):n&&(n.scrollLeft+=Gt.x*o,n.scrollTop+=Gt.y*o),Gt.prevTime=i),Gt.isScrolling&&(dn(Gt.i),Gt.i=pn(Gt.scroll))},edgeMove:function(t){if(Pt&&Pt.options.autoScrollEnabled&&(Ht||Qt)){var n,i,r,o,s=Pt.options.autoScroll;if(s.container instanceof e.Window)o=t.clientX<Gt.margin,n=t.clientY<Gt.margin,i=t.clientX>s.container.innerWidth-Gt.margin,r=t.clientY>s.container.innerHeight-Gt.margin;else{var a=c(s.container);o=t.clientX<a.left+Gt.margin,n=t.clientY<a.top+Gt.margin,i=t.clientX>a.right-Gt.margin,r=t.clientY>a.bottom-Gt.margin}Gt.x=i?1:o?-1:0,Gt.y=r?1:n?-1:0,Gt.isScrolling||(Gt.margin=s.margin,Gt.speed=s.speed,Gt.start(Pt))}},isScrolling:!1,prevTime:0,start:function(e){Gt.isScrolling=!0,dn(Gt.i),Gt.target=e,Gt.prevTime=(new Date).getTime(),Gt.i=pn(Gt.scroll)},stop:function(){Gt.isScrolling=!1,dn(Gt.i)}},Vt="createTouch"in st,Bt=Vt?20:10,Ut=!1,Kt=!1,Wt=!1,Ht=!1,Jt=!1,Qt=!1,Zt="xy",en={drag:{cursor:"move",moveListener:I},resizex:{cursor:"e-resize",moveListener:F},resizey:{cursor:"s-resize",moveListener:F},resizexy:{cursor:"se-resize",moveListener:F},gesture:{cursor:"",moveListener:L}},tn={drag:!0,resize:!0,gesture:!0},nn=null,rn="onmousewheel"in st?"mousewheel":"wheel",on=["dragstart","dragmove","draginertiastart","dragend","dragenter","dragleave","drop","resizestart","resizemove","resizeinertiastart","resizeend","gesturestart","gesturemove","gestureinertiastart","gestureend","tap","doubletap"],sn={},an={directBind:0,onevent:1,globalBind:2},ln="Opera"==navigator.appName&&Vt&&navigator.userAgent.match("Presto"),cn="matchesSelector"in Element.prototype?"matchesSelector":"webkitMatchesSelector"in Element.prototype?"webkitMatchesSelector":"mozMatchesSelector"in Element.prototype?"mozMatchesSelector":"oMatchesSelector"in Element.prototype?"oMatchesSelector":"msMatchesSelector",pn=e.requestAnimationFrame,dn=e.cancelAnimationFrame,un={_element:e,events:{}},hn={_element:st,events:{}},gn={_element:e.parent,events:{}},fn={_element:null,events:{}},mn=function(){function t(e,t,n,c){var g=i(d,e),f=u[g];if(f||(f={events:{},typeCount:0},g=d.push(e)-1,u.push(f),h.push(a?{supplied:[],wrapped:[],useCount:[]}:null)),f.events[t]||(f.events[t]=[],f.typeCount++),-1===i(f.events[t],n)){var m;if(a){var y=h[g],v=i(y.supplied,n),x=y.wrapped[v]||function(t){t.immediatePropagationStopped||(t.target=t.srcElement,t.currentTarget=e,t.preventDefault=t.preventDefault||r,t.stopPropagation=t.stopPropagation||o,t.stopImmediatePropagation=t.stopImmediatePropagation||s,/mouse|click/.test(t.type)&&(t.pageX=t.clientX+st.documentElement.scrollLeft,t.pageY=t.clientY+st.documentElement.scrollTop),n(t))};m=e[l](p+t,x,Boolean(c)),-1===v?(y.supplied.push(n),y.wrapped.push(x),y.useCount.push(1)):y.useCount[v]++}else m=e[l](t,n,c||!1);return f.events[t].push(n),m}}function n(e,t,r,o){var s,l,g,f=i(d,e),m=u[f],y=r;if(m&&m.events)if(a&&(l=h[f],g=i(l.supplied,r),y=l.wrapped[g]),"all"!==t){if(m.events[t]){var v=m.events[t].length;if("all"===r)for(s=0;v>s;s++)n(e,t,m.events[t][s],Boolean(o));else for(s=0;v>s;s++)if(m.events[t][s]===r){e[c](p+t,y,o||!1),m.events[t].splice(s,1),a&&l&&(l.useCount[g]--,0===l.useCount[g]&&(l.supplied.splice(g,1),l.wrapped.splice(g,1),l.useCount.splice(g,1)));break}m.events[t]&&0===m.events[t].length&&(m.events[t]=null,m.typeCount--)}m.typeCount||(u.splice(f),d.splice(f),h.splice(f))}else for(t in m.events)m.events.hasOwnProperty(t)&&n(e,t,"all")}function i(e,t){for(var n=0,i=e.length;i>n;n++)if(e[n]===t)return n;return-1}function r(){this.returnValue=!1}function o(){this.cancelBubble=!0}function s(){this.cancelBubble=!0,this.immediatePropagationStopped=!0}var a="attachEvent"in e&&!("addEventListener"in e),l=a?"attachEvent":"addEventListener",c=a?"detachEvent":"removeEventListener",p=a?"on":"",d=[],u=[],h=[];return{add:function(e,n,i,r){t(e._element,n,i,r)},remove:function(e,t,i,r){n(e._element,t,i,r)},addToElement:t,removeFromElement:n,useAttachEvent:a,indexOf:i}}();w.prototype={preventDefault:t,stopImmediatePropagation:function(){this.immediatePropagationStopped=this.propagationStopped=!0},stopPropagation:function(){this.propagationStopped=!0}},At.indexOfElement=Ct.indexOfElement=function(e,t){for(var n=0;n<this.length;n++){var i=this[n];if(i.selector===e&&i._context===(t||st)||!i.selector&&i._element===e)return n}return-1},At.get=Ct.get=function(e,t){return this[this.indexOfElement(e,t&&t.context)]},At.forEachSelector=function(e){for(var t=0;t<this.length;t++){var n=this[t];if(n.selector){var i=e(n,n.selector,n._context,t,this);if(void 0!==i)return i}}},Z.prototype=It,et.prototype={setOnEvents:function(e,t){if("drop"===e){var n=t.ondrop||t.onDrop||t.drop,i=t.ondragenter||t.onDropEnter||t.dragenter,r=t.ondragleave||t.onDropLeave||t.dragleave;"function"==typeof n&&(this.ondrop=n),"function"==typeof i&&(this.ondragenter=i),"function"==typeof r&&(this.ondragleave=r)}else{var o=t.onstart||t.onStart||t.start,s=t.onmove||t.onMove||t.move,a=t.onend||t.onEnd||t.end,l=t.oninertiastart||t.onInertiaStart||t.inertiastart;e="on"+e,"function"==typeof o&&(this[e+"start"]=o),"function"==typeof s&&(this[e+"move"]=s),"function"==typeof a&&(this[e+"end"]=a),"function"==typeof l&&(this[e+"inertiastart"]=l)}return this},draggable:function(e){return e instanceof Object?(this.options.draggable=!0,this.setOnEvents("drag",e),/^x$|^y$|^xy$/.test(e.axis)?this.options.dragAxis=e.axis:null===e.axis&&delete this.options.dragAxis,this):"boolean"==typeof e?(this.options.draggable=e,this):null===e?(delete this.options.draggable,this):this.options.draggable},dropzone:function(e){if(e instanceof Object)return this.options.dropzone=!0,this.setOnEvents("drop",e),this.accept(e.accept),(this.selector?Mt:Ct).push(this),Jt||this.selector||(this.rect=this.getRect()),this;if("boolean"==typeof e){if(e)(this.selector?Mt:Ct).push(this),Jt||this.selector||(this.rect=this.getRect());else{var t=this.selector?Mt:Ct,n=tt(t,this);-1!==n&&t.splice(n,1)}return this.options.dropzone=e,this}return null===e?(delete this.options.dropzone,this):this.options.dropzone},dropCheck:function(e,t,n){var i,r,o=s(e),a=f(t,n);return o.x+=a.x,o.y+=a.y,Jt&&(this.rect=this.getRect()),this.rect?(i=o.x>this.rect.left&&o.x<this.rect.right,r=o.y>this.rect.top&&o.y<this.rect.bottom,i&&r):!1},dropChecker:function(e){return"function"==typeof e?(this.dropCheck=e,this):this.dropCheck},accept:function(e){return n(e)?(this.options.accept=e,this):"string"==typeof e?(st.querySelector(e),this.options.accept=e,this):null===e?(delete this.options.accept,this):this.options.accept},resizable:function(e){return e instanceof Object?(this.options.resizable=!0,this.setOnEvents("resize",e),/^x$|^y$|^xy$/.test(e.axis)?this.options.resizeAxis=e.axis:null===e.axis&&(this.options.resizeAxis=It.resizeAxis),this):"boolean"==typeof e?(this.options.resizable=e,this):this.options.resizable},resizeable:t,squareResize:function(e){return"boolean"==typeof e?(this.options.squareResize=e,this):null===e?(delete this.options.squareResize,this):this.options.squareResize},gesturable:function(e){return e instanceof Object?(this.options.gesturable=!0,this.setOnEvents("gesture",e),this):"boolean"==typeof e?(this.options.gesturable=e,this):null===e?(delete this.options.gesturable,this):this.options.gesturable},gestureable:t,autoScroll:function(t){var i=It.autoScroll;if(t instanceof Object){var r=this.options.autoScroll;return r===i&&(r=this.options.autoScroll={margin:i.margin,distance:i.distance,interval:i.interval,container:i.container}),r.margin=this.validateSetting("autoScroll","margin",t.margin),r.speed=this.validateSetting("autoScroll","speed",t.speed),r.container=n(t.container)||t.container instanceof e.Window?t.container:i.container,this.options.autoScrollEnabled=!0,this.options.autoScroll=r,this}return"boolean"==typeof t?(this.options.autoScrollEnabled=t,this):null===t?(delete this.options.autoScrollEnabled,delete this.options.autoScroll,this):this.options.autoScrollEnabled?this.options.autoScroll:!1},snap:function(e){var t=It.snap;if(e instanceof Object){var n=this.options.snap;return n===t&&(n={}),n.mode=this.validateSetting("snap","mode",e.mode),n.endOnly=this.validateSetting("snap","endOnly",e.endOnly),n.actions=this.validateSetting("snap","actions",e.actions),n.range=this.validateSetting("snap","range",e.range),n.paths=this.validateSetting("snap","paths",e.paths),n.grid=this.validateSetting("snap","grid",e.grid),n.gridOffset=this.validateSetting("snap","gridOffset",e.gridOffset),n.anchors=this.validateSetting("snap","anchors",e.anchors),this.options.snapEnabled=!0,this.options.snap=n,this
  }return"boolean"==typeof e?(this.options.snapEnabled=e,this):null===e?(delete this.options.snapEnabled,delete this.options.snap,this):this.options.snapEnabled?this.options.snap:!1},inertia:function(e){var t=It.inertia;if(e instanceof Object){var n=this.options.inertia;return n===t&&(n=this.options.inertia={resistance:t.resistance,minSpeed:t.minSpeed,endSpeed:t.endSpeed,actions:t.actions,zeroResumeDelta:t.zeroResumeDelta}),n.resistance=this.validateSetting("inertia","resistance",e.resistance),n.minSpeed=this.validateSetting("inertia","minSpeed",e.minSpeed),n.endSpeed=this.validateSetting("inertia","endSpeed",e.endSpeed),n.actions=this.validateSetting("inertia","actions",e.actions),n.zeroResumeDelta=this.validateSetting("inertia","zeroResumeDelta",e.zeroResumeDelta),this.options.inertiaEnabled=!0,this.options.inertia=n,this}return"boolean"==typeof e?(this.options.inertiaEnabled=e,this):null===e?(delete this.options.inertiaEnabled,delete this.options.inertia,this):this.options.inertiaEnabled?this.options.inertia:!1},getAction:function(e){var t=this.defaultActionChecker(e);return this.options.actionChecker&&(t=this.options.actionChecker(e,t,this)),t},defaultActionChecker:C,actionChecker:function(e){return"function"==typeof e?(this.options.actionChecker=e,this):null===e?(delete this.options.actionChecker,this):this.options.actionChecker},getRect:function(){return this.selector&&!n(this._element)&&(this._element=this._context.querySelector(this.selector)),c(this._element)},rectChecker:function(e){return"function"==typeof e?(this.getRect=e,this):null===e?(delete this.options.getRect,this):this.getRect},styleCursor:function(e){return"boolean"==typeof e?(this.options.styleCursor=e,this):null===e?(delete this.options.styleCursor,this):this.options.styleCursor},preventDefault:function(e){return"boolean"==typeof e||"auto"===e?(this.options.styleCursor=e,this):null===e?(delete this.options.styleCursor,this):this.options.styleCursor},origin:function(e){return e instanceof Object||/^parent$|^self$/.test(e)?(this.options.origin=e,this):null===e?(delete this.options.origin,this):this.options.origin},deltaSource:function(e){return"page"===e||"client"===e?(this.options.deltaSource=e,this):null===e?(delete this.options.deltaSource,this):this.options.deltaSource},restrict:function(e){if(void 0===e)return this.options.restrict;if(e instanceof Object){var t={};(e.drag instanceof Object||/^parent$|^self$/.test(e.drag))&&(t.drag=e.drag),(e.resize instanceof Object||/^parent$|^self$/.test(e.resize))&&(t.resize=e.resize),(e.gesture instanceof Object||/^parent$|^self$/.test(e.gesture))&&(t.gesture=e.gesture),"boolean"==typeof e.endOnly&&(t.endOnly=e.endOnly),this.options.restrictEnabled=!0,this.options.restrict=t}else null===e&&(delete this.options.restrict,delete this.options.restrictEnabled);return this},context:function(){return this._context},_context:st,ignoreFrom:function(e){return"string"==typeof e||n(e)?(this.options.ignoreFrom=e,this):null===e?(delete this.options.ignoreFrom,this):this.options.ignoreFrom},validateSetting:function(e,t,i){var r=It[e],o=this.options[e];if(void 0!==r&&void 0!==r[t]){if("objectTypes"in r&&r.objectTypes.test(t))return i instanceof Object?i:t in o&&o[t]instanceof Object?o[t]:r[t];if("arrayTypes"in r&&r.arrayTypes.test(t))return i instanceof Array?i:t in o&&o[t]instanceof Array?o[t]:r[t];if("stringTypes"in r&&r.stringTypes.test(t))return"string"==typeof i?i:t in o&&"string"==typeof o[t]?o[t]:r[t];if("numberTypes"in r&&r.numberTypes.test(t))return"number"==typeof i?i:t in o&&"number"==typeof o[t]?o[t]:r[t];if("boolTypes"in r&&r.boolTypes.test(t))return"boolean"==typeof i?i:t in o&&"boolean"==typeof o[t]?o[t]:r[t];if("elementTypes"in r&&r.elementTypes.test(t))return n(i)?i:t in o&&n(o[t])?o[t]:r[t]}return null},element:function(){return this._element},fire:function(e){if(!e||!e.type||-1===tt(on,e.type))return this;for(var t,n,i=0,r=0,o="on"+e.type;3>i;)try{switch(i){case an.directBind:if(e.type in this._iEvents){for(t=this._iEvents[e.type],n=t.length;n>r&&!e.immediatePropagationStopped;r++)t[r](e);break}break;case an.onevent:"function"==typeof this[o]&&this[o](e);break;case an.globalBind:if(e.type in sn&&(t=sn[e.type]))for(n=t.length;n>r&&!e.immediatePropagationStopped;r++)t[r](e)}if(e.propagationStopped)break;r=0,i++}catch(s){at.error("Error thrown from "+e.type+" listener"),at.error(s),r++,i===an.onevent&&i++}return this},on:function(e,t,n){if("wheel"===e&&(e=rn),n=n?!0:!1,-1!==tt(on,e))e in this._iEvents?-1===tt(this._iEvents[e],t)&&this._iEvents[e].push(t):this._iEvents[e]=[t];else if(this.selector){Rt[e]||(Rt[e]={selectors:[],contexts:[],listeners:[]},mn.addToElement(this._context,e,W),mn.addToElement(this._context,e,H,!0));var i,r=Rt[e];for(i=r.selectors.length-1;i>=0&&(r.selectors[i]!==this.selector||r.contexts[i]!==this._context);i--);-1===i&&(i=r.selectors.length,r.selectors.push(this.selector),r.contexts.push(this._context),r.listeners.push([])),r.listeners[i].push([t,n])}else mn.add(this,e,t,n);return this},off:function(e,t,n){var i,r=-1;if(n=n?!0:!1,"wheel"===e&&(e=rn),-1!==tt(on,e))i=this._iEvents[e],i&&-1!==(r=tt(i,t))&&this._iEvents[e].splice(r,1);else if(this.selector){var o=Rt[e],s=!1;if(!o)return this;for(r=o.selectors.length-1;r>=0;r--)if(o.selectors[r]===this.selector&&o.contexts[r]===this._context){for(var a=o.listeners[r],l=a.length-1;l>=0;l--){var c=a[l][0],p=a[l][1];if(c===t&&p===n){a.splice(l,1),a.length||(o.selectors.splice(r,1),o.contexts.splice(r,1),o.listeners.splice(r,1),mn.removeFromElement(this._context,e,W),mn.removeFromElement(this._context,e,H,!0),o.selectors.length||(Rt[e]=null)),s=!0;break}}if(s)break}}else mn.remove(this,t,n);return this},set:function(e){e&&"object"==typeof e||(e={}),this.options=new Z(e),this.draggable("draggable"in e?e.draggable:this.options.draggable),this.dropzone("dropzone"in e?e.dropzone:this.options.dropzone),this.resizable("resizable"in e?e.resizable:this.options.resizable),this.gesturable("gesturable"in e?e.gesturable:this.options.gesturable);for(var t=["accept","actionChecker","autoScroll","dropChecker","ignoreFrom","inertia","origin","rectChecker","restrict","snap"],n=0,i=t.length;i>n;n++){var r=t[n];r in e&&this[r](e[r])}return this},unset:function(){if(mn.remove(this,"all"),"string"!=typeof this.selector)mn.remove(this,"all"),this.options.styleCursor&&(this._element.style.cursor=""),this._gesture&&(this._gesture.target=null);else for(var e in Rt)for(var t=Rt[e],n=0;n<t.selectors.length;n++){t.selectors[n]===this.selector&&t.contexts[n]===this._context&&(t.selectors.splice(n,1),t.contexts.splice(n,1),t.listeners.splice(n,1),t.selectors.length||(Rt[e]=null)),mn.removeFromElement(this._context,e,W),mn.removeFromElement(this._context,e,H,!0);break}return this.dropzone(!1),At.splice(tt(At,this),1),Q}},et.prototype.gestureable=et.prototype.gesturable,et.prototype.resizeable=et.prototype.resizable,Q.isSet=function(e,t){return-1!==tt(At,e,t&&t.context)},Q.on=function(e,t,n){return-1!==tt(on,e)?sn[e]?-1===tt(sn[e],t)&&sn[e].push(t):sn[e]=[t]:mn.add(hn,e,t,n),Q},Q.off=function(e,t,n){if(-1===tt(on,e))mn.remove(hn,e,t,n);else{var i;e in sn&&-1!==(i=tt(sn[e],t))&&sn[e].splice(i,1)}return Q},Q.simulate=function(e,n,i){var r,o,s={};if("resize"===e&&(e="resizexy"),!(e in en))return Q;if(i)for(r in i)s[r]=i[r];else o=Pt._element instanceof lt?n.getBoundingClientRect():o=n.getClientRects()[0],"drag"===e?(s.pageX=o.left+o.width/2,s.pageY=o.top+o.height/2):(s.pageX=o.right,s.pageY=o.bottom);return s.target=s.currentTarget=n,s.preventDefault=s.stopPropagation=t,k(s,e),Q},Q.enableDragging=function(e){return null!==e&&void 0!==e?(tn.drag=e,Q):tn.drag},Q.enableResizing=function(e){return null!==e&&void 0!==e?(tn.resize=e,Q):tn.resize},Q.enableGesturing=function(e){return null!==e&&void 0!==e?(tn.gesture=e,Q):tn.gesture},Q.eventTypes=on,Q.debug=function(){return{target:Pt,dragging:Ht,resizing:Qt,gesturing:Wt,prepared:nn,matches:Dt,prevCoords:mt,downCoords:vt,pointerIds:bt,pointerMoves:St,addPointer:j,removePointer:N,recordPointers:q,inertia:Ot,downTime:Et,downEvent:zt,prevEvent:_t,Interactable:et,IOptions:Z,interactables:At,dropzones:Ct,pointerIsDown:Ut,defaultOptions:It,defaultActionChecker:C,actions:en,dragMove:I,resizeMove:F,gestureMove:L,pointerUp:K,pointerDown:k,pointerMove:$,pointerHover:U,events:mn,globalEvents:sn,delegatedEvents:Rt}},Q.getTouchAverage=d,Q.getTouchBBox=u,Q.getTouchDistance=h,Q.getTouchAngle=g,Q.getElementRect=c,Q.margin=function(e){return"number"==typeof e?(Bt=e,Q):Bt},Q.styleCursor=function(e){return"boolean"==typeof e?(It.styleCursor=e,Q):It.styleCursor},Q.autoScroll=function(t){var i=It.autoScroll;return t instanceof Object?(It.autoScrollEnabled=!0,"number"==typeof t.margin&&(i.margin=t.margin),"number"==typeof t.speed&&(i.speed=t.speed),i.container=n(t.container)||t.container instanceof e.Window?t.container:i.container,Q):"boolean"==typeof t?(It.autoScrollEnabled=t,Q):It.autoScrollEnabled?i:!1},Q.snap=function(e){var t=It.snap;return e instanceof Object?(It.snapEnabled=!0,"string"==typeof e.mode&&(t.mode=e.mode),"boolean"==typeof e.endOnly&&(t.endOnly=e.endOnly),"number"==typeof e.range&&(t.range=e.range),e.actions instanceof Array&&(t.actions=e.actions),e.anchors instanceof Array&&(t.anchors=e.anchors),e.grid instanceof Object&&(t.grid=e.grid),e.gridOffset instanceof Object&&(t.gridOffset=e.gridOffset),Q):"boolean"==typeof e?(It.snapEnabled=e,Q):{enabled:It.snapEnabled,mode:t.mode,actions:t.actions,grid:t.grid,gridOffset:t.gridOffset,anchors:t.anchors,paths:t.paths,range:t.range,locked:Ft.locked,x:Ft.x,y:Ft.y,realX:Ft.realX,realY:Ft.realY,dx:Ft.dx,dy:Ft.dy}},Q.inertia=function(e){var t=It.inertia;return e instanceof Object?(It.inertiaEnabled=!0,"number"==typeof e.resistance&&(t.resistance=e.resistance),"number"==typeof e.minSpeed&&(t.minSpeed=e.minSpeed),"number"==typeof e.endSpeed&&(t.endSpeed=e.endSpeed),"boolean"==typeof e.zeroResumeDelta&&(t.zeroResumeDelta=e.zeroResumeDelta),e.actions instanceof Array&&(t.actions=e.actions),Q):"boolean"==typeof e?(It.inertiaEnabled=e,Q):{enabled:It.inertiaEnabled,resistance:t.resistance,minSpeed:t.minSpeed,endSpeed:t.endSpeed,actions:t.actions,zeroResumeDelta:t.zeroResumeDelta}},Q.supportsTouch=function(){return Vt},Q.currentAction=function(){return Ht&&"drag"||Qt&&"resize"||Wt&&"gesture"||null},Q.stop=function(e){if(Ht||Qt||Wt){Gt.stop(),Dt=[],Pt.options.styleCursor&&(st.documentElement.style.cursor=""),Pt._gesture&&Pt._gesture.stop();for(var t=0;t<Mt.length;t++)Mt._elements=[];e&&"function"==typeof e.preventDefault&&z(e,Pt),J()}return bt&&bt.length&&(bt.splice(0),St.splice(0)),Ut=Ft.locked=Ht=Qt=Wt=!1,nn=_t=null,Q},Q.dynamicDrop=function(e){return"boolean"==typeof e?(Ht&&Jt!==e&&!e&&m(Ct),Jt=e,Q):Jt},Q.deltaSource=function(e){return"page"===e||"client"===e?(It.deltaSource=e,this):It.deltaSource},Q.restrict=function(e){var t=It.restrict;return void 0===e?It.restrict:(e instanceof Object?((e.drag instanceof Object||/^parent$|^self$/.test(e.drag))&&(t.drag=e.drag),(e.resize instanceof Object||/^parent$|^self$/.test(e.resize))&&(t.resize=e.resize),(e.gesture instanceof Object||/^parent$|^self$/.test(e.gesture))&&(t.gesture=e.gesture),"boolean"==typeof e.endOnly&&(t.endOnly=e.endOnly)):null===e&&(t.drag=t.resize=t.gesture=null,t.endOnly=!1),this)},ht?(it=ht===e.MSPointerEvent?{up:"MSPointerUp",down:"MSPointerDown",over:"MSPointerOver",out:"MSPointerOut",move:"MSPointerMove",cancel:"MSPointerCancel"}:{up:"pointerup",down:"pointerdown",over:"pointerover",out:"pointerout",move:"pointermove",cancel:"pointercancel"},rt=gt===e.MSGestureEvent?{start:"MSGestureStart",change:"MSGestureChange",inertia:"MSInertiaStart",end:"MSGestureEnd"}:{start:"gesturestart",change:"gesturechange",inertia:"inertiastart",end:"gestureend"},mn.add(hn,it.up,A),mn.add(hn,it.down,D),mn.add(hn,rt.change,$),mn.add(hn,rt.end,K),mn.add(hn,rt.inertia,K),mn.add(hn,it.over,V),mn.add(hn,it.out,B),mn.add(hn,it.move,q),mn.add(hn,it.up,q),mn.add(hn,it.cancel,q),mn.add(hn,it.up,function(){Ht||Qt||Wt||(Ut=!1)}),kt=new ut,kt.target=st.documentElement):(mn.add(hn,"mouseup",A),mn.add(hn,"touchend",A),mn.add(hn,"mousedown",D),mn.add(hn,"mousemove",$),mn.add(hn,"mouseup",K),mn.add(hn,"mouseover",V),mn.add(hn,"mouseout",B),mn.add(hn,"touchstart",D),mn.add(hn,"touchmove",$),mn.add(hn,"touchend",K),mn.add(hn,"touchcancel",K)),mn.add(un,"blur",K);try{e.frameElement&&(fn._element=e.frameElement.ownerDocument,mn.add(fn,"mouseup",K),mn.add(fn,"touchend",K),mn.add(fn,"touchcancel",K),mn.add(fn,"pointerup",K),mn.add(fn,"MSPointerUp",K),mn.add(gn,"blur",K))}catch(yn){Q.windowParentError=yn}mn.add(hn,"selectstart",function(e){(Ht||Qt||Wt)&&z(e,Pt)}),cn in Element.prototype&&"function"==typeof Element.prototype[cn]||(ot=function(e,t,n){n=n||e.parentNode.querySelectorAll(t);for(var i=0,r=n.length;r>i;i++)if(n[i]===e)return!0;return!1}),function(){for(var t=0,n=["ms","moz","webkit","o"],i=0;i<n.length&&!e.requestAnimationFrame;++i)pn=e[n[i]+"RequestAnimationFrame"],dn=e[n[i]+"CancelAnimationFrame"]||e[n[i]+"CancelRequestAnimationFrame"];pn||(pn=function(n){var i=(new Date).getTime(),r=Math.max(0,16-(i-t)),o=e.setTimeout(function(){n(i+r)},r);return t=i+r,o}),dn||(dn=function(e){clearTimeout(e)})}(),"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=Q),exports.interact=Q):"function"==typeof define&&define.amd?define("interact",function(){return Q}):e.interact=Q}(this);
  