text: (typeof define=="function"&&define.amd?define:function(t,e,i){(i||e)()})("kendo.userevents",["kendo.core"],function(){return function(t,e){function i(t,e){var i=t.x.location,n=t.y.location,s=e.x.location,o=e.y.location,r=i-s,a=n-o;return{center:{x:(i+s)/2,y:(n+o)/2},distance:Math.sqrt(r*r+a*a)}}function n(t){var e,i,n,s=[],o=t.originalEvent,a=t.currentTarget,h=0;if(t.api)s.push({id:2,event:t,target:t.target,currentTarget:t.target,location:t,type:"api"});else if(t.type.match(/touch/))for(e=(i=o?o.changedTouches:[]).length;h<e;h++)n=i[h],s.push({location:n,event:t,target:n.target,currentTarget:a,id:n.identifier,type:"touch"});else r.pointers||r.msPointers?s.push({location:o,event:t,target:t.target,currentTarget:a,id:o.pointerId,type:"pointer"}):s.push({id:1,event:t,target:t.target,currentTarget:a,location:t,type:"mouse"});return s}function s(t){for(var e=o.eventMap.up.split(" "),i=0,n=e.length;i<n;i++)t(e[i])}var o=window.kendo,r=o.support,a=o.Class,h=o.Observable,c=t.now,u=t.extend,l=r.mobileOS,p=l&&l.android,d=800,f=r.browser.msie?5:0,g={api:0,touch:0,mouse:9,pointer:9},v=!r.touch||r.mouseAndTouchPresent,m=a.extend({init:function(t,e){this.axis=t,this._updateLocationData(e),this.startLocation=this.location,this.velocity=this.delta=0,this.timeStamp=c()},move:function(t){var e=t["page"+this.axis],i=c(),n=i-this.timeStamp||1;!e&&p||(this.delta=e-this.location,this._updateLocationData(t),this.initialDelta=e-this.startLocation,this.velocity=this.delta/n,this.timeStamp=i)},_updateLocationData:function(t){var e=this.axis;this.location=t["page"+e],this.client=t["client"+e],this.screen=t["screen"+e]}}),_=a.extend({init:function(t,e,i){u(this,{x:new m("X",i.location),y:new m("Y",i.location),type:i.type,useClickAsTap:t.useClickAsTap,threshold:t.threshold||g[i.type],userEvents:t,target:e,currentTarget:i.currentTarget,initialTouch:i.target,id:i.id,pressEvent:i,_moved:!1,_finished:!1})},press:function(){this._holdTimeout=setTimeout(t.proxy(this,"_hold"),this.userEvents.minHold),this._trigger("press",this.pressEvent)},_hold:function(){this._trigger("hold",this.pressEvent)},move:function(t){if(!this._finished){if(this.x.move(t.location),this.y.move(t.location),!this._moved){if(this._withinIgnoreThreshold())return;if(T.current&&T.current!==this.userEvents)return this.dispose();this._start(t)}this._finished||this._trigger("move",t)}},end:function(t){this.endTime=c(),this._finished||(this._finished=!0,this._trigger("release",t),this._moved?this._trigger("end",t):this.useClickAsTap||this._trigger("tap",t),clearTimeout(this._holdTimeout),this.dispose())},dispose:function(){var e=this.userEvents.touches;this._finished=!0,this.pressEvent=null,clearTimeout(this._holdTimeout),e.splice(t.inArray(this,e),1)},skip:function(){this.dispose()},cancel:function(){this.dispose()},isMoved:function(){return this._moved},_start:function(t){clearTimeout(this._holdTimeout),this.startTime=c(),this._moved=!0,this._trigger("start",t)},_trigger:function(t,e){var i=e.event,n={touch:this,x:this.x,y:this.y,target:this.target,event:i};this.userEvents.notify(t,n)&&i.preventDefault()},_withinIgnoreThreshold:function(){var t=this.x.initialDelta,e=this.y.initialDelta;return Math.sqrt(t*t+e*e)<=this.threshold}}),T=h.extend({init:function(e,i){var n,a=o.guid();if(i=i||{},n=this.filter=i.filter,this.threshold=i.threshold||f,this.minHold=i.minHold||d,this.touches=[],this._maxTouches=i.multiTouch?2:1,this.allowSelection=i.allowSelection,this.captureUpIfMoved=i.captureUpIfMoved,this.useClickAsTap=!i.fastTap&&!r.delayedClick(),this.eventNS=a,e=t(e).handler(this),h.fn.init.call(this),u(this,{element:e,surface:i.global&&v?t(e[0].ownerDocument.documentElement):t(i.surface||e),stopPropagation:i.stopPropagation,pressed:!1}),this.surface.handler(this).on(o.applyEventMap("move",a),"_move").on(o.applyEventMap("up cancel",a),"_end"),e.on(o.applyEventMap("down",a),n,"_start"),this.useClickAsTap&&e.on(o.applyEventMap("click",a),n,"_click"),r.pointers||r.msPointers)if(r.browser.version<11){var c="pinch-zoom double-tap-zoom";e.css("-ms-touch-action",i.touchAction&&"none"!=i.touchAction?c+" "+i.touchAction:c)}else e.css("touch-action",i.touchAction||"none");if(i.preventDragEvent&&e.on(o.applyEventMap("dragstart",a),o.preventDefault),e.on(o.applyEventMap("mousedown",a),n,{root:e},"_select"),this.captureUpIfMoved&&r.eventCapture){var l=this.surface[0],p=t.proxy(this.preventIfMoving,this);s(function(t){l.addEventListener(t,p,!0)})}this.bind(["press","hold","tap","start","move","end","release","cancel","gesturestart","gesturechange","gestureend","gesturetap","select"],i)},preventIfMoving:function(t){this._isMoved()&&t.preventDefault()},destroy:function(){var t=this;if(!t._destroyed){if(t._destroyed=!0,t.captureUpIfMoved&&r.eventCapture){var e=t.surface[0];s(function(i){e.removeEventListener(i,t.preventIfMoving)})}t.element.kendoDestroy(t.eventNS),t.surface.kendoDestroy(t.eventNS),t.element.removeData("handler"),t.surface.removeData("handler"),t._disposeAll(),t.unbind(),delete t.surface,delete t.element,delete t.currentTarget}},capture:function(){T.current=this},cancel:function(){this._disposeAll(),this.trigger("cancel")},notify:function(t,e){var n=this.touches;if(this._isMultiTouch()){switch(t){case"move":t="gesturechange";break;case"end":t="gestureend";break;case"tap":t="gesturetap"}u(e,{touches:n},i(n[0],n[1]))}return this.trigger(t,u(e,{type:t}))},press:function(t,e,i){this._apiCall("_start",t,e,i)},move:function(t,e){this._apiCall("_move",t,e)},end:function(t,e){this._apiCall("_end",t,e)},_isMultiTouch:function(){return this.touches.length>1},_maxTouchesReached:function(){return this.touches.length>=this._maxTouches},_disposeAll:function(){for(var t=this.touches;t.length>0;)t.pop().dispose()},_isMoved:function(){return t.grep(this.touches,function(t){return t.isMoved()}).length},_select:function(t){this.allowSelection&&!this.trigger("select",{event:t})||t.preventDefault()},_start:function(e){var i,s,o=0,r=this.filter,a=n(e),h=a.length,c=e.which;if(!(c&&c>1||this._maxTouchesReached()))for(T.current=null,this.currentTarget=e.currentTarget,this.stopPropagation&&e.stopPropagation();o<h&&!this._maxTouchesReached();o++)s=a[o],(i=r?t(s.currentTarget):this.element).length&&(s=new _(this,i,s),this.touches.push(s),s.press(),this._isMultiTouch()&&this.notify("gesturestart",{}))},_move:function(t){this._eachTouch("move",t)},_end:function(t){this._eachTouch("end",t)},_click:function(e){var i={touch:{initialTouch:e.target,target:t(e.currentTarget),endTime:c(),x:{location:e.pageX,client:e.clientX},y:{location:e.pageY,client:e.clientY}},x:e.pageX,y:e.pageY,target:t(e.currentTarget),event:e,type:"tap"};this.trigger("tap",i)&&e.preventDefault()},_eachTouch:function(t,e){var i,s,o,r,a={},h=n(e),c=this.touches;for(i=0;i<c.length;i++)a[(s=c[i]).id]=s;for(i=0;i<h.length;i++)(r=a[(o=h[i]).id])&&r[t](o)},_apiCall:function(e,i,n,s){this[e]({api:!0,pageX:i,pageY:n,clientX:i,clientY:n,target:t(s||this.element)[0],stopPropagation:t.noop,preventDefault:t.noop})}});T.defaultThreshold=function(t){f=t},T.minHold=function(t){d=t},o.getTouches=n,o.touchDelta=i,o.UserEvents=T}(window.kendo.jQuery),window.kendo});