var __extends=this&&this.__extends||function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}();import Interaction from"./Interaction.js";import MapBrowserEventType from"../MapBrowserEventType.js";import{getValues}from"../obj.js";var PointerInteraction=function(n){function t(t){var e=this,t=t||{},e=n.call(this,t)||this;return t.handleDownEvent&&(e.handleDownEvent=t.handleDownEvent),t.handleDragEvent&&(e.handleDragEvent=t.handleDragEvent),t.handleMoveEvent&&(e.handleMoveEvent=t.handleMoveEvent),t.handleUpEvent&&(e.handleUpEvent=t.handleUpEvent),t.stopDown&&(e.stopDown=t.stopDown),e.handlingDownUpSequence=!1,e.trackedPointers_={},e.targetPointers=[],e}return __extends(t,n),t.prototype.getPointerCount=function(){return this.targetPointers.length},t.prototype.handleDownEvent=function(t){return!1},t.prototype.handleDragEvent=function(t){},t.prototype.handleEvent=function(t){if(!t.originalEvent)return!0;var e,n=!1;return this.updateTrackedPointers_(t),this.handlingDownUpSequence?t.type==MapBrowserEventType.POINTERDRAG?(this.handleDragEvent(t),t.originalEvent.preventDefault()):t.type==MapBrowserEventType.POINTERUP&&(e=this.handleUpEvent(t),this.handlingDownUpSequence=e&&0<this.targetPointers.length):t.type==MapBrowserEventType.POINTERDOWN?(e=this.handleDownEvent(t),this.handlingDownUpSequence=e,n=this.stopDown(e)):t.type==MapBrowserEventType.POINTERMOVE&&this.handleMoveEvent(t),!n},t.prototype.handleMoveEvent=function(t){},t.prototype.handleUpEvent=function(t){return!1},t.prototype.stopDown=function(t){return t},t.prototype.updateTrackedPointers_=function(t){var e,n;isPointerDraggingEvent(t)&&(n=(e=t.originalEvent).pointerId.toString(),t.type==MapBrowserEventType.POINTERUP?delete this.trackedPointers_[n]:(t.type==MapBrowserEventType.POINTERDOWN||n in this.trackedPointers_)&&(this.trackedPointers_[n]=e),this.targetPointers=getValues(this.trackedPointers_))},t}(Interaction);function centroid(t){for(var e=t.length,n=0,r=0,o=0;o<e;o++)n+=t[o].clientX,r+=t[o].clientY;return[n/e,r/e]}function isPointerDraggingEvent(t){t=t.type;return t===MapBrowserEventType.POINTERDOWN||t===MapBrowserEventType.POINTERDRAG||t===MapBrowserEventType.POINTERUP}export default PointerInteraction;export{centroid};