define(["Ti/_/declare","Ti/_/lang"],function(e,t){function n(e){if(c&&2==c.length&&2==e.touches.length){var t=Math.sqrt(Math.pow(e.touches[0].clientX-e.touches[1].clientX,2)+Math.pow(e.touches[0].clientY-e.touches[1].clientY,2)),n=0,u=Date.now();return o&&(n=Math.abs(o/h-t/h)/((u-l)/1e3)),o=t,l=u,{pinch:[{scale:t/h,velocity:n}]}}}var c=null,u=null,h=null,o=null,l=null,s=100;return t.setObject("Ti._.Gestures.Pinch",{processTouchStartEvent:function(e){var t=e.changedTouches[0].clientX,n=e.changedTouches[0].clientY,o=e.touches.length,l=e.changedTouches.length;1==o&&1==l?(c=[{x:t,y:n}],u=setTimeout(function(){c=null},s)):2==o&&1==l?(clearTimeout(u),c&&(c.push({x:t,y:n}),h=Math.sqrt(Math.pow(c[0].x-c[1].x,2)+Math.pow(c[0].y-c[1].y,2)))):2==o&&2==l?(c=[{x:t,y:n},{x:e.changedTouches[1].clientX,y:e.changedTouches[1].clientY}],h=Math.sqrt(Math.pow(c[0].x-c[1].x,2)+Math.pow(c[0].y-c[1].y,2))):c=null},processTouchEndEvent:function(e){var t=n(e);return c=null,t},processTouchMoveEvent:function(e){return n(e)},processTouchCancelEvent:function(){c=null}})});